Feeds:
Articles
Commentaires

Archive for septembre 2013

Before using rsync I used the following :
tar czvf "/media/extHD/BACKUPS/$(date +%Y%m%d)_HOME_DATAS.tgz" ~/ --exclude=~/.thumbnails/ /datas/ --exclude=/datas/PHOTOS/

This created a zipped archive to the present date into my external hard drive.
It backs up my home directory and /datas/ excluding files or directories as shown.
Of course I excluded more than just these two but for the purpose of this article I simplified the command line.

I was happy with this a long time but some clusters on the hard drive became defective so I am worried a whole enormous file like these backups would get corrupted as well… and lose everything.
So the only other way, using the exclude option, was rsync…

So here goes :
#!/bin/bash
rsync -av --exclude-from exclude-list.txt . ../media/extHD/BACKUPS /"$(date +%Y%m%d)_HOME_DATAS/"

I put this in a file and used chmod u+x as user to execute it when necessary.
You’ve got to write your exclude list in a file called exclude-list.txt as follows :

PHOTOS
.qt
.dbus
Downloads
.esd_auth
.texmf-var
.thumbnails

Again, this is a short list but you can make it as long as you wish. No need for exact paths, just key-words will do. Don’t forget to add everything you don’t want !
In my example the backup will start from / so if you don’t want /etc, /bin, /share etc… in your archive write them down in your exclude file.
It’s easy, just copy and paste ‘ls’ and edit a little… Make sure both files ‘exclude-list.txt’ and your script are in the same running directory /.

Edit 06/01/2015 :
Now I do this : rsync -zivar --exclude-from exclude-list.txt --delete --progress /home/dir1 /media/ext3/dir1

Publicités

Read Full Post »