Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Ok, I have this in fstab

  //windows_mashine/Backup /backups cifs credentials=/root/.credentials,rw,_netdev,iocharset=utf8,uid=1000 0 0

I have rsnapshot in my cron which backups /etc/ and /usr/local/ and some other files to /backups

Recently I find that when other mashine is down and /backups cannot be mounted rsnapshot backups to physical folder /backups thus it eats partition / space. How can I avoid this?

Can I prevent any writing to /backups when it is not mounted (rsnapshot runs as root, since it need to backup some system files)

share|improve this question

3 Answers 3

up vote 14 down vote accepted

Another option is to set the directory to be immutable. To do this you need to run the following command with the mount point unmounted.

chattr +i /backups

I do this on any directory that is intended to only be a mount point just to prevent this sort of thing. Because there are situations where you're not in a position to add a check to see if something is mounted. Like if the process isn't a script that you control or it's a human that is generating or moving the data. This approach will prevent unwanted data getting written into an unmounted mount point in those situations. I would still add the mount check to your scripts so that you can output meaningful errors though.

share|improve this answer
    
It works and doesn't require to modify anything except mount point folder. Great! –  jonny Sep 21 '11 at 18:23

the easiest way to handle this is.. with rsnapshot directly.

You should have a look at the option no_create_root

HTH

share|improve this answer

Why not just have the backup script test whether /backups is mounted, and exit if not?

mount | grep -q /backups || exit 1
share|improve this answer
    
oh! good point, thanks –  jonny Sep 21 '11 at 16:47
    
just modified my crontab as if [ ! -z "$(ls /backups/)" ]; then /usr/bin/rsnapshot daily; fi; –  jonny Sep 21 '11 at 16:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.