So I've finally begun cleaning up my digital mess over here and decided it was high time to automate backups. Since I have a server, it seemed and obvious choice for storing a backup of my home directory. Additionally, my server houses a few (thousand) files I'd also not like to lose - mostly family photos and I have plenty of space on my desktop to backup those.
Easy right? So I've decided a daily backup would be sufficient for now. So I made a little rsync script (one line) and put it in /etc/cron.daily:
rsync -avz --delete-after /home/stuart /backup/home
This copies my home directory to an NFS mounted share. Likely, I'll add lines to it for my install and for the photos and anything else I can think of, but before I do I have a question: It seems like a dangerous possibility that one or more of the drives could be off-line or fail and this could be catastrophic.
For example, if for some reason my /home partition became un-mounted or unreadable, wouldn't then the --delete-after option delete my backup? Obviously, this would be bad! Or in the other direction, what if the NFS share was off-line? Then the backup would be re-created entirely on the / partition under the target mount directory thus filling my root partition until it was full and this is again b-a-d!
So I think I need a way to detect the existence of one or more mounts before executing each backup command and a notification waiting for me if one of them fails.
Digging for ideas but any suggestions would be helpful. Right now I'm at:
This tests for a mount point and works correctly. Now I guess I nest IFs until I reach the desired state...
Easy right? So I've decided a daily backup would be sufficient for now. So I made a little rsync script (one line) and put it in /etc/cron.daily:
rsync -avz --delete-after /home/stuart /backup/home
This copies my home directory to an NFS mounted share. Likely, I'll add lines to it for my install and for the photos and anything else I can think of, but before I do I have a question: It seems like a dangerous possibility that one or more of the drives could be off-line or fail and this could be catastrophic.
For example, if for some reason my /home partition became un-mounted or unreadable, wouldn't then the --delete-after option delete my backup? Obviously, this would be bad! Or in the other direction, what if the NFS share was off-line? Then the backup would be re-created entirely on the / partition under the target mount directory thus filling my root partition until it was full and this is again b-a-d!
So I think I need a way to detect the existence of one or more mounts before executing each backup command and a notification waiting for me if one of them fails.
Digging for ideas but any suggestions would be helpful. Right now I'm at:
Code:
libsmount="/backup/home"; mountpoint $libsmount if [ $? -eq 0 ] ; then echo "mounted" else echo "not mounted" fi
Comment