--link-dest but only if rsync detects differences
Matt McCutchen
matt at mattmccutchen.net
Fri Nov 14 15:57:06 GMT 2008
On Thu, 2008-11-13 at 16:17 -0500, Daniel Jarboe wrote:
> I'm currently using rsync and --link-dest to give me something like a
> poor-man's incremental snapshot to disk. But I really only want to
> generate a new backup if rsync detects differences, otherwise I don't
> need a new backup.
>
> Currently I do something like this:
>
> rsync -a --delete --link-dest=../backup.previous/ source/
> backup.next/
> diff -r backup.previous backup.next && rm -r backup.next
>
> Is there a way to tell rsync to not even bother creating backup.next
> if there are no differences? It looks like --compare-dest will also
> recreate the directory structure when there are no differences. The
> closest I can come up with other than cleaning up after the fact is
> first running rsync with -n --stats and conditionally running rsync
> again if the output from the first run indicates new files (which
> doesn't account for deletions).
I don't believe there is any better way than the two you have suggested:
run and delete if there were no changes, or check first with -n. Note
that with the first approach, you don't need a separate diff command;
you can just use -i and check whether the itemize output is nonempty.
Matt
More information about the rsync
mailing list