How To Sync All Files From a Remote Server to a Local Folder With rsync

To sync all files from a remote server to a local folder using rsync while ensuring the remote files remain undisturbed, you can use the following command. This example assumes that you have SSH access to the remote server:

rsync -avz --update --exclude 'wp-content/cache' user@remote-server:/path/to/wordpress/ /local/path/to/wordpress/

Explanation:

  • rsync: The command itself.
  • -a: Archive mode to preserve permissions, times, symbolic links, etc.
  • -v: Verbose output to see what’s being transferred.
  • -z: Compress file data during the transfer.
  • --update: Skip files that are newer on the receiver.
  • --exclude: To avoid syncing specific folders like the cache (optional).
  • user@remote-server: The username and hostname or IP address of the remote server.
  • /path/to/wordpress/: Path to the WordPress files on the remote server.
  • /local/path/to/wordpress/: Local path where you want to sync the files.

Make sure to replace /path/to/wordpress/ and /local/path/to/wordpress/ with the actual paths relevant to your situation. Additionally, user@remote-server should be updated with the actual username and server address.

This command will pull all WordPress files from the remote server to the local directory but will not change anything on the remote server, ensuring that the remote files remain undisturbed.