Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

server1 has a filename.tgz and I need to copy it to server2. I would like to keep daily copies on server2, like:

/backup/Mon/filename.tgz
/backup/Tue/filename.tgz
...
/backup/Sun/filename.tgz

I have been reading the rsync man page, but I'm not clear on whether I should use the --backup-dir option or the --copy-dest option

I'll have a command similar to

rsync -av --copy-dir=../`date -d yesterday +%a` filename.tgz dest:/backup/`date +%a`/
share|improve this question
up vote 1 down vote accepted

I think you're overthinking it. rsync will automatically create directories, so you can just do:

rsync -v filename.tgz server2:/backup/`date -d yesterday +%a`/

Make sure you have the trailing slash, or the backup file will be called the day of the week instead.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .