Sync files locally?
Alex Zbyslaw
xfb52 at dial.pipex.com
Wed Sep 27 15:27:40 PDT 2006
Paul Schmehl wrote:
> What's the best way to sync files locally?
>
> I'm running rsync over ssh to backup files from a server. Now I'm
> setting up a new server, so I rsynced to it as well. The files end up
> in a subdir of my home directory, because my account is being used for
> the rsync. I've been using cp -R to put them in the right place on
> the server and the chmod and chown to get the perms right, but I'm
> thinking there has to be a way to sync the files locally so that only
> the ones that have changed or are new have to be copied to the right
> place.
>
> I can use find to set the perms, but I'm not sure how to sync the
> files. This is unix, so there's got to be a built-in utility that does
> this, but I can't seem to find it.
Well, rsync. When the paths are both local it won't use ssh since it
doesn't need it. Not sure why you think the files have to end up under
your home dir. Something like
rsync -a --delete /path1/ /alt/path2
will make an exact copy under /alt/path2, updating only things that need
it. Done as root it would do all the preservation of users, modes etc
regardless of ownership.
You also have --flags if you need it but it doesn't appear to work with
schg flag - maybe nouulnk and variants either.
Other than that you can use tar with pipes, which was the traditional
method Before Rsync (TM). But obviously not very efficient for keeping
a tree up-to-date.
These days cp -Rp as root should also do a one-time copy but won't
preserve any hard links.
--Alex
More information about the freebsd-questions
mailing list