Package: btrfs-sxbackup
Btrfs snapshot backup utilityPush/pull support via SSHRetentionEmail notificationsCompression of transferred dataSyslog loggingSystem dependenciesRequiredThe following packages have to be available on both source and destinationbashbtrfs-progsThe system executing btrfs-backup requirespython3Optionalssh (for remote push/pull, not required for local operation)bash has to be set as the default remote shell for the user running the backuplzop (for compression support if desired)pv (provides progress indication if installed)sendmail (for email notifications if desired)Installationpip3 install btrfs-sxbackupSetupwhen using ssh, public/private key authentication should be set upKnown limitationsthe destination filesystem has to be mounted without the subvol option, otherwise an error will occur on btrfs receive prompting you to remount with fs treesome commands (likeupdate) may not be available for backup jobs created with older versions of btrfs-sxbackup. in this case backup jobs can be recreated usingdestroyandinit. existing snapshots will be kept as long asdestroyisnotinvoked with–purge.Usage examplesInitializeInitialize a backup job pulling snapshots of subvolume/on remote hostmyhost.orgto local subvolume/backup/myhostbtrfs-sxbackup init ssh://root@myhost.org:/ /backup/myhostInitialize a backup job pushing snapshots of local subvolume/to remote subvolume/backup/myhoston hostmybackupserver.orgbtrfs-sxbackup init / ssh://root@mybackupserver.org:/backup/myhostRunRun a backup jobbtrfs-sxbackup run /backup/myhostCronCronjob performing a pull backup job# /etc/cron.d/btrfs-sxbackup
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
30 2    * * *     root     btrfs-sxbackup run /backup/myhostSynopsis and optionsusage: btrfs-sxbackup [-h] [-q] [--version] [-v]
                      {init,destroy,update,run,info,transfer} ...

positional arguments:
  {init,destroy,update,run,info,transfer}
    init                initialize backup job
    destroy             destroy backup job
    update              update backup job
    run                 run backup job
    info                backup job info
    purge               purge backups according to retention expressions
    transfer            transfer snapshot

optional arguments:
  -h, --help            show this help message and exit
  -q, --quiet           do not log to stdout
  --version             show program's version number and exit
  -v                    can be specified multiple times to increase verbosityinitusage: btrfs-sxbackup init [-h] [-sr SOURCE_RETENTION]
                           [-dr DESTINATION_RETENTION] [-c]
                           source-subvolume destination-subvolume

positional arguments:
  source-subvolume      source subvolume to backup. local path or ssh url
  destination-subvolume
                        destination subvolume receiving backup snapshots.
                        local path or ssh url

optional arguments:
  -h, --help            show this help message and exit
  -sr SOURCE_RETENTION, --source-retention SOURCE_RETENTION
                        expression defining which source snapshots to
                        retain/cleanup. can be a static number (of backups) or
                        more complex expression like "1d:4/d, 1w:daily,
                        2m:none" literally translating to: "1 day from now
                        keep 4 backups a day, 1 week from now keep daily
                        backups, 2 months from now keep none"
  -dr DESTINATION_RETENTION, --destination-retention DESTINATION_RETENTION
                        expression defining which destination snapshots to
                        retain/cleanup. can be a static number (of backups) or
                        more complex expression (see --source-retention
                        argument)
  -c, --compress        enables compression during transmission. Requires lzop
                        to be installed on both source and destinationrunusage: btrfs-sxbackup run [-h] [-m [MAIL]] [-li LOG_IDENT]
                          subvolume [subvolume ...]

positional arguments:
  subvolume             backup job source or destination subvolume. local path
                        or SSH url

optional arguments:
  -h, --help            show this help message and exit
  -m [MAIL], --mail [MAIL]
                        enables email notifications. If an email address is
                        given, it overrides the default email-recipient
                        setting in /etc/btrfs-sxbackup.conf
  -li LOG_IDENT, --log-ident LOG_IDENT
                        log ident used for syslog logging, defaults to script
                        nameupdateusage: btrfs-sxbackup update [-h] [-sr SOURCE_RETENTION]
                             [-dr DESTINATION_RETENTION] [-c]
                             subvolume [subvolume ...]

positional arguments:
  subvolume             backup job source or destination subvolume. local path
                        or SSH url

