Rsync backups

My own simple rsync backup ‘script’.

You’ll need a rsync server, something to backup, and ssh-agent running to ease the process (or, fill in your password each time).

Add the following lines (using a terminal text editor) to a text file (“.rsync” for example, hidden files under Unix-like systems), and chmod +x $file.

rsync --archive -uv --exclude-from=/home/you/.rsync_exclude \
--rsh="ssh -p 222" --delete --stats --progress /Users/you/Documents/ \
[email protected]:/home/you/remote-backup-directory

This will upload any files in /Users/you/Documents to /home/you/remote-backup-directory.

It will use ssh on port 222 to transfer the files.

Just execute ./.rsync (if that’s the name of your file) to run it.

If you make any changes (locally), and run this, the changes will be applied on the remote server (e.g. file changes, renames, deletes, …) — this will delete files on the remote server if you’ve deleted them locally!

The file .rsync_exclude is optional, it includes all files or directories that should NOT be uploaded

This is what I have in my .rsync_exclude:

Nazgul:~ yeri$ cat .rsync_exclude
Parallels/*

Simple as hell, and yet so handy!


Posted by

in

, ,

Comments

Leave a Reply…