SOHO : Small Office Home Office
Freeware - Opensource software tips, tricks, tweaks & fixes for managing, securing, improving the performance of SOHO Desktop, Laptop, Networks

Wednesday, June 1, 2011

rsync for beginners

rsync -azv --progress --append --exclude=filename1 filename2  -e "ssh [options]" source destination

-a :  The files are transferred in "archive" mode, which ensures that symbolic links,
devices, attributes, permissions, ownerships, recursive etc 

-z : enable compression

-v : verbose

--progress : displays the progress of file transfer. This is useful if the file size is big

--append :  rsync will resume file transfer from a broken pipe.

--exclude : listed files will not be transfered.

-e : Specify the remote shell to use

Example :
rsync -azv --progress --append --exclude=sample.txt -e "ssh -p 22022" /home/user_source/ user_destination@

In the above example all the files and folder from source directory ( /home/user_source/ )  will be transfered in archive mode to the destination folder (/home/user_destination/backup/ ), where the destination computer accepts connection on port 22022. If the connection breaks, running the above command will resume the incomplete file transfer.

Importance of trailing slash

A trailing / on a source name means "copy the contents of this directory". Without a trailing slash it means "copy the directory". 


   rsync -a foo/ bar/

directory bar will end up with a copy of the contents of foo. So a file foo/wibble.txt will end up as bar/wibble.txt. If on the other hand you say:

   rsync -a foo bar/

then you end up with a directory structure 'bar/foo/...', and wibble.txt ends up as bar/foo/wibble.txt

Other than that, the presence or absence of the trailing slash on the *target* directory doesn't make a great deal of difference.  I usually try and work things so that the rsync command line always has trailing slashes on both the source and the destination directories simply for consistencies' sake.

1 comment:

  1. GSCopy Pro v6.0 (RoboCopy Alternative) with Open File Agent
    GSCopyPro is a single command-line tool (CLI) that can copy, replicate and move files from one folder to another. This folder can be on the same machine/ server or another server elsewhere. What makes GSCopyPro stand out from other competitors is the fact it works on 32-bit as well as 64-bit systems and has no restrictions. It can easily be scheduled to run as a scheduled task and fully automated. GSCopyPro also comes with an open file agent which can copy files that are locked/ opened by other processes. This feature is supported in all windows versions from widows XP/ 2003 and later.
    Go To:>>