Here in this example, We will be using the “ ssh” with the “ -e” option and perform data transfer. To specify a protocol with rsync you need to give the “ -e” option with the protocol name you want to use. Copy a File from a Remote Server to a Local Server with SSH With rsync, we can use SSH ( Secure Shell) for data transfer, using SSH protocol while transferring our data you can be ensured that your data is being transferred in a secured connection with encryption so that nobody can read your data while it is being transferred over the wire on the internet.Īlso when we use rsync we need to provide the user/ root password to accomplish that particular task, so using the SSH option will send your logins in an encrypted manner so that your password will be safe. Sent 104 bytes received 3.49M bytes 997.68K bytes/sec :~]# rsync -avzh :/root/rpmpkgs /tmp/myrpms Here in this example, a directory /root/rpmpkgs which is on a remote server is being copied in your local computer in /tmp/myrpms. This command will help you sync a remote directory to a local directory. Rsync Directory Remote System Copy/Sync a Remote Directory to a Local Machine Sent 3.74M bytes received 96 bytes 439.88K bytes/sec Warning: Permanently added '192.168.0.141' (ED25519) to the list of known hosts. The authenticity of host '192.168.0.141 (192.168.0.141)' can't be established.ĮD25519 key fingerprint is SHA256:bH2tiWQn4S5o6qmZhmtXcBROV5TU5H4t2C42QDEMx1c.Īre you sure you want to continue connecting (yes/no/)? yes For example, there is a folder in your local computer “ rpmpkgs” that contains some RPM packages and you want that local directory’s content sends to a remote server, you can use the following command. This command will sync a directory from a local machine to a remote machine. Copy/Sync Files and Directory to or From a Server Copy a Directory from Local Server to a Remote Server Sent 3.47M bytes received 96 bytes 2.32M bytes/sec ]# rsync -avzh /root/rpmpkgs /tmp/backups/ Here in this example, /root/rpmpkgs contains some rpm package files and you want that directory to be copied inside /tmp/backups/ folder. The following command will transfer or sync all the files from one directory to a different directory in the same machine. Rsync Local Files Copy/Sync a Directory on Local Computer In the above example, you can see that if the destination is not already existed rsync will create a directory automatically for the destination. Sent 224.54K bytes received 70 bytes 449.21K bytes/sec Here in this example, a file name backup.tar needs to be copied or synced to /tmp/backups/ folder. The following command will sync a single file on a local machine from one location to another location. Copy/Sync Files and Directory Locally Copy/Sync a File on a Local Computer We can install the rsync package with the help of the following command in your Linux distribution. -h : human-readable, output numbers in a human-readable format.-a : archive mode, which allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships, and timestamps.-r : copies data recursively (but don’t preserve timestamps and permission while transferring data.The basic syntax of the rsync command # rsync options source destination Some common options used with rsync commands Rsync consumes less bandwidth utilization as it uses compression and decompression method while sending and receiving data on both ends.The first time, it copies the whole content of a file or a directory from source to destination but from next time, it copies only the changed blocks and bytes to the destination. It’s faster than scp ( Secure Copy) because rsync uses a remote-update protocol which allows transferring just the differences between two sets of files.
0 Comments
Leave a Reply. |