rsync
tool very useful. This particular snippet
refers to a situation where we want to keep local backup of a site or a
a directory, which is either local or remote, and keep also incremental changes
in the backup.
Assuming that a remote repository is user@remote.host:some/dir
,
we would create a local Makefile
with the contents (make sure tabs
are properly entered--do not just copy and paste):
help: @echo make rsync-in .PHONY: rsync-in help rsync-in: mkdir -p dir-old # or create dir-old once rsync -av --backup --delete \ --backup-dir=../dir-old/`date +%Y-%m-%d-%H%M%S` \ user@remote.host:some/dir/ dir/and then the command:
$ make rsync-inwould properly backup the remote directory to the local local directory
dir
with old versions saved in time-stamped subdirectories of
dir-old
.
If you want to merge changes into one directory tree with different versions
saved in the same directory, you can consider using the Perl script
move-merge
.