An rsync daemon is running constantly on a server so you can push to and/or pull from that server’s assigned rsync daemon directory at any time. Now that we’ve gone over basic file/directory transferring with rsync, we can go over connecting to an rsync daemon. To test these instructions out, see our article on setting up an rsync daemon. This section requires a server running an rsync daemon. rsync -rt /home/transfer_me :/homeĪs you can see, the folder on the remote (receiving) server contains all the subdirectories and files that the local folder did on the initiating server. I then pushed the /transfer_me directory to the remote server. I have also created the directory /simple (which contains the file simple.txt) inside /transfer_me. In the below example, I have moved the pullme.txt file into a /transfer_me directory. These options will work with pushing or pulling. Using -t is good for keeping accurate records of when a file was last edited. This option will copy the date and time that the file was last changed. While we’re at it, let’s tack on the -t option. If you want to move the directory and its contents, use -r instead to recursively copy over all files and subfolders. Add the -d option, and it will move only the directory. You can push/pull any single file you specify using this method. This command will copy the file to the local server’s /home directory. The file pullme.txt is on the remote server (x.x.x.x) in the /home directory. Here is an example of a pull: rsync :/home/pullme.txt /home On the right, we did an ls before the rsync and then again after it was run, so we can see the file was copied. This command will copy the file simple.txt from our local server, to our remote server’s /home directory. Pull: rsync -e 'ssh -p PORT' :SOURCE DESTINATION Simple File Transfer Examplesįirst, we will initiate a push of a. Push: rsync -e 'ssh -p PORT' SOURCE :DESTINATION See the example below (replace PORT with the port number you need to connect to). Now, say you need to specify a port outside of the default port 22 for rsync to connect to. It can also be a hostname if you have DNS configured. X.x.x.x stands for the IP address of the remote host. The is the user on the remote host for rsync to connect with. SOURCE stands for the /directory/path/to/the/file/or/directory which will be copied.ĭESTINATION stands for the /directory/path/to/the/new/location on the receiving host. For a full list of all the options, review the manual page. Some I’ll reference and explain in examples below. The are all the different options that can be used. Let’s see the exact type of syntax below. If you specify your remote host first, it will initiate a pull. If you specify your local file first, it will initiate a push. The difference between the two is in the syntax. Rsync can push files to another server or pull files from another server. – The user needs to have permissions to use rsync (the examples below will be run as the root user). – The server doing the initiating of the transfer needs to be able to access the receiving server’s SSH port (or rsync port, if connecting to an rsync daemon). – 2 Linux servers that both have rsync installed. Below we’ll go over the basics copying between servers, copying to/from rsync daemons, and keeping files in sync with each other on different servers. The rsync daemon, covered later in this article, uses its own protocol and runs on a specified port. It connects two servers via the SSH protocol, allowing for the transfer of data between them. Rsync is a great way to synchronize files between servers or to simply move files between servers without the need of FTP.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |