Rsync and LFTP are wonderful tools for synchronizing files. Here are various examples.


NOTE: If certificate errors prevent you from connecting to a trusted server, you can disable these errors permanently: echo “set ssl:verify-certificate false” >> ~/.lftprc

To connect to a server and mirror it to a local directory:

cd public_html
lcd /var/www/devsite/

To mirror local directory to remote: mirror -R

To exclude a folder: mirror --exclude somefolder/


Rsync is great as it can securely synchronize data over ssh, also it is very efficient as it only transfers changed blocks and bytes of files.

Syntax: rsync options source destination

Common options:

  • -v : verbose
  • -r : copies data recursively (but don’t preserve timestamps and permission while transferring data
  • -a : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
  • -z : compress file data
  • -h : human-readable, output numbers in a human-readable format
  • --exclude : items to exclude, eg. --exclude '.git/*'
  • --include : items to include
  • --delete : use with extreme caution! This will delete files and folders at the destination if they do not exist at the source.
  • --max-size : maximum size of files to transfer, eg. --max-size='200k'
  • --bwlimit : bandwidth limit, eg. --bwlimit=100
  • --dry-run : shows the output of your rsync command but does not actually manipulate any files

To use rsync over SSH to sync a remote site to local devsite:

rsync -avz -e ssh /var/www/devsite

Next Post Previous Post