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 |