...
Skip to main content
Print

How to Transfer Files With rsync and SCP

With SCP you quickly copy individual files to your server via SSH. With rsync you synchronise entire folders and only changed files are transferred. Both work via an encrypted SSH connection, so you do not need FTP.

Copying files with SCP

A file from your computer to the server:

scp backup.zip root@JOUW-IP:/root/

A file from the server to your computer:

scp root@JOUW-IP:/root/backup.zip .

You copy an entire folder with -r. If you use a different SSH port, add -P 2222 .

Synchronising folders with rsync

Rsync transfers only new and changed files. Ideal for backups and large websites:

rsync -avz --progress ./website/ root@JOUW-IP:/var/www/website/
shellXITENS
-akeeps permissions, owner and timestamps.
-zcompresses the data during transfer.
--deletedeletes files on the server that no longer exist locally. Use this with care.

Different SSH port? Use -e "ssh -p 2222".

From Windows

SCP works directly in PowerShell on Windows 10 and 11. If you prefer a program, use WinSCP or FileZilla with the SFTP protocol.

Related articles

Table of Contents