SNAP-SYNC(8) System Manager's Manual SNAP-SYNC(8)

snap-sync - send incremental btrfs snapshots, keeping track of them with snapper

snap-sync [-c config] [-d desc] [-n] [-r address] [-p port] [--sudo] [-s subvolid] [-u UUID] [-k] [-q]

This program sends incremental snapshots to another drive for backing up data. Plug in and mount any btrfs-formatted device you want your system to be backed up to (like a USB drive). When you run the script you will be prompted to select a mounted btrfs device, or you can optionally select the disk using its UUID on the command line.

The script iterates through all snapper configurations by default (this can be changed using the -c flag). For each configuration it creates a new local snapshot. If you have never synced to the specified device you will be prompted to enter a directory on the device where the backup snapshots will go. Additionally you are shown the location of the backed up snapshot. If you have performed a backup to this device before, only the changes since the last backup have to be sent.

Use `snapper` to view the snapshots for a subvolume you have backed up. A snapshots with the description `Latest incremental backup` is kept on our local machine so that the next time `snap-sync` runs it will only transfer the difference between it and a new snapshot. Don't manually delete that snapshot unless you want to do an entirely new backup, transferring all of the data again.

-c, --config config

Specify the snapper configuration to use. Otherwise will perform for each snapper configuration. Can list multiple configurations within quotes, space-separated (e.g. -c "root home").

-d, --description desc

Change the snapper description. Default: "latest incremental backup"

-h, --help

Print the help message.

-n, --noconfirm

Do not ask for confirmation for each configuration. Will still prompt for backup directory name on first backup.

-k, --keepold

Keep the most recent local snapshot which is no longer needed. By default, after a backup is performed for a snapper configuration, the previous local snapshot is deleted since a new local snapshot is created. It's not necessary to keep all of those snapshots, but if you pass this flag, it will be kept.

-p, --port port

The remote port. Used with --remote.

-q, --quiet

Do not send notifications to notify system if it is available. Instead print notifications to stdout.

-r, --remote address

Send the snapshot backup to a remote machine. The snapshot will be sent via ssh. You should specify the remote machine's hostname or ip address. The 'root' user must be permitted to login on the remote machine.

--sudo

Use sudo on the remote machine. Only valid when used with the --remote flag.

-s, --subvolid subvolid

Specify the subvolume id of the mounted BTRFS subvolume to back up to. Defaults to 5.

-u, --UUID UUID

Specify the UUID of the mounted BTRFS subvolume to back up to. Otherwise will prompt. If multiple mount points are found with the same UUID and subvolid, will prompt user.

snap-sync

Get prompted interactively on what disks to backup to and what snapshots to send.

snap-sync --UUID 7360922b-c916-4d9f-a670-67fe0b91143c --subvolid 5 --noconfirm

Specify the UUID and subvolume of the external disk, backing up all subvolumes with a snapper configuration without promptin for confirmation.

You can create systemd unit and timer. Here is an example service:

    [Unit]
    Description=Run snap-sync backup 
    [Install]
    WantedBy=multi-user.target
    [Service]
    Type=simple
    ExecStart=/usr/bin/snap-sync --UUID 7360922b-c916-4d9f-a670-67fe0b91143c --subvolid 5 --noconfirm

And here is its corresponding timer:

    [Unit]
    Description=Run snap-sync weekly
    [Timer]
    OnCalendar=weekly
    AccuracySec=12h
    Persistent=true
    [Install]
    WantedBy=timers.target

https://github.com/wesbarnett/snap-sync

Wes Barnett wes@wbarnett.us

btrfs-send(8), snapper(8)

2021-01-24 SNAP-SYNC