Yabsnap

From ArchWiki

Yabsnap is a scheduled snapshot manager for Btrfs partitions written for Arch.

Installation

Install the yabsnapAUR package, the development version can be installed from yabsnap-gitAUR.

Configuration

Run the following to create a skeleton config:

# yabsnap create-config 'configname'

This will create /etc/yabsnap/configs/confignane.conf. Edit the file to specify the following:

  • source - The location where a subvolume is mounted. E.g. /home.
  • dest_prefix - The full path and prefix for the snapshot names to be created. E.g. /.snapshot/@home- will create files snapshot backups such as /.snapshot/@home-20230525120000.

You can also edit other parameters to specify when backups will be triggered and cleaned up.

Main commands

Viewing snapshots

To review existing snapshots, use:

$ yabsnap list

Creating snapshots

To create snapshots for all configs, use:

# yabsnap create --comment 'COMMENT'

You can also restrict to a specific mounted subvolume. Yabsnap will automatically find the right config for it and use it:

# yabsnap --source '/home' create --comment 'COMMENT'

Cleaning up or deleting snapshots

Automatic cleanups

Yabsnap will automatically delete snapshots based on the configurations in /etc/yabsnap/configs/*.conf.

Deleting snapshots

You can also manually remove snapshots, with the following commands:

Specifying full path deletes a specific snapshot:

# yabsnap delete /.snapshots/@home-20230525120000

Specifying a timestamp deletes all matching snapshots that were taken together:

# yabsnap delete 20230525120000

Creating a rollback

Rollback requirement: Mount by subvol and not subvolid

It is recommended that you mount all the volumes with subvol instead of subvolid.

For example, this can be your fstab entry:

UUID=[YOUR_UUID] / btrfs rw,noatime,ssd,space_cache=v2,compress=zstd,subvol=/@ 0 0
Note: The notation used is subvol=/@. Do not use subvolid=.

The reason this works is because rollback mechanism will not edit your fstab file, it will simply ensure that the correct snapshots are mounted in the respective locations.

Rollback operation

The command for rollback is safe, until you execute the script it generates.

This generates a rollback script:

Change the timestamp to one of your existing snapshots:

$ yabsnap rollback-gen 20230525081049 | tee ~/rollback.sh

Executing the script will actually cause the rollback to happen. It is recommended that you review the generated lines before rolling back.

Once you have reviewed the generated script for your rollback, you can then make it executable then run it:

# ~/rollback.sh

This will perform a rollback of all snapshots that were taken at the specified timestamp.

Comparison with Snapper

It was created to overcome some of the shortcomings of Snapper, specifically it does the following which are difficult or impossible to do in Snapper (as of writing):

  • custom destinations for backup (related issue),
  • rollback for all configs (not just the default subvolume),
  • has integrated pacman hook support.

See also