These function return information on the backups of a file (if any exist)

backup_info(file, backup_dir = dirname(file))

list_backups(file, backup_dir = dirname(file))

n_backups(file, backup_dir = dirname(file))

newest_backup(file, backup_dir = dirname(file))

oldest_backup(file, backup_dir = dirname(file))



character scalar: Path to a file.


character scalar. The directory in which the backups of file are stored (defaults to dirname(file))


backup_info() returns a data.frame similar to the output of

list_backups() returns the paths to all backups of file

n_backups() returns the number of backups of file as an integer scalar

newest_backup() and oldest_backup() return the paths to the newest or oldest backup of file (or an empty character vector if none exist)


In rotor, an interval is a character string in the form "<number> <interval>". The following intervals are possible: "day(s)", "week(s)", "month(s)", "quarter(s)", "year(s)". The plural "s" is optional (so "2 weeks" and "2 week" are equivalent). Please be aware that weeks are ISOweeks and start on Monday (not Sunday as in some countries).

Interval strings can be used as arguments when backing up or rotating files, or for pruning backup queues (i.e. limiting the number of backups of a single) file.

When rotating/backing up "1 months" means "make a new backup if the last backup is from the preceding month". E.g if the last backup of myfile is from 2019-02-01 then backup_time(myfile, age = "1 month") will only create a backup if the current date is at least 2019-03-01.

When pruning/limiting backup queues, "1 year" means "keep at least most one year worth of backups". So if you call backup_time(myfile, max_backups = "1 year") on 2019-03-01, it will create a backup and then remove all backups of myfile before 2019-01-01.

See also


# setup example files tf <- tempfile("test", fileext = ".rds") saveRDS(cars, tf) backup(tf) backup(tf) backup_info(tf)
#> path name sfx ext size isdir #> 1 /tmp/RtmpFDrb0U/test215e1a2996e7.1.rds test215e1a2996e7 1 rds 289 FALSE #> 2 /tmp/RtmpFDrb0U/test215e1a2996e7.2.rds test215e1a2996e7 2 rds 289 FALSE #> mode mtime ctime atime uid gid #> 1 664 2020-01-07 09:38:05 2020-01-07 09:38:05 2020-01-07 09:38:05 1000 1000 #> 2 664 2020-01-07 09:38:05 2020-01-07 09:38:05 2020-01-07 09:38:05 1000 1000 #> uname grname index #> 1 hoelk hoelk 1 #> 2 hoelk hoelk 2
#> [1] "/tmp/RtmpFDrb0U/test215e1a2996e7.1.rds" #> [2] "/tmp/RtmpFDrb0U/test215e1a2996e7.2.rds"
#> [1] 2
#> [1] "/tmp/RtmpFDrb0U/test215e1a2996e7.1.rds"
#> [1] "/tmp/RtmpFDrb0U/test215e1a2996e7.2.rds"
# cleanup prune_backups(tf, 0) n_backups(tf)
#> [1] 0
#> [1] TRUE