btrfs snapshot when adding/removing packages - ugly hack

Here you'll find a place for solutions and hints.

Please use one of the support subforums below for questions or if you have any issues and need support.

btrfs snapshot when adding/removing packages - ugly hack

Postby neXt » Mar 30th, '14, 19:17

Hello,
I'm posting just to share with you this:

On my M4 I've finally installed / on btrfs and grub2 boot this setup, everything's working as supposed.
Code: Select all
cat /etc/fstab
# Entry for /dev/sda5 :
UUID=9d78b470-3922-4fa8-80e3-2c5658xxxxxx / btrfs noatime 1 1


We'll try to create snapshots, that's being the main purpose of using btrfs:
Code: Select all
$ sudo btrfs subvolume snapshot / /_snaphot_test
$ sudo btrfs subvolume list -a /
ID 313 gen 15625 top level 5 path _snaphot_test

All good, now let's add an extra line at the begining (2nd line is just perfect) of /usr/sbin/urpmi, /usr/sbin/urpme and /usr/libexec/drakrpm:
Code: Select all
system ("/usr/sbin/btrfs subvolume snapshot / /media/backups/root_`date +%Y_%m_%d_%H_%M`");

this will put a snapshot in /media/backups/ every time we run urpmi/urpme or gurpmi
Warning: every time an update to (g)urpmi is pushed, we'll have to edit those 3 files and make sure we readd that line into them! I's not a perfect suystem, but untill (g)urpmi will get real support for btrfs snapshot, this little trick will do it's job.

Of course, if we want to delete snapshots, we'll just do a:
Code: Select all
$ sudo btrfs subvolume delete /_snaphot_test
Delete subvolume '//_snaphot_test'

That's it, enjoy installing and removing packages without fear of losing anything and without waiting for a full backup to finish!

PS: btrfs snapshot is NOT replacing the backup! A hdd failure, or losing your laptop will render unavailable all your btrfs snapshots :) - keep doing your backups!
User avatar
neXt
 
Posts: 18
Joined: Oct 15th, '11, 21:48
Location: Le Gardeur, Canada

Re: btrfs snapshot when adding/removing packages - ugly hack

Postby doktor5000 » Mar 30th, '14, 19:36

Thanks for sharing, although this doesn't belong below General discussions.

You may want to propose this as a feature via viewtopic.php?f=2&t=7182 or via an enhancement request bug report.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17659
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany


Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 1 guest

cron