Simple backup script

I use this script to synchronize my files from my desktop computer to my usb pendrive:

#!/bin/sh
if [ -z $1 ]; then
echo "Error: missing source path"
elif [ -z $2 ]; then
echo "Error: missing destination path"
else
rsync -arRuv --delete --files-from=$1/bin/sync.txt $1 $2
fi

Save as sync.sh, for example. If you want to know about the rsync options I use, read the fine manual.

sync.txt is a file that contains the path of the files you want to copy from your $HOME, for example:

.xinitrc
.zshrc
TODO
bin
work/geoz/mainline.tar.bz2

But it is not limited to that. You can also synchronize from your $HOME to a remote host:

./sync.sh $HOME user@host:~

This is also valid, to synchronize from a remote host to your $HOME:

./sync.sh user@host:~ $HOME

Remember to have rsync installed on the remote host.

Advertisements

About this entry