Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wp-youtube-lyte domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wordpress/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wordpress/wp-includes/functions.php on line 6114
Getting Files Delta From A Remote Folder Using rsync - The Grok Shop

Getting Files Delta From A Remote Folder Using rsync

Don’t you just love a piece of software that has stood the test of time, and averted relegation to the wistful days of yore??  rsync is a perfect example of this.   How has rsync achieved this?  Well, you see, rsync is awesome!

Say you have a folder on a remote machine that you want to sync up locally.  Your first instinct might be ftp.  Haha… just kidding!  Probably more like sftp or scp.  If you are talking a handful of small files, sure those tools are ok.  For larger files, or a large amount of files, rsync is your guy.  Why?  Check it…

rsync has brains.  For starters, its faster.  But wait there’s more!  It will also figure out the diff and transfer only the diff.

Say your remote folder is:

/somePath/thumbnails/maxresdefault

Then perhaps your local folder is:

./maxresdefault

You can bring in the missing files from the remote box like so:

rsync -aP you@remoteBox:/somePath/thumbnails/maxresdefault .

This will take all files from the maxresdefault folder on the remote box – which don’t already exist in the maxresdefault folder on the local box – and copy them to the local maxresdefault folder.  Pay careful attention to the fact the local maxresdefault folder is one level down & you don’t run the command from within the local folder itself.

This  is “pull” mode. To do “push” mode, just reverse source and destination. Ie:

  Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]
  Push: rsync [OPTION...] SRC... [USER@]HOST:DEST

Note that you must have already been able to establish a normal ssh connection in order to do this.

Not only is rsync faster than sftp & scp and able figure out the diffs & only get what you are missing, but when you add the -P option (a combination of the –partial and –progress options), you get the ability to continue where you left off if you loose the connection or need to force it to stop.

The -a option means “archive mode” (another combination of a bunch of other options).  Archive mode “ensures that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer”.

rsync also works very well for automated backups, but that is another post.  Happy rsyncing!

man rsync

Sharing is caring!

Leave a Comment

Your email address will not be published. Required fields are marked *