Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.