I'm starting to use btrfs. I want to be able to snapshot certain directories but do not want to create sub-volumes. Is this possible?
Debian – btrfs snapshots without subvolumes
btrfsdebianfilesystemslinuxsnapshot
Related Solutions
If you mean with reattaching that your btrfs subvolume list
would show:
ID 257 gen 59802 top level 5 path __active
ID 258 gen 59784 top level 5 path __snapshot
ID 259 gen 59802 top level 416 path home
ID 260 gen 36538 top level 416 path opt
ID 261 gen 59802 top level 416 path var
ID 416 gen 59784 top level 258 path __snapshot/__active
then no there is now way to do that with the btrfs-progs
.
Sub-volumes can only be deleted if all the child-subvolumes (created with btrfs subvolume create ...
) are empty, however this is not true for snapshots (which are created with btrfs subvolume snapshot ...
. Snapshots can always be deleted and so if you could move them, there would be a problem with removing the snapshot.
Although both child subvolumes and snapshots appear in the same tree structure, and even share the btrfs subvolume delete ..
command, they don't act the same.
The replace command doesn't make a backup of sda1, it replaces sda1 with sdb1 in the filesystem, but since it's a one device filesystem and btrfs doesn't bother wiping the data from sda1 when it replaces it they end up being indentical copies of the filesystem. However you do NOT want to do this as both will have the same UUID, and currently it's not safe to mount two btrfs filesystems with the same UUID as it can cause MASSIVE DATA CORRUPTION (see btrfswiki's Gotchas page). If you want to use btrfs's incremental backup feature you should format you're backup drive /dev/sdb1 to a new btrfs filesystem. Then you should make a read-only snapshot of watever subvolume(s) you want to backup on your filesystem by using
btrfs su sn -r @subvolume-name @subvolume-name-RO
on each subvolume. Then you should mount the blank btrfs filesystem and run
btrfs send /path/to/@subvolume-name-RO | btrfs rec /path/to/backup-directory/
This will be the first send and btrfs will have to transfer all of the data this time. Next time you want to send a backup to this drive you can use incremental sends to only send what data has changed since the previous backup you sent. It will also use Copy On Write so you'll save a lot of space as well. Just make sure you keep the latest snapshot on both filesystems. When it's done you can rename the sent snapshot to whatever you want.
Now if you want to send another snapshot just rename the orignal one and take a new snapshot with something like
mv @subvolume-name-RO @subvolume-name-RO-old
btrfs su sn -r @subvolume-name @subvolume-name-RO
Then you can use send to send the latest snapshot using
btrfs send -p @subvolume-name-RO-old @subvolume-name-RO | btrfs rec /path/to/backup-directory/
and if the previous snapshot still exists on your backup drive it will send your new snapshot by only having to copy whatever changes you've made since the previous one.
Best Answer
Yes. Do
cp --reflink=auto /src/dir /dest/dir
. For all practical purposes it behaves like read & write snapshot of the given directory.(If you use this command across independent btrfs partitions or outside the btrfs it will perform an ordinary copy)