Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Sep 2006 23:27:30 +0100
From:      Alex Zbyslaw <xfb52@dial.pipex.com>
To:        Paul Schmehl <pauls@utdallas.edu>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Sync files locally?
Message-ID:  <451AFAD2.3090507@dial.pipex.com>
In-Reply-To: <765A325E54DCF1DC39EBF9AE@utd59514.utdallas.edu>
References:  <765A325E54DCF1DC39EBF9AE@utd59514.utdallas.edu>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
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









Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?451AFAD2.3090507>