DEV Community

Samuel John
Samuel John

Posted on

My favourite rsync commands

Below, i have collated some rsync commands that I use in my day-to-day system administration tasks.
I found rsync a better tool compared with other FTP/SFTP tools that I have used in the past. (FileZilla was my goto tool in the past).

Another thing that fascinated me and attracted me to using rsync was the need to carry out all my sysadmin/development tasks inside one gui using an IDE (I fell in love with VSCode as my favourite).

Now, let's begin:

Rsync command to copy a file/folder from local pc to a remote server

With key/certificate
$ rsync -iav /path/to/keyfile/key.pem /local/directory/path/ user@example.com:/remote/directory/path/

Enter fullscreen mode Exit fullscreen mode
Without key/certificate
$ rsync -iv /local/directory/path/ user@example.com:/remote/directory/path/
Enter fullscreen mode Exit fullscreen mode

Rsync command to copy a file/folder from remote pc/server to a local pc/server

With key/certificate
$ rsync -avzP --rsh=ssh user@example.com:/remote/directory/path/ /local/directory/path/

Enter fullscreen mode Exit fullscreen mode
Without key/certificate
$ rsync -avzP --rsh=ssh user@example.com:/remote/directory/path/ /local/directory/path/
Enter fullscreen mode Exit fullscreen mode

Rsync command to copy a file/folder from remote pc/server to another remote pc/server

$ rsync -i /path/to/keyfile/key.pem user@example.com:/path/to/file.txt user@example.org:/path/to/file

Enter fullscreen mode Exit fullscreen mode

Top comments (0)