[Linux Mint 20.1, 16GB RAM, 16GB swap]
I recently converted my system - root and backup partitions - to BTRFS. I've been experimenting with archiving some of root's snapshots to my backup drive, but the memory usage of the following commands brought my system to its knees:
btrfs send /.snapshots/98/snapshot | btrfs receive /media/backups/@root/.snapshots/98
This command sucked up nearly 20 GB of RAM, completely freezing my system a couple of times in the process. My root partition is using about 11 GB, not including snapshots.
My next test was using the same command within a script (original reason was to test systemd-run
and setting memory limits), like this:
#!/usr/bin/fish
btrfs send /.snapshots/98/snapshot | btrfs receive /media/backups/@root/.snapshots/98
Running this script used a grand total of 8 MB and was 4x faster. Just to be sure I was running in the same testing environment, I made sure that the original backup snapshot was deleted and committed (btrfs subvol delete -Cv
). I also ran the same tests with bash, got the same results.
UPDATE: just to make each test the same, I ran both again - in fish
and bash
- using /usr/bin/btrfs
instead of my alias (to sudo btrfs
). The results were the same.
UPDATE #2: my previous update was in error.
btrfs
is a function, which would need to buffer its output. Doestype btrfs
show something other than just an executable path?