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)


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.

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

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

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

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

You should have a look at the option no_create_root


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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