Difficulty: ★★★☆☆
While there are a some applications, which provide a tooling for doing incremental backups, yet there is no simple tutorial which just explain how to move a subvolume. That is the reason why I try to explain the basic steps here.
Preparation
- Install
pv
:
pamac install pv
pv
is needed to monitor the progress, when streaming or piping on the terminal, but is rather optional.
- Switch to root:
sudo --shell --user root
- Set the source and target path:
export SOURCE="/storage"
export TARGET="/backup"
export SUBVOL="@subvolume"
Copy the subvolume
- Set the subvolume read-only:
btrfs property set -t subvol ${SOURCE}/${SUBVOL} ro true
- Stream the read-only subvolume to another partition:
btrfs send ${SOURCE}/${SUBVOL} | pv | btrfs receive ${TARGET}
- Set the streamed read-only subvolume writable:
btrfs property set -t subvol ${TARGET}/${SUBVOL} ro false
- Set the source subvolume writable again:
btrfs property set -t subvol ${SOURCE}/${SUBVOL} ro false
Now the subvolume is completely copied 1:1.
At this stage, it is also possible to use rsync
to update the subvolume. Streaming of the subvolume speeds up the initial process heavily.
Move the subvolume
- Set the subvolume read-only:
btrfs property set -t subvol ${SOURCE}/${SUBVOL} ro true
- Stream the read-only subvolume to another partition:
btrfs send ${SOURCE}/${SUBVOL} | pv | btrfs receive ${TARGET}
- Set the streamed read-only subvolume writable:
btrfs property set -t subvol ${TARGET}/${SUBVOL} ro false
- Set the source subvolume writable again:
btrfs property set -t subvol ${SOURCE}/${SUBVOL} ro false
- Delete the source subvolume and therefore completely move it:
btrfs subvolume delete -c ${SOURCE}/${SUBVOL}
Now the subvolume is completely moved 1:1.
This is a wiki article. You are free to copy, share, or edit the content without restrictions as long as it doesn’t miss the main topic.