Rsync Programming

Had my server setup and running Rsync nicely before to sync external HD and my folders I wanted syncing. Worked fine.

Now I’m trying to set it up for syncing my documents off my main rig to my server. (thus I want to get this right so nothing bad happens to my documents!)
Basically, I want to copy all my documents across, excluding some folders and specific files (by extension). And I want only syncing if the file is newer. If the file doesn’t exist in the source, I don’t want it copied across. File system is from a Vista system (NTFS) to a NTFS based flash drive in the server. Would the following command do it?

Guessing easiest way would be to use a shell script and two rsync commands. First updates the main PC from the server with any changed documents then copies all the changed ones from the main PC to the server.

rsync -au /home/chris/Documents /Magellan/Documents
rsync -a --exclude="-*.log" --exclude="-*.xac" --exclude="-/EVE" --exclude="-/My Games" --exclude="-*thumbs.db" /Magellan/Documents /home/chris/Documents

-a archives the data and preserves permissions. Which wont work but cos saves -r and other flags
-u to skip whatever is newer on the server (it’s an FTP server, so I’ll upload newer docs to it then want them on my main rig)
filter commands to filter out XAC, log and thumbs.db files and to exclude the directories My Games and EVE.

That still doesn’t help me sort out not sending files that exist on the server to the PC. Think is the server is there to collect ALL files and never delete them (unless I go into the server to delete them). The main PC will have it’s documents changed everyday ish and may not have everything on server. And I don’t want it to get that all, though I would like it to sync any files I might have FTP’d to the server from work.

Can anyone help or offer a suggestion?

the --existing parameter would stop the server sending files which do not exist on the PC - if that is what you are asking?

That it I think. How I missed that flag whilst looking through the commands I don’t know.

The first part of my question though I figured out myself. Because the server may get new files that I DO want copying across search for files last modified in the past 24 hours and then copy those across using grep | cp.

Also found the verbose and dry run commands so I’ll give that a try. :slight_smile:

I found this article really useful for rsync backups

http://www.mikerubel.org/computers/rsync_snapshots/

I’ve been looking into using rdiff-backup and backupninja

Well backup ninja uses rdiff which exactly the same as rsync, except it creates a change file so I can revert back to older files if I wish.