what is rsync command and how to transfer files via rsync on linux system

what is rsync command and how to transfer files via rsync on linux system

Define rsync :

‘rsync’ refers to remote sync is a command that is used to synchronizing and copying files on remotely and local machines on Unix and Linux system. ‘rsync’ command is used to copy and synchronize data on locally and remotely on Linux and Unix system via the disk, via directories and via network. With the use of rsync command you can also store the backup of your data. The rsync command is act as a mirror between two Linux machine.

Features of rsync command:

· This command is used to copy and synchronize data from remote machines.

· It transfers the files locally and remotely on Linux system.

· You can also run this command without being a root user.

· It also supports the owners, group, permissions and copying links.

· This command is used remote update protocol that allows it to transfer the differences between two files so this command copies the data in two sections, in first section it copies the whole data from files between source to destination and in second section it copies the bytes and change blocks to the destination. This feature makes it faster than others like SCP (Secure copy).

· Rsync command uses decomposition and compression method for sending and receiving data that consumes less bandwidth.

Syntax:

# rsync options source destination.

You can also use the multiple options with rsync commands that are as follow

· -r option is used to copy data recursively.

· -v option is used to verbose or diffusive.

· -a option is used to copying data in archive mode. Archive mode helps to copy data recursively and it reserved files permissions, timestamps and symbolic links.

· -z option is used to compressed data from file.

· -h option is used to output in a format that is human readable.

You can also install the rsync package with the help of following commands on your Linux system

Syntax:

# yum install rsync


Use the following commands for Debian based system.

# apt –get install rsync

You can easily installed rsync packages for both version of Linux system using the above commands.

How to Securely Transfer Files via rsync and SSH on Linux System

To securely transfer file on your server with the use of rsync and SSH use the following commands.

SSH Port:

Syntax:

rsync –avHe ssh user@server:/path/to/file/home/user/path/to/file

User: enter the remote user name that can login to remote server.

Server: hostname of remote sever.

/path/to/file: define the path of file that downloads from remote server.

/home/user/path/to/file: it define the path where you store the downloaded file from remote server.

Alternate SSH Port:

Syntax:

rsync –avHPe “ssh –pPORTNUMBER” user@server:/path/to/file /home/user/path/to/file

PortNumber: enter port number for ssh port on remote server.

User: enter the remote user name that can login to remote server.

Server: hostname of remote sever.

/path/to/file: define the path of file that downloads from remote server.

/home/user/path/to/file: it define the path where you store the downloaded file from remote server.

Commands for upload file on server:

To securely upload your file on server follows the given commands:

SSH Port:

Syntax:

rsync –avH /home/user/path/to/file –e ssh user@server:/path/to/file


you can use this command for upload file on standard SSH Port on remote server.

User: enter the remote user name that can login to remote server.

Server: hostname of remote sever.

/path/to/file:define the path of file that downloads from remote server.

/home/user/path/to/file:it define the path where you store the downloaded file from remote server.

Alternate SSH Port:

Syntax:

rsync –avHPe “ssh -pPORTNUMBER” /home/user/path/to/file –e ssh username@server:/path/to/file.

PortNumber: enter port number for ssh port on remote server.

User:enter the remote user name that can login to remote server.

Server: hostname of remote sever.

/path/to/file:define the path of file that downloads from remote server.

/home/user/path/to/file:it define the path where you store the downloaded file from remote server.

You can transfer and upload the file via rsync on remote server.
Author
Jaishree
First release
Last update
Rating
0.00 star(s) 0 ratings
Top