I am learning how to use rysnc
(version 3.0.9, protocol version 30) to do backup on a toy example, from a dir /tmp/pdf
to a backup dir /tmp/backup
, following http://schlutech.com/2011/11/rsync-full-incremental-differential-snapshots/.
First is a full backup:
$ mkdir /tmp/backup
$ ls /tmp/pdf
100 bkg.pdf p1 stamp.pdf
$ rsync -a /tmp/pdf /tmp/backup/`date +%Y.%m.%d_%H:%M:%S`/
$ ls /tmp/backup/
2015.02.26_08:36:40
$ ls /tmp/backup/2015.02.26_08\:36\:40/
pdf
$ ls /tmp/backup/2015.02.26_08\:36\:40/pdf
100 bkg.pdf p1 stamp.pdf
Then I add a new pdf file into the source dir:
$ cp /tmp/linux-kernel.pdf /tmp/pdf
$ ls /tmp/pdf
100 bkg.pdf linux-kernel.pdf p1 stamp.pdf
and do a incremental backup:
$ link_dest=`find /tmp/backup -maxdepth 1 -type d | sort | tail -n 1`
$ echo $link_dest
/tmp/backup/2015.02.26_08:36:40
$ rsync -au –link-dest=${link_dest} /tmp/pdf /tmp/backup/`date +%Y.%m.%d_%H:%M:%S`/
rsync: change_dir "/tmp//–link-dest=/tmp/backup" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]
$ ls /tmp/backup/
2015.02.26_08:36:40 2015.02.26_08:55:47
$ ls /tmp/backup/2015.02.26_08\:55\:47/pdf/
100 bkg.pdf linux-kernel.pdf p1 stamp.pdf
Why is the rsync
error above? It seems the second backup has capture the change to the source, i.e. the pdf file I added after the first backup, so I don't see anything wrong?
If it were you, how would you use rsync
to do incremental backup? Thanks.