RSS feed for blog Linkin Skype Mail Me Twitter

Stickfight

rsync backup

This was something I should have got round to doing ages ago but I finally set up my laptop to backup to my NAS using rsync, and I figured a proper step by step guide might help others, there are lots of rsync guides out there but few that don’t assume loads, so here’s a simple one

GOAL: I want to backup nearly everything in my home directory onto a windows (or samba) share, I want it to be one click, not to do certain places and files and on subsequent runs only back up new stuff, I also don’t want it to inherit any fancy permissions as if I have a disaster I might need to access it without out any rights on a new machine.

I am assuming you are using ubuntu or a common version of Linux, most of this will work on the mac I suspect (I know rsync does)

SO, first thing I need is a mount or drive mapping to backup too,

1) Run “gksudo nautilus” to get a all powerful file manager and create your folder that is going to be your mount point, I created “/media/backup”

2) Next ensure you have samba file sharing utilities installed (smbfs), you can do this on a terminal prompt with “sudo apt-get install smbfs

3) See if you can now mount your share with “sudo mount -t smbfs //192.168.0.XXX/myshare/backup/ -o username=stickfight,password=password
This assumes that I am backing up to the “myshare” share on the IP address 192.168.0.XXX and into the “backup” folder that already exists, also that you have to log-on to your share to be able to write to it, if you don’t, just miss out the “-o username=stickfight,password=password” bit

4) Next you want to figure out which files and folders you DONT want to backup, in my case, I don’t want any big media files or to backup the cache folder, so I create a text file called “backupexclude.txt” save it into my home directory and type the following into it (making sure that items are on separate lines)

*.mkv
*.avi
*.ogm
*.mp4
.cache

The paths are relative so instead if /home/stickfight/.cache , as I’m backing all of /home/stickfight/ I just put “.cache”

5) install rsync “apt-get install rsync

6) Now in the terminal window you want to enter “sudo rsync -r -u —exclude-from ‘/home/stickfight/backupexclude.txt’ —progress /home/stickfight /media/backup/home

let me break it up first

“-r” = copies all the sub directories and file, normally you would use “-a” but that copies the file permissions as well which in this case I don’t want.
“-u” = Update, means it only copies only new or recently changed files.
“—exclude-from ‘/home/stickfight/backupexclude.txt’ ” = loads the exclude file we just made.
“—progress” = makes the terminal output far more readable and tells you how far it gets now.
“/home/stickfight /media/backup/home” = source and target directories.

7) run this and make sure it does what you expect, rsync has tons of options, so alter it as you see fit, once you have it working, copy both lines into a text file and save it as backup.sh (or whatever)

8) you can now run it form a icon with “sudo sh /home/stickfight/backup.sh

there we go , job done

P.S. you might notice a lot of “sudo” going on, perhaps this is not correct from a security point of view, but I’m stripping out the security anyway and I just want it to work, without complaining

Leave Your Comments

blog comments powered by Disqus

Related Entries

rsync backup

Latest Blogs