The SKIRT project
advanced radiative transfer for astrophysics
Functions
pts.admin.do.create_backup Namespace Reference

Create backup archives for the SKIRT/PTS parent project. More...

Functions

"create backup archives for the SKIRT/PTS parent project" do ((int,"backup derived data (specify zero to skip)") derived=1,(int,"backup repositories (specify zero to skip)") repos=1,(str,"backup only project subdirectories starting with this name") name="")
 

Detailed Description

Create backup archives for the SKIRT/PTS parent project.

This script creates backup archives (ZIP files) for the SKIRT/PTS parent project as directed by the contents of a simple command file residing in the hierarchy of the project directory. The script assumes a directory structure similar to the following example:

<project-parent-directory>
    Backup
        create_backup.txt
        Backup--2019-01-28--10-09-27
    Benchmark9
    Functional9
    PTS9
        pts
        run
    Resources9
    SKIRT9
        git
        run

In this example, the code for this script resides in the .../PTS9/pts/admin/do directory. The file .../Backup/create_backup.txt contains backup creation instructions interpreted by this script. The ZIP archives generated by the script are placed inside a newly created directory at the same level. The target backup directory names start with time stamps that collate in date/time order.

The instruction file for the above example might contain the following text:

original    Backup          exclude Backup--*;Backup--*/*
original    Benchmark9
original    Functional9     exclude out
repository  PTS9/pts
original    Resources9/OriginalData
derived     Resources9/StoredTables
repository  SKIRT9/git
repository  Web9/git

Lines in the instruction file starting with a # character are ignored. Other than that, each line causes a ZIP archive to be created in the target backup directory. The first token on the line is one of three backup characterizations:

The second token on each line specifies the directory to be backed up, relative to the project parent directory. For the original and derived characterizations, certain files in the nested substructure can be excluded by specifying the exclude keyword followed by a glob-style pattern. The pattern can have multiple sub-patterns separated by a semicolon. Each subpattern is matched to the rightmost portion of the full absolute file path.

Note
In the current implementation of this script, the tokens (including the directory names and exclusion patterns) cannot contain whitespace and cannot be quoted.

By default, the script creates backup archives for all three characterizations. Specifying the --derived and/or –repos options to have a zero value on the command line suppresses creation of the corresponding archives. Specifying the --name=dirname restricts backup creation to the project folders starting with the specified string.