[K12OSN] copying data

Les Mikesell les at futuresource.com
Wed Oct 5 22:06:10 UTC 2005


On Wed, 2005-10-05 at 11:25, Brandon Kovach wrote:
> Thanks for the idea Les.  However, I am new enough to Linux to not
> understand rsync.  Could that be the problem I am having now?  How does
> rsync work and what does it do?

Rsync is like a smarter version of cp that only copies changes if files
already exist on the target, and like scp can work over the network
using ssh.  It has about a million options, but usually you want to
cd to the source directory and:
rsync -essh -aHv . target_host:/target_path
The -essh tells it to use ssh for the connection.  If you run as root
at both ends you don't need to specify a remote user, but you could if
you wanted with the user at target_host notation.  If you haven't set up
ssh keys, you'll be prompted for the remote password.
The -a means 'archive' which is the same as setting a lot of other
options about preserving owner/attributes/timestamps, etc., plus it
turns on recursion through subdirectories.
-H means to duplicate hardlinks also.  This isn't included in -a because
it is a slow process if you have a lot of them to track.
-v  is verbose - you see the names as they are copied.
. means the current directory is the source starting point, and using
it eliminates any confusion about whether it will create an extra
directory on the target.
The last directory element of target_path will be created on the
target_host if it doesn't already exist or used if it does.

So, if you cd to /home and copy that to the other system's home it
will take everything, including the invisible files whose names
start with . that you may not want. 
If instead you cd to a user's home directory and
rsync -essh -av * target_host:/home/user
you'd only get the 'visible' files.  But you have to repeat it
for each user.  The difference is that recursing from . takes
invisible files while * expands to just the visible ones.

-- 
  Les Mikesell
   les at futuresource.com





More information about the K12OSN mailing list