optional arguments:
  -h, --help            show this help message and exit
  -sr SOURCE_RETENTION, --source-retention SOURCE_RETENTION
                        expression defining which source snapshots to
                        retain/cleanup. can be a static number (of backups) or
                        more complex expression like "1d:4/d, 1w:daily,
                        2m:none" literally translating to: "1 day from now
                        keep 4 backups a day, 1 week from now keep daily
                        backups, 2 months from now keep none"
  -dr DESTINATION_RETENTION, --destination-retention DESTINATION_RETENTION
                        expression defining which destination snapshots to
                        retain/cleanup. can be a static number (of backups) or
                        more complex expression (see --source-retention
                        argument)
  -c, --compress        enables compression during transmission. Requires lzop
                        to be installed on both source and destinationinfousage: btrfs-sxbackup info [-h] subvolume [subvolume ...]

positional arguments:
  subvolume   backup job source or destination subvolume. local path or SSH
              url

optional arguments:
  -h, --help  show this help message and exitpurgeusage: btrfs-sxbackup purge [-h] [-sr SOURCE_RETENTION]
                            [-dr DESTINATION_RETENTION]
                            subvolume [subvolume ...]

positional arguments:
  subvolume             backup job source or destination subvolume. local path
                        or SSH url

optional arguments:
  -h, --help            show this help message and exit
  -sr SOURCE_RETENTION, --source-retention SOURCE_RETENTION
                        Optionally override expression defining which source
                        snapshots to retain/cleanup. can be a static number
                        (of backups) or more complex expression like "1d:4/d,
                        1w:daily, 2m:none" literally translating to: "1 day
                        from now keep 4 backups a day, 1 week from now keep
                        daily backups, 2 months from now keep none"
  -dr DESTINATION_RETENTION, --destination-retention DESTINATION_RETENTION
                        Optionally override expression defining which
                        destination snapshots to retain/cleanup. can be a
                        static number (of backups) or more complex expression
                        (see --source-retention argument)destroyusage: btrfs-sxbackup destroy [-h] [--purge] subvolume [subvolume ...]

positional arguments:
  subvolume   backup job source or destination subvolume. local path or SSH
              url

optional arguments:
  -h, --help  show this help message and exit
  --purge     removes all backup snapshots from source and destinationtransferusage: btrfs-sxbackup transfer [-h] [-c]
                               source-subvolume destination-subvolume

positional arguments:
  source-subvolume      source subvolume to transfer. local path or ssh url
  destination-subvolume
                        destination subvolume. local path or ssh url

optional arguments:
  -h, --help            show this help message and exit
  -c, --compress        enables compression during transmission. Requires lzop
                        to be installed on both source and destinationChangelog0.6.10FIXED username should be checked forNonewhen building ssh url0.6.9RESOLVED #32 regression, always transferring full snapshots0.6.8RESOLVED #31 Error when destination has no snapshots0.6.7FIXED #30: full snapshot warning breaks local jobs (having no destination)RESOLVED #29: can’t destroy when destination unavailable0.6.6ADDED support for retain timespan multiplier (eg. ‘1/4m’ -> keep 1 in 4 months) and yearly timespan literal (‘y’), resolving #280.6.5RESOLVED #18, improved error output0.6.4ADDED support for falling back to transferring full snapshot if latest snapshot (timestamp) does not match on source/destination0.6.3FIXED exception during exception handling in main method0.6.2FIXED pip installation may fail with bdist/wheel0.6.1README update0.6.0ADDED support for purge command0.5.9ADDED license headers to all source files, no functional changes0.5.8FIXED job won’t run due to inconsistent  datetime comparison (offset-naive/aware)0.5.7ADDED local timestamps to info, resolving #140.5.6Fixed #13 “update” command always activates compression, regardless of -c0.5.5Fixed retention breakage which could occur when first/earliest expression kept 1 backup per interval0.5.4Python 3.3 compatibility fixesAdded proper support for relative paths passed to init0.5.0New command line interfaceSource container subvolume path is now.sxbackuprelative to the source subvolume and cannot be customized anylongerBackups created with older versions are still supported.
If you customized the source container subvolume, this will still work, but it’s recommended to rename it
to the new default (.sxbackup) and update source and destination configuration files (.btrfs-sxbackup) accordingly