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


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`/

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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