Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.