Forrest
Forrest

Reputation: 35

How to backup files before overwriting them with rsync

I'm using rsync to copy/deploy only the new/modified files from dev environment to test environment. How can I backup the files (in test env) before overwriting them? Just the ones that will be overwritten.

Cheers Matteo

Upvotes: 2

Views: 2266

Answers (1)

uzsolt
uzsolt

Reputation: 6037

I think you should use --backup option of rsync. It's useful to use --backup-dir or --suffix too.

-b, --backup
With this option, preexisting destination files are renamed as
each file is transferred or deleted. You can control where the
backup file goes and what (if any) suffix gets appended using
the --backup-dir and --suffix options

Upvotes: 2

Related Questions