Protecting your root volume from your backup programs

in #programming7 years ago

There is a common problem with filesystem based backup programs like rsnapshot or rdiff-backup, when your disk is unmounted for some reason and a backup job runs the backups will fill up your root volume and case all kinds of problems.

To get around it you may think you need to write some convoluted, unmaintainable wrapper script that makes a list of the expected devices and compares them to the currently mounted devices that kicks off the backup program if and only if the check passes.

That will work, but how long will that take you to write and test? There is a tool that comes with your operating system that gives you the exact same effect. The tool is called chattr. It is written by Remy Card [email protected] and currently maintained by Theodore Ts'o [email protected] .

You can use chattr -i on the mount point you write your backups to immutable so no files can be written to it when there is no disk mounting. When you mount your device to the mount point, the all of the directory is masked by the contents of the disk. The top level directory of the device will have the new attributes of the mount point and by default things will be able to write to it again. You can verify the attributes with the lsattr command which displays attributes. Your backup problem is solve in literally two lines of code that you had to write.

Sort:  

Thanx. I am brand new to Linux and it has been hard getting up to speed. I am taking a class and getting a good grade, but I feel like a fish out of water still.

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 64381.21
ETH 3475.67
USDT 1.00
SBD 2.50