BackupQueue & co are part of the R6 API of rotor. They are used internally by rotate() and related functions and are not designed for interactive use. Rather, if you are a package developer and want to integrate rotor in one of your package, the BackupQueue subclasses give you a bit of extra control.

As of now, the R6 API is still experimental and subject to change.

Methods

pad_index()

Pad the indices in the filenames of indexed backups to the number of digits of the largest index. Usually does not have to be called manually.

prune()

Delete all backups except max_backups. See prune_backups()

push_backup() <BackupQueueIndex>

Create a new backup with index 1, push back all other indices. Always calls $prune() before it terminates.

push_backup(overwrite = FALSE, now = Sys.time()) <BackupQueueDate> <BackupQueueDateteime>

Create a new backup with a timestamp. The now parameter override the real system time. If overwrite is TRUE existing backups with the same filename (i.e timestamp) are overwritten. Always calls $prune() before it terminates.

backup_dir, set_backup_dir(x)

character scalar. Set a directory in which to place the backups

cache_backups, set_cache_backups(x)

TRUE or FALSE. If TRUE (the default) the list of backups is cached, if FALSE it is read from disk every time this appender triggers. Caching brings a significant speedup for checking whether to rotate or not based on the age of the last backup, but is only safe if there are no other programs/functions (except this appender) interacting with the backups.

compression, set_compression

See compression argument of rotate()

file, set_file(x)

character scalar. The file to backup/rotate

fmt, set_fmt(x)

character scalar. See format argument of rotate_date()

max_backups, set_max_backups(x)

See max_backups argument of rotate()

should_rotate(size) <BackupQueueIndex>

Should a file of size be rotated? See size argument of rotate()

should_rotate(size, age, now = Sys.time(), last_rotation = self$last_rotation) <BackupQueueDate> <BackupQueueDateteime>

Should a file of size and age be rotated? See size and age arguments of rotate_date(). now overrides the current system time, `last_rotation`` overrides the date of the last rotation.

update_backups_cache()

Force update of the backups cache. Only does something if $cache_backups is TRUE.

Usage

x <- BackupQueueIndex$new(file, backup_dir = dirname(file), max_backups = Inf,
  compression = FALSE)

x <- BackupQueueDate$new(file, backup_dir = dirname(file), max_backups = Inf,
  compression = FALSE, fmt = "%Y-%m-%d", cache_backups = FALSE)

x <- BackupQueueDateTime$new(file, backup_dir = dirname(file), max_backups =
  Inf, compression = FALSE, fmt = "%Y-%m-%d--%H-%M-%S", cache_backups = FALSE)

x$increment_index(n = 1)
x$pad_index()
x$print()
x$prune(max_backups = self$max_backups)
x$push_backup()
x$push_backup(overwrite = FALSE, now = Sys.time())
x$set_backup_dir(x)
x$set_cache_backups(x)
x$set_compression(x)
x$set_file(x)
x$set_fmt(x)
x$set_max_backups(x)
x$should_rotate(size, age, now = Sys.time(), last_rotation = self$last_rotation %||% file.info(self$file)$ctime, verbose = FALSE)
x$should_rotate(size, verbose = FALSE)
x$update_backups_cache()

x$backup_dir
x$backups
x$cache_backups
x$compression
x$file
x$fmt
x$has_backups
x$last_rotation
x$max_backups
x$n_backups