Index: An Incremental Blog
Newer: STIL Recipes: emacs
Older: Recipe: GitHub Upload
[ Vlado Keselj | 2022-02-14 ]

Recipe: rsync-in

This is a topic that could also go under the a STIL tag (Software that I like), since I find the 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-in
would 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.


created: 2022-02-14, last update: 2022-02-14, me comments

© 2022 Vlado Keselj, last update: 23-Oct-2022