ANS Documentation

Improve This Doc
  • Cloud
  • Domains and DNS management
  • Backup and High Availability
  • eCommerce Stacks
  • Security
  • Email
  • Monitoring and usage management
  • Networking
  • Operating systems
    • Linux
      • Basics
      • Apache
      • Control Panels
      • FTP
      • Magento
      • Miscellaneous
      • MySQL
      • NGINX
      • PHP
      • PHP-FPM
      • Setting up Websites
      • NFS
      • VPN
      • Percona
      • SSH
      • SSL
      • Git
      • Redis
      • Elasticsearch
      • MongoDB
      • Ncdu
    • VMware ESXi
    • Windows
  • Webcelerator
  • MyUKFast
  • Home >
  • Operating systems >
  • Linux >
  • Miscellaneous >
  • Transferring files with rsync

Transferring files with rsync¶

rsync is a utility that can be used for both file transfers and file synchronisation. rsync uses the SSH protocol to transfer files. This utility can be used to transfer from a local computer to a server, the server to a local computer and also between remote server. This guide will go explain how to transfer files between remote servers.

You will need to have working server credentials for both the origin and the destination server. You will need to login to the origin server via SSH and then you will be able to start with the transfer. The syntax will need to follow the example below.

rsync /path/to/origin/dir [email protected]:/path/to/dir/destination/server

There are a lot of flags that can be added to this command that would can be found by reading the man pages for the rsync command. The below example command will use archive mode to preserve permissions (a), verbose output (v), compress the data during transfer (z), show the progress of the transfer (P) and output information in a human readable format (h). The -e flag also allows the specification of a port to use, which in this case is 2020.

rsync -avzPh -e"ssh -p2020" /path/to/dir [email protected]:/new/location/for/dir

The above example will transfer the folder /path/to/dir over to /new/location/for/dir on the remote IP. The folder will appear as /new/location/for/dir/dir. If you just wanted to transfer the contents of /path/to/dir over to /new/location/for/dir you would need to include a trailing slash on the source directory, like this:

rsync -avzPh -e"ssh -p2020" /path/to/dir/ [email protected]:/new/location/for/dir

Trailing slashes on destination directories don’t make any difference.

Next Article > The sed command

  • Useful Links
  • SMB
  • Enterprise
  • Channel
  • Public Sector
  • ANS Data Centres
  • About ANS
  • Careers
  • Blog
  • Get in touch
  •  
  • Sales 0800 458 4545
  • Support 0800 230 0032
  • Get in touch

© ANS Group Limited | Terms and Conditions | Corporate Guidance | Sitemap
ANS Group Limited, registered in England and Wales, company registration number 03176761, registered office 1 Archway, Birley Fields, Manchester M15 5QJ