5

I think I'm having difficulty fully understanding subvolumes and snapshots. The /home partition is btrfs. I want to create a "backup" snapshot of /home/user (for example) but user has existed for years (previously ext4 > btrfs-convert). I believe you can only make a snapshot of a subvolume. I checked and there are no "default" subvolumes already present.

1) Is there another way for me to backup /home/user other than creating a subvolume /home/user2 and copying everything from user to user2 in order to snapshot it?

2 Answers 2

4

It is perfectly reasonable to just snapshot the whole /home if you want /home/user to be backed up. snapshots are relatively cheep.

btrfs snapshot create /home/ /home/snapshot

In Btrfs the base unit of a snapshot is the subvolume (/mount-point/ is automatically a subvolume) and you cant snapshot anything smaller. In this case your /home is the smallest thing you can snapshot. You will likely never run into problems with snapshotting all of /home and if someday you do then you're method of creating a subvolume and copying into it will work to. there is a good chance that by then btrfs will be able to create snapshots of plain old directories anyway.

1

You can create reflinks in a backup directory to everything under /home/user, which is very similar to what a snapshot is. For example you could run something like cp -rax --reflink /home/user /backup/home/user. (Both /home/user and /backup/home/user need to be on the same btrfs volume.) This will copy the directory structure and the inodes (meta-data), but the inodes will point to the same extents (containing the actual file content) as the original files. Since the actual file contents are not copied, this takes up less disk space and runs much faster than actually coping the full files. When the original file changes, the new data will be written to new extents, so the backup will still contain the old data.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .