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 email@example.com:/way/to/root/catalog/site / ~/local/catalog/
In a team:
-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.
firstname.lastname@example.org- login and host from SSH connection data.
/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/ email@example.com:/way/to/root/catalog/site /