Skip to contents

Every function that edits a .qgs in place takes backup = TRUE and copies the file first. The copy is written outside the project (#262). It used to be <name>.qgs.bak beside the file, which is itself a project file: on a Mergin project it synced to every device (14.7 MB on one field project), and it held one generation, overwritten by the next edit - seconds later, when a script calls several writers in a row.

Details

Each backup is a new generation, named <name>_<YYYYmmddHHMMSS>.qgs, with a two-digit counter (_01, _02, ...) when two land in the same second. The path is reported in the call's message. Generations live in a folder per project, named for the project directory plus a short hash of its real path, so two projects that share a directory name never share a folder.

Options

  • rfp.dir_backup - the root directory. Default tools::R_user_dir("rfp", "data")/backups.

  • rfp.backup_keep_days - a generation younger than this many days is never pruned. Default 7.

  • rfp.backup_keep - past that, the newest this many generations of each project file are kept. Default 10.

Pruning runs after each successful copy. The day floor is what keeps the copy from before a long script: with a count alone, one run of ten writers would prune every generation older than the run.

Examples

if (FALSE) { # \dontrun{
# Keep backups beside your other project archives
options(rfp.dir_backup = "~/Projects/gis/backups")

# Find a project's backups
fs::dir_ls(getOption("rfp.dir_backup"), recurse = TRUE, glob = "*hornby*")
} # }