5.7.1 Using Send/Receive to Implement Incremental Backups

The following procedure is a suggestion for setting up an incremental backup and restore process for a subvolume.

  1. Create a read-only snapshot of the subvolume to serve as an initial reference point for the backup:

    # btrfs subvolume snapshot -r /vol /vol/backup_0
  2. Run sync to ensure that the snapshot has been written to disk:

    # sync
  3. Create a subvolume or directory on a btrfs file system as a backup area to receive the snapshot, for example, /backupvol.

  4. Send the snapshot to /backupvol:

    # btrfs send /vol/backup_0 | btrfs receive /backupvol

    This command creates the subvolume /backupvol/backup_0.

    Having created the reference backup, you can then create incremental backups as required.

  5. To create an incremental backup:

    1. Create a new snapshot of the subvolume:

      # btrfs subvolume snapshot -r /vol /vol/backup_1
    2. Run sync to ensure that the snapshot has been written to disk:

      # sync
    3. Send only the differences between the reference backup and the new backup to the backup area:

      # btrfs send -p /vol/backup_0 /vol/backup_1 | btrfs receive /backupvol

      This command creates the subvolume /backupvol/backup_1.