How to manage and manage BtrFS snapshots and rollbacks on Linux?

How to manage and manage BtrFS snapshots and rollbacks on Linux?

In “ How to Manage Btrfs Storage Pools, Subvolumes And Snapshots on Linux (part 1) ” we learned how to create a nice little Btrfs test lab, and how to create a Btrfs storage volume. Now we’re going to learn how to make live snapshots whenever we want, and how to roll the filesystem back to any point to any arbitrary point in time.

Where do I find the subvolume ID in Btrfs?

Go back to the blkid example ( in part 1) to get the correct label or UUID, and then fetch your subvolume ID from the btrfs subvolume list command. Put it all together and your /etc/fstab entry looks like this: Run mount /btrfs to test it.

Can a snapshot be created in a subvolume?

You can make snapshots of snapshots, and each one is a discrete unit. Creating new subvolumes is just as easy as creating new directories, by using the btrfs command. The following examples creates three new subvolumes on a mounted top-level subvolume:

How to rename BtrFS snapshots with the same name?

If you decide you don’t need the mangled subvolume anymore you can delete it and rename the snapshot with the same name as the mangled subvolume, so you don’t have to change configuration files like /etc/stab. Use our old friend the mv command for renaming:

How are snapshots created in a Btrfs subvolume?

The snapshot subcommand creates a snapshot of the given subvolume (the /mnt/1 root volume in this case), placing that snapshot under the requested name ( /mnt/1/snapshot) in that subvolume. As a result, we now have a new subvolume called snapshot which appears to contain a full copy of everything that was in the filesystem previously.

When to use–inplace in Btrfs backups?

For rsync + btrfs snapshot backups, the –inplace rsync option might be useful. By default, when a file is changed, rsync creates a new file and moves it over the original. With –inplace, updated data is written directly to the file, so the unchanged parts can be shared among snapshots.