4.21. Downloading a website from a VPS

There are several ways to download a website from the server:

  • FTP — setting up an FTP server and downloading files to a PC.
  • SFTP — downloading files to a PC without additional settings.
  • SCP — copying files directly to another server without downloading files to a PC.
  • rsync — copying files directly to another server without downloading files to a PC.

Important points:

  • When working with FTP or SFTP, the data will be downloaded to the device, thereby there is a possibility of files being damaged when transferred from device to device, as their integrity or encoding may be violated, which can lead to great inconvenience in the future.
  • FTP is faster than SFTP or SCP (no compression). When transferring a large number of files, it will be noticeably faster to upload or download data.
  • FTP is less secure than SFTP, SCP or rsync. It is highly recommended not to use it on public networks.
  • SCP (compressed) and rsync are much faster than FTP or SFTP, since data is transferred directly between servers without intermediaries. This transfer is faster and more secure in terms of the integrity of the copied files.
  • rsync is many times faster and more flexible than SCP, but it is quite difficult to create commands and it is better to use SCP for everyday tasks.
To download files via FTP, you need to set up an FTP server on the VPS. To do this, you can use, for example, ProFTPd:
  1. Install ProFTPd on a VPS.
  2. Connect to the server using any FTPclientusing the data of the user configured in ProFTPd.
  3. Go to the directory where the site is hosted (most often this will be the directory /var/www/).
  4. Download all the files you need.
To download files via SFTP, setting up a separate server on the VPS is not required, just do the following:
  1. Connect to the server using any FTPclientsupporting SFTP using SSH connection data... When setting up the connection, be sure to select the SFTP protocol and port 22.
  2. Go to the directory where the site is hosted (most often this will be the directory /var/www/).
  3. Download all the files you need.
To download files via SCP, do the following:
  1. Connect to the server via SSH.
  2. Run the copy files command recursively:
    scp -rC /var/www/example.com/* user@example.ftp.tools:~/example.com/

    Command Description:

    • -r — copying files recursively in the specified directory, that is, all files and subdirectories will be copied.
    • -C — using compression for copying. Speeds up the copying process by minimizing traffic. If you have problems with the files after copying, then it should not be used.
    • /var/www/example.com/ — the directory to be copied. Please note that at the end of the path you must specify /* to copy files without creating a directory example.com... All contents of the directory will be copied to the new server example.com.
    • user@example.ftp.tools:~/example.com/ — you need to specify SSH connection data and the target directory where the data will be copied:
      • user — SSH user.
      • example.ftp.tools — server for connecting via SSH.
      • ~/example.com/ — the target directory to which the data will be copied. It is important to consider that ~/ indicates the standard location of the user's directory, that is, it is analogous to /home/example/.
    1. After executing the command, the addition of a key may be requested «fingerprint» target server, enter yes.
    2. After completing the above steps, an empty field will appear indicating «Password:», you need to specify password from an SSH user. Attention! When entering a password or pasting it from the clipboard, characters are not displayed on the screen.
    3. If all actions were performed correctly, a list of files copied to another server will be displayed. This completes the copying process, it is worth checking the copied files on the new server.
To download files using rsync, do the following:
  1. Connect to the server via SSH.
  2. Run the copy files command recursively:
    rsync -rvz /var/www/example.com/* user@example.ftp.tools:~/example.com/

    Command Description:

    • -r — copying files recursively in the specified directory, that is, all files and subdirectories will be copied.
    • -v — detailed output of all actions when copying.
    • -z — using compression for copying. Speeds up the copying process by minimizing traffic. If you have problems with the files after copying, then it should not be used.
    • /var/www/example.com/* — the directory to be copied. Please note that at the end of the path you must specify /* to copy files without creating a directory example.com... All contents of the directory will be copied to the new server example.com.
    • user@example.ftp.tools:~/example.com/ — you need to specify SSH connection data and the target directory where the data will be copied:
      • user — SSH user.
      • example.ftp.tools — server for connecting via SSH.
      • ~/example.com/ — the target directory to which the data will be copied. It is important to consider that ~/ indicates the standard location of the user's directory, that is, it is analogous to /home/example/.
    1. After executing the command, the addition of a key may be requested «fingerprint» target server, enter yes.
    2. After completing the above steps, an empty field will appear indicating «Password:», you need to specify password from an SSH user. Attention! When entering a password or pasting it from the clipboard, characters are not displayed on the screen.
    3. If all actions were performed correctly, a list of files copied to another server will be displayed. This completes the copying process, it is worth checking the copied files on the new server.
Content