Hostwinds Tutorials

Search results for:


Table of Contents


Linux only
From a Unix Machine
From a Windows Machine

How to Sync a VPS to your Local Computer with rsync (Linux)

Tags: VPS,  Linux 

Linux only
From a Unix Machine
From a Windows Machine

Linux only

This guide requires rsync and will only work on Linux VPS, and will not work for a Windows VPS.

If you'd like to copy the contents of your *-nix VPS to your local machine, the rsync command makes it extremely easy to do so.

rsync is a standard tool for Unix-based operating systems that is used to sync files between directories. One nifty use of rsync is that the source and destination directories for syncing can be located on a remote server. It even works with MacOSx.

We can use this feature to sync files from the remote VPS to your localhost. This one-liner will sync all files on the VPS starting from the / directory. It will preserve permissions and ownership, and copy objects in "archive" mode, which also preserves timestamps, symlinks, and other features:

From a Unix Machine

# sudo rsync --archive root@<IP>:/* --exclude={"/tmp/","/sys/","/proc/","/dev/","/mnt/"} .
  • sudo: run the command with root privilege
  • rsync: execute the rsync command binary
  • –archive: run in archive mode, which executes recursively and preserves cross-platform data such as timestamps, symlinks, ownership, and permissions.
  • root@:/* – The username, host, and directory to copy from. Replace root with the target user on the VPS, and replace IP with the IP of the VPS
  • –exclude={"/tmp/","/sys/","/proc/","/dev/","/mnt/"} : Excludes files in tmp, sys, proc, dev, and mnt directories. These are state-exclusive directories that are generally not needed but can be copied as desired.

The command may take several minutes to complete. Once it completes, the contents of the VPS will be available on your local machine:

You will now have a copy of the contents of the VPS with the original file structures preserved.


From a Windows Machine

Windows does not provide support for the rsync command. You will need to install cygwin with the default net packages. Then you can execute the provided commands from cygwin's bash.exe.

Written by Hostwinds Team  /  June 18, 2020