Backup with mtree and rsync?

Lowell Gilbert freebsd-questions-local at be-well.ilk.org
Tue Jan 8 16:38:18 UTC 2013


schultz at ime.usp.br writes:

> I have been wondering whether it is possible to create a backup system
> using mtree and rsync. Essentially, the user would create a mtree
> specification of the source directory and copy it over to the destination
> directory with rsync. Any changes in the destination could then be
> detected before restoring with the mtree specification, which should
> contain strong hashes of the files and should not contain the nlink
> keyword.
>
> The problem is that mtree would be too slow. It would recompute the
> hashes of big files even when they did not change from the last backup.
> Therefore, I would like to ask if there is an easy way to accomplish
> the following.
>
> Let a mtree specification of a directory from a certain point in the
> past be given. Also, assume that a (regular) file below that directory
> has not changed if its current modification time (mtime) equals
> its modification time in the past specification.
> Produce as output the new mtree specification for the directory without
> reading these files.
>
> This is somewhat like rsync does to perform incremental backups.

Except that you have a spec for mtree to be sure the backup copy hasn't
been corrupted. 

I don't see any way to do this directly. What you probably want to do is
use find(1) to pick out the new files to check, and then merge the
changes into the old mtree(8) spec. Not trivial, but the spec syntax is
intended to be easy to parse, so it shouldn't be that hard either.

> P.S.: As an aside, is there an utility in the base system that can
> reproduce the behavior of `rsync --delete -a dir0/ dir1/`?

It's possible that the mtree support in tar(8) might be able to do it,
but it would probably be a lot slower.


More information about the freebsd-questions mailing list