taking advantage of filles in folder other than destination folder

Paul Slootman paul+rsync at wurtel.net
Mon May 5 13:13:30 GMT 2008


On Mon 05 May 2008, rssrik wrote:

> Suppose, 
> 
> 1. I have taken yesterdays dump in a folder named 04-05-08 in database
> server
> 2. I have rsynced the folder 04-05-08 to the backup server.
> 3. I have taken today's dump in folder named 05-05-08 in database server.
> 4. Now while doing rsync, I want rsync to compare the <database server's
> 05-05-08/dump file>  with the <04-05-08/dump file> which already exists in
> backup server. (then eventually,  I want rsync to send only the differences
> and store the output in folder 05-05-08).
> 
> Typicaly I want to take advantage of yesterday's file which already present
> in a different folder. 
> 
> Can anyone suggest a working method to implement this ? (I tried --copy-dest
> / --compare-dest .. but couldnt get it to work)

Something like this should work...

BASE=/backup/psql # edit for your situation
REMOTESOURCE=dbhost::psqldumps/ # again, edit
TODAY=`date +%d-%m-%y`  # I prefer %Y-%m-%d, sorts better
cd $BASE
YESTERDAYS_BACKUP=`ls -td ??-??-?? | head -n 1`
rsync -a --compare-dest=../$YESTERDAYS_BACKUP $REMOTESOURCE $TODAY/


Paul Slootman


More information about the rsync mailing list