On using rsync(1)

[back]


General

DESTHDD="/path/to/backups"

# get day of the year
day=$((10#`date +%j`))
switch=$[ day % 2 ]

if [ $switch -eq 0 ]
then
    dest=backup1
else
    dest=backup2
fi

rsync -avzh /path/to/work/ -e ssh uname@host:$DESTHDD/$dest
rsync -avzh --delete /path/to/work/ -e ssh uname@host:$DESTHDD/$dest

Excluding files

  1. Create a file such as exclude-file.txt and write down the files that you want to exclude in it.
  2. Execute:
DESTHDD="/path/to/target"

rsync -avzh --exclude-from='exclude-file.txt' -e ssh uname@host:$DESTHDD .
rsync -avzh --delete --exclude-from='exclude-file.txt' -e ssh uname@host:$DESTHDD .

rsyncing files from a list

In order to synchronize only files provided by a list.txt:

DESTHDD="/path/to/target"

rsync -avzh --files-from='include-file.txt' -e ssh uname@host:$DESTHDD .