Advance

How To Transfer Files Using rsync Command

How to transfer files using rsync command

[Updated on: 2021-01-04] Remote Sync is a famous command which is used to copy and synchronizes files, data, and directions remotely. You can do all these activities remotely and locally across directories (In Linux/Unix), across disks, and networks, perform data backups and mirroring between two Linux machines. Join us with this article to learn How to transfer files using rsync command. While you wish to work with Linux VPS or RDP Admin, this article would be useful to you.

Tutorial Transfer Files Using rsync Command

To let this tutorial work better, please consider the below Prerequisites:

The utility of rsync should have been installed on both the source and the destination systems. In case you have not installed it before, you can do that by distribution’s package manager:

For Ubuntu and Debian:

sudo apt install rsync

For CentOs and Fedora:

sudo yum install rsync
Recommended Article: 10 useful Linux Command Line Tricks For Newbies

Transfer Files With rsync Command Step By Step

If you work with the system remotely, using the rsync command to copy and sync files would be efficient since it supports copying links, owners, groups, and permissions. The main reason for using the rsync command is that it is faster than the Secure Copy.

The basic syntax of rsync command is as below:

rsync options source destination

The rsync command can be used to transfer files to SSH.

rsync [options] source destination  

Example: Transfer multiple files:

rsync [email protected]:/root  

Instead of the root, you can use your own username.

The rsync command also has a number of options, which are best used when using this command:

-a: Archive mode

-v: Verbose mode

-z: Compression during transfer (for faster transfer)

–progress: To display a list of submitted items

Example:

rsync -azv --progress *[email protected]:/home  

If the rsync command is interrupted, You can use the -a option. Using this option prevents files from being overwritten and only files that are not at the destination are transferred.

Recommended Article: How To Transfer Files Using rsync Command

The rsync command works by default with port 22 of the SSH protocol. If the destination server does not use port 22, you can use the following option:

--rsh='ssh -p22'  

Put your favorite port number instead of 22.

If you receive the following error while executing this command, it is because the rsync packet is not installed on the destination server.

rsync: Connection unexpectedly closed (0 bytes recived so for ) [Sender]    rsync: Error: Rewrote command not found (code 127/ atioc 456) [Sender]  

Learn Transfer Files Using rsync Command

Conclusion

In this article, you learned How To Transfer Files Using rsync Command. Using the remote-update protocol, the rsync command allows transferring just the difference between two sets of files. rsync command copies the whole content of a file or a directory from source to destination for the first time, but then, will copy the changed blocks and bytes to the destination. In case you are interested to read more, find our related article on 21 Most Used Commands in SSH and Linux.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave Your Comment

Your email address will not be published.

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+18054214518

7 days a week, 24 hours a day