I made a script, to handle backups ans snapshots with btrfs to an external HD.
On short here:
You need one Subvolume for /. In this subvolume are all your other subvolumes (/home, /var/spool, ...). You only mount one subvolume for your whole system!
You need your subvolumes for manual snapshots (for example your mailserver-store in /var/spool, or your Videos ... whatever) and to exclude them from your entire system-snapshot. (You don't want .cache from your /home/user or /tmp, if it is not tmpfs!!)
The entry in /etc/fstab for your system is for a subvolume for /
Code: Select all
LABEL=SYSTEM / btrfs defaults,compress=lzo,space_cache,subvol=@debian-new 0 0
Code: Select all
LABEL=SYSTEM /var/cache/btrfs_pool_SYSTEM btrfs defaults,noauto,comment=systemd.automount,noatime,compress=lzo,space_cache 0 0
/dev/sdbX /var/cache/backup btrfs defaults,nofail,comment=systemd.automount,noauto,compress=lzo,space_cache 0 0
The commands:
Go to the directory, where the entire btrfs-partition is mounted
Code: Select all
cd /var/cache/btrfs_pool_SYSTEM
Code: Select all
mkbtrbackup create @debian-new
Code: Select all
mkbtrbackup create @debian-new --interval hourly -x
Code: Select all
mkbtrbackup transfer @debian-new.20141129-151331
Be careful, each subvolume in your snapshot is tested. If there is a new subvolume, this one is initially transferred. If you have modified the older snapshot (on the external or internal disk), datacorruption may be occur!!!
Delet a snapshot
You have 3 "stores" (I called them so for my script!!)
One is SNP. This is Your mountpoint for the btrfs-pool + a subdirectory there. Here are your snapshots stored.
The other is BKP. This is the mountpoint for your external HD + a subdirectoriy, where are the backups for your snapshots are stored.
The 3rd one is SRC. This is $PWD or the dirname of the given subvolume on the commandline.
So you can delete an entire snapshot from SNP or BKP or both together.
Delete a snapshot from your external HD
Code: Select all
mkbtrbackup delete BKP @debian-new.20141129-151331
Code: Select all
mkbtrbackup delete SNP @debian-new.20141129-151331
Code: Select all
mkbtrbackup delete SNP BKP @debian-new.20141129-151331
Code: Select all
mkbtrbackup setprop ro @debian-new.20141129-151331
Code: Select all
mkbtrbackup setprop rw @debian-new.20141129-151331
Check out http://linux.xundeenergie.at/doku.php?id=mkbtrbackup
Almost the same description is on debianforum.de https://wiki.debianforum.de/Snapshots_u ... _mit_btrfs
There is no warranity for your data, the script is bleeding edge and bugs are possible. Use it at your own risk!!!