I will be writing this guide as a part of my upcoming “Arch System Maintenance Guide”. When you are using Linux, you should always take regular backups. It is secure, it is stable and all that, but backup is very important to aid you in case you make a mess of your system. I will be writing the script to backup the entire system, excluding a few folders/files,etc. So here is the script.
mkdir ~/.rsync && cd ~/.rsync wget http://s2.sigmirror.com/files/53582_x8b8x/rsync.sh wget http://www.sigmirror.com/files/50262_e92yu/exclude wget http://www.sigmirror.com/files/50261_xjpd3/warn
Now, make sure you have rsync and zenity installed. If you are using Gnome, zenity should already be installed but just in-case, if you are using a Debian-based distro like ubuntu, or even Debian do:
sudo apt-get install zenity rsync
Rsync is already present there for Slackers, check out zenity at Slackbuilds. Note: This will require a few Gnome dependencies, so you can use xdialog or a Qt equivalent tool.
If you are using Xdialog instead, open the warn file and replace the zenity line with:
Xdialog --msgbox Plugin\ Your\ Backup\ Drive 10 50
Save it and exit. If for some reason cron fails to launch the Warning message box, put “DISPLAY=:0″ in front of zenity or Xdialog line.
Now, in my script I have started backup from root, excluding a few directories like /proc, /dev , and a few of my personal files. So you need to edit that file. Open the exclude file with a text editor [nano], and remove my folders [I kept them intentionally to make you do some work, lol
] and add whatever files or folders you would like to exclude from Backing up. We also exclude all .bak and .~ files from backups.
Edit the rsync.sh file to specify what drive path to use for backup. I use /media/backup in my External HDD. So replace that accordingly.
Now it’s time to edit your cron.
sudo nano /var/spool/cron/your-user-name-here 10 8 * * * ~/.rsync/warn 1> /dev/null sudo nano /var/spool/cron/root 15 8 * * * /home/username/.rsync/rsync.sh 1> /home/username/cronlog
Set the backup time according to your preference. The first field is minutes and the next one is hours. So cron warns me with a popup message box warning me to Plugin my External HDD for Backup and 5 minutes later my Backup starts. If you want to keep a weekly or monthly [not recommended!] backup instead, create your cron line easily using this.
After this save it and exit, check if the entry was created:
sudo crontab -l $USER
You may need to restart cron daemon:
sudo /etc/rc.d/crond restart
Or init.d, whatever your system uses. You can even reboot if you want to.
Also make sure all the scripts have execute permissions on them:
sudo chmod +x ~/.rsync/*
Enjoy!

7 responses to “[script] Easy Backup Solution using rsync”
hughetorrance
January 3rd, 2010 at 22:03
Well…I just keep a clone of my 64 bit Slack 13…so its easy to replace all or part of it…I have Slack 64 13 on sda9 and sdb9…
The reason for this is that I don,t really value anything on my box,the real value is what is in my head… LOL
ps I have another temporary one on sdb7 but that will be changing into something else soon.
littlebear
January 9th, 2010 at 01:58
Wow, this is very neat, I don’t do backup as I use USB stick to contain my data
les joy
January 10th, 2010 at 10:53
Once you have a backup or several backups, how do you restore the backup?
thanks,
blu…..
pdg86
January 10th, 2010 at 11:48
Manually. The point of this backup is to be on the safe-side. In case something goes wrong, suppose you delete a bunch of configs from /etc, just copy them over from your backup drive “as root”.
spc
January 25th, 2010 at 02:26
I’ve got one problem – the rsync.sh is unreadable – opening it it gvim produces gibberish – well, can’t modify it as well. Would you care to repost it as a plain text??
Tech tip usefull as always , cheers.
pdg86
January 25th, 2010 at 07:53
I have re-uploaded version 0.1.1, see if it works, or else I’ll send you the code. It’s working for me and others as well.
spc
January 26th, 2010 at 01:54
Thanks mate!
Got it and it works like a charam
6 Trackbacks / Pingbacks
Blu-ray Disc – HD Solution | Buy & Reviews Blu ray Disc Player | All Brands and Models | Best Deal Update Daily January 3rd, 2010 at 21:26
[...] [script] Easy Backup Solution using rsync « The Linux Space [...]
[script] Easy Backup Solution using rsync « The Linux Space Scripts Rss January 3rd, 2010 at 21:49
[...] the original post: [script] Easy Backup Solution using rsync « The Linux Space By admin | category: script writing | tags: 205-students, carefully-before, entire, [...]
[script] Easy Backup Solution using rsync « The Linux Space OShopping January 3rd, 2010 at 23:46
[...] original here: [script] Easy Backup Solution using rsync « The Linux Space By admin | category: linux os, os | tags: announced-the-release, end-user-solution, [...]
[script] Easy Backup Solution using rsync « The Linux Space | Linux Affinity January 4th, 2010 at 03:05
[...] here to read the rest: [script] Easy Backup Solution using rsync « The Linux Space Posted in: Kernels, Server ADD [...]
Tweets that mention [script] Easy Backup Solution using rsync « The Linux Space -- Topsy.com January 4th, 2010 at 03:51
[...] This post was mentioned on Twitter by Jake O'Riley, Ronnie Shearer and Robert Cardillo, Larry King. Larry King said: [script] Easy Backup Solution using rsync « The Linux Space http://bit.ly/4H808c #Linux [...]
IE Vulnerability February 11th, 2010 at 17:55
New Internet Explorer Vulnerability that can’t be fixed…
[...]talked about vulnerabilities in Microsoft[...]…