Skip to contents

Convenience function to restore a database from backup files. Can either import the backup for inspection or restore it as the current database.

Usage

boilerplate_restore_backup(
  category = NULL,
  backup_version = NULL,
  data_path = NULL,
  restore = FALSE,
  confirm = TRUE,
  quiet = FALSE
)

Arguments

category

Character. Category to restore, or NULL for unified database.

backup_version

Character. Specific backup timestamp (format: "YYYYMMDD_HHMMSS"), or NULL to use the latest backup.

data_path

Character. Path to directory containing backup files. If NULL (default), uses here::here("boilerplate", "data").

restore

Logical. If TRUE, saves the backup as the current standard file (overwrites existing). If FALSE (default), just returns the backup content.

confirm

Logical. If TRUE (default), asks for confirmation before overwriting. Ignored if restore = FALSE.

quiet

Logical. If TRUE, suppresses messages. Default is FALSE.

Value

The restored database (invisibly if restore = TRUE).

See also

boilerplate_list_files to see available backups, boilerplate_import for general import functionality.

Examples

if (FALSE) { # \dontrun{
# View latest methods backup without restoring
backup_db <- boilerplate_restore_backup("methods")

# Restore specific backup and overwrite current
db <- boilerplate_restore_backup(
  category = "methods",
  backup_version = "20240110_120000",
  restore = TRUE
)

# Restore latest unified backup
db <- boilerplate_restore_backup(restore = TRUE)
} # }