You are currently viewing a single post of this guestblog.

Click here to go back the complete page. I would be glad to hear your comments, so don’t hesitate to leave me your feedback below. It will appear on the main guestblog page.

in categories  linux  permalink:  256   posted on 01.12.2010 24:47
From Yorik

A simple backup script

I use this script at home to create a mirror effect between 2 machines, every hour the contents of a given folder on machine A get synced to a same folder on machine B. For our little 2-machine workplace, this is a pretty handy backup system. You must first setup your fstab so that you can mount a remote folder as normal user, adding something like this (changing "credential-file" by the path to your credentials file):
// /media/backup \
cifs credentials=credentials-file,uid=1000,gid=1002,rw,user,noauto 0 0
Then, save this in your exec path and make it executable:
umount /media/backup
if mount /media/backup; then
    echo "network drive mounted, performing backup... "
    rsync -rtvx --delete /path/to/my/Worksfolder /media/backup
    umount /media/backup
    logger works backup done
    echo "unmounting... done"
    echo "backup failed"
    logger works backup failed
The logger line inserts the text that follows into the syslog, which is useful so you can check later if something went wrong and when. Then, add this to your crontab (using "crontab -e"):
00 * * * * /home/yorik/bin/backup
Which means "run each minute 00" which means run every hour.

First and foremost, your name:

And your message:

To publish it, just press this ...