You know and love the well known rsync-time-backup from Laurent Cozic aka laurent22! Now what could be missing since this is a mature project? The whole thing based on separate profile files per backup case!
Example:
Consider this example profile (named user1-documents.inc
):
SOURCE="${HOME}/Documents"
TARGET="/mnt/backup-disk/Documents"
EXCLUDE_FILE="/home/user1/opt/backup-documents-excludes.lst"
Now it's as easy as this to backup our data:
rtb-wrapper.sh backup user1-documents
And here is how to restore from the latest
backup:
rtb-wrapper.sh restore user1-documents
- rsync-time-backup
- rsync
# prepare the profile folder
mkdir -p "${HOME}/.rsync_tmbackup/conf.d"
# download the script
curl -Lo "/usr/local/bin/rtb-wrapper.sh" "https://raw.githubusercontent.com/thomas-mc-work/rtb-wrapper/master/rtb-wrapper.sh"
# mark the script executable
chmod +x "/usr/local/bin/rtb-wrapper.sh"
rtb-wrapper
is using $HOME/.rsync_tmbackup
as the base config folder, except it's overridden by the environment variable RTB_CONFIG_DIR
.
$HOME/.rsync_tmbackup/conf.d/<profile-name>.inc
: The backup profiles, one per file
# the source folder
SOURCE="${HOME}/Documents"
# the target folder
TARGET="/media/user1/backup-disk/Documents"
# optional: the exclude file for rsync
EXCLUDE_FILE="${HOME}/backup-documents-excludes.lst"
# optional: wipe the source folder before restoring files? (true/false; default: false)
WIPE_SOURCE_ON_RESTORE=true
Alternatively you can define the exlcude file also by placing it next to the profile file. Following the convention:
${HOME}/.rsync-tmbackup/conf.d/<profile-name>.inc
${HOME}/.rsync-tmbackup/conf.d/<profile-name>.excludes.lst
This exclude file definition will be overriden by the definition within the profile.
There are some tests written with bats to verify your changes:
./run-tests.sh