What I want:
I'm trying to back up many files to S3 each day. I want to compress these into archives daily so that each individual backup doesn't cost as much. Therefore, I want a backup system whereby I can create differential archives from the previous day to be backed up to S3.
My current reasoning is to create an initial backup, and then base backups per day that are differential wrt that initial backup.
Example:
Say I have a directory named dir
containing a file, a.txt
:
dir:
a.txt
Then let's say I run rsync -r dir backup.1
, or some other backup program, such as, but not limited to, rdiff-backup
. Great stuff, I have a backup located at backup.1
.
Now, I add one file, b.txt
, so that folder
's contents is as follows:
dir:
a.txt
b.txt
Is there an rsync
, or another backup utility, command I can run that will give me a separate directory, backup.2
, that contains only the file b.txt
?
If I modify the permissions of a.txt
, will that file also be included?
What I've tried:
I've tried rsync
and rdiff-backup
, with a range of flags, but I cannot get anywhere. I've been doing it for hours now, and I cannot figure it out.
EDIT:
Halfway there!
rsync -n -rpgov backup/ backup-copy/
Please note the -n
means this does a dry-run,, so you can happily test this without wrecking your own local directories with file changes.
This outputs the difference between two local folders. However, I cannot for the life of me figure out how to get this output, through rsync
's options, to a new directory.
I've tried using rsync
's --compare-dest
flag:
rsync -n -rpgov --compare-dest=backup/ backup-copy/
but this seems to output different files to the above command.How to push this over the edge?
Best Answer
Here's the answer!
Note the complete path, and the lack of trailing slash at the end of the
--compare-dest
flag. This made the difference!