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. As the name suggests, it allows you to specify files or directories that you don't want to sync.Rsync is a great way to synchronize files between servers or to simply move files between servers without the need of FTP. For example, the following command syncs the source directory on the local machine with the target directory on a remote machine which has the 192.168.1.7 IP address, connecting to the remote server as the user "monkey": lsyncd /path/to/source most cases, you have to provide a password to successfully connect to a remote server, so to make the command above work, you have to use the -no-daemon option which prevents the process from running as a daemon: lsyncd -no-daemon /path/to/source useful option is -exclude. This command syncs two local directories, but lsyncd can also mirror a local directory to a folder on a remote machine. The lsyncd command requires only two parameters: the source and the target directory, for example: lsyncd /path/to/source /path/to/target lsyncd is rather straightforward in use, as it features just one command and a handful of options. configure command followed by make, and make install (the latter command requires root privileges). tar.gz archive from the project's Web site, unpack it, and use the terminal to switch to the resulted directory. To install lsyncd on your machine, download the latest. If this is what you want, then you need the lsyncd tool, a command-line utility which uses rsync to synchronize (or rather mirror) local directories with a remote machine in real time. Sure, you can use cron to create scheduled backups, but even this solution cannot provide seamless live synchronization. Rsync is an excellent and versatile backup tool, but it does have one drawback: you have to run it manually when you want to back up your data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |