Protect harddisk-based backup from accidental removal

by on July 28, 2006 · 0 comments· LAST UPDATED July 28, 2006

in , ,

If you store a backup on hard disk, the risk of rm -rf does exists.

Use chattr command changes the file attributes on a Linux second extended file system so that you will stay away from accidentally removing your backup files with rm -rf.

chattr command write protect the backup directory so that no one can delete it (including root). This is also known as making file immutable. For example your backup directory is /backup, type the following command to write protect directory /backup (only root can set or remove these flags):

# chattr -R +i /backup

To remove immutable flag, type the following command:

# chattr -R -i /backup

If you are using FreeBSD use chflags command to setup immutable flag:

# chflags -R schg /backup

To remove immutable flag, type the following command:

# chflags -R noschg /backup

These commands will keep you from accidentally removing your backup files with rm -rf :D

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: