We use cookies
We use cookies to optimize our website. By continuing to browse the site, you agree to our use of cookies.
New design
Control panel
  • Русский
  • Українська
  • English
  • UAH
  • USD
  • RUB
  • EUR
  • 0-800-307-307 Hotline
  • +38 (044) 392-74-33 Kiev
  • +38 (057) 728-39-00 Kharkiv
  • +38 (056) 794-38-31 Dnipro
  • +38 (032) 229-58-93 Lviv
  • +38 (048) 738-57-70 Odessa
  • +38(093) 170-15-42  Life
  • +38 (067) 400-88-44 Kievstar
  • +1(888)393-24-51  USA, Toll free
  • +44(131)507-01-14  Great Britain
  • +7 (499) 348-28-61 Moscow

2.10.17. Create and restore a copy of site files using rsync

rsync is a utility for synchronizing files and directories between a local PC and a remote server. The data is transmitted encrypted. The transfer is performed in one stream and when resynchronizing, only the changed data is transferred, which provides a higher speed than when copying files over FTP, SFTP or SCP.

rsync is available for Linux and macOS operating systems. On Windows it can be used via WSL (Linux Subsystem for Windows).

To create a copy of the content of the site directory on a local PC, you need to run the following command in the console on this PC:

rsync -avzg --delete --progress example@example.ftp.tools:/way/to/root/catalog/site  / ~/local/catalog/

In a team:

  • Keys:
    • -a - archiving mode, recursive copying of data while maintaining symbolic links, access rights and other information.
    • -v - output of detailed information in the course of work.
    • -z - compression of transmitted data.
    • -h - information output in a human-friendly form.
    • –delete - deleting files in the destination directory that are not in the source.
    • –progress - output the progress of the transfer of each file.
  • example@example.ftp.tools - login and host from SSH connection data.
  • Paths:
    • /path/to/root/directory/site/ - full path to the directory, the contents of which should be saved on the local PC. Attention! The closing slash at the end of the path affects the location of data in the target directory - if a slash is specified, the contents of the source directory will be copied directly to the target directory, if not specified, the contents of the source directory will be copied to a subdirectory with the name of the source directory.
    • ~/local/directory/ - the directory on the local PC where you want to save the data. The trailing slash of the target directory does not matter.

After running the command, you need to enter SSH access password... When you enter it or paste it from the clipboard, characters are not displayed on the screen. In order not to enter a password each time you run the command, you just need to configure SSH key authentication.

To restore a site from a copy on a local PC, it is enough to swap the source and destination in the command:

rsync -avzg --delete ~/local/catalog/ example@example.ftp.tools:/way/to/root/catalog/site  /