Package: yarbs
YetAnotherRsyncBackupScriptCreate incremental backups using Rsync. The script takes advantage of Rsync's--link-destfunctionality to create full snapshots that save space by linking to the previously backed-up files instead of creating new copies. This has the advantage that only new or changed files are copied, but at the same time all backups appear as complete full backups on the disk.Read more here on Admin Magazine:Incremental Backups on Linux.Download and installationPackage can be installed or upgradedusing pip:python3 -m pip install --upgrade yarbsUse the appropriatepython3executable orpy -3launcher (Windows) based on your platform.DependenciesRsyncmust be installed and in path. On Debian based Linux distros (e.g. Ubuntu) can be done by:sudoaptinstallrsyncUsageDisplay help:python3 -m yarbs --help
python3 -m yarbs backup --help
python3 -m yarbs prepare --help
python3 -m yarbs sync --helpMaking a snapshot ofsrcdirectory todst:sudo python3 -m yarbs backup src dstThis will create a timestamped backup likedst/src_2018-12-31T17-00. This backup is used the next time a backup is executed as a source of links to avoid unnecessary file duplication. One a maximum a kept backups is reached, the oldest backup is removed.While still syncing, the backup directory has.tmpname suffix that is removed once finished. If an error is encountered, the directory is removed. Temporary directories are also removed every time old backups are removed, in case the directory couldn't be removed immediately. Only successfully finished backups are used for--link-dest.The-aRsync parameteris used. This among other things preserves the original file permissions (owner and group), but requires YARBS to be executed as root (i.e. withsudo). Without it, YARBS still works, but permissions are not kept.ExampleCreate dummy test directories:mkdir src
touch src/test1
touch src/test2
mkdir src/subdir
touch src/subdir/test3
mkdir dstRun the first backup ofsrctodst:sudo python3 -m yarbs backup src dstOutput:INFO : Preparing "src" backup.
INFO : Backup dir: dst/src_2019-03-03T17-12-26
INFO : Syncing "src" backup.
cd+++++++++ ./
>f+++++++++ test1
>f+++++++++ test2
cd+++++++++ subdir/
>f+++++++++ subdir/test3
INFO : Finished "src" backup.Check the backup:ls dst/src_2019-03-03T17-12-26/Output:subdir  test1  test2Run the 2nd, incremental backup:sudo python3 -m yarbs backup src dstOutput:INFO : Preparing "src" backup.
INFO : Backup dir: dst/src_2019-03-03T17-15-07
INFO : Syncing "src" backup.
INFO : Finished "src" backup.Check the backup and see that unchanged files have in fact the same Inode:stat dst/src_2019-03-03T17-12-26/test1 dst/src_2019-03-03T17-15-07/test1Output:File: 'dst/src_2019-03-03T17-12-26/test1'
...
Device: b302h/45826d    Inode: 398303      Links: 2
...
  File: 'dst/src_2019-03-03T17-15-07/test1'
...
Device: b302h/45826d    Inode: 398303      Links: 2
...Changing a file results in a new copy being made on the next backup:echo 'change' >> src/test1
sudo python3 -m yarbs backup src dstOutput:INFO : Preparing "src" backup.
INFO : Backup dir: dst/src_2019-03-03T17-20-02
INFO : Syncing "src" backup.
>f.st...... test1
INFO : Finished "src" backup.Check that then newest backup contains the changed file, with a different Inode:stat dst/src_2019-03-03T17-12-26/test1 dst/src_2019-03-03T17-15-07/test1 dst/src_2019-03-03T17-20-02/test1Output:File: 'dst/src_2019-03-03T17-12-26/test1'
...
Device: b302h/45826d    Inode: 398303      Links: 2
...
  File: 'dst/src_2019-03-03T17-15-07/test1'
...
Device: b302h/45826d    Inode: 398303      Links: 2
...
  File: 'dst/src_2019-03-03T17-20-02/test1'
...
Device: b302h/45826d    Inode: 398758      Links: 1
...Three backups now exist. Setting limit of kept backups to 3 removes the oldest backup on the next run:sudo python3 -m yarbs backup src dst --backups_kept 3Output:INFO : Preparing "src" backup.
INFO : Removing old backup: dst/src_2019-03-03T17-12-26
INFO : Backup dir: dst/src_2019-03-03T17-22-24
INFO : Syncing "src" backup.
INFO : Finished "src" backup.Preparation and synchronization can be split into individual actions. The following command:sudo python3 -m yarbs backup src dstCan be split into two steps:python3 -m yarbs prepare src dst --backups_kept 3 | sudo python3 -m yarbs sync srcThis can be useful for execution via SSH. The destination server is specified as--ssh_serverparameter:ssh myserver python3 -m yarbs -v prepare backup dst --backups_kept 3 | python3 -m yarbs -v sync src --ssh_server="myserver"Configuremyserverin your~/.ssh/configto specify user name, hostname and key/password.YARBS is also importable:fromyarbsimportbackupbackup('src','dst')