Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Need help w/ rsync

I have two computers connected to the same network, say Computer A and Computer B. Computer A has some backup files in a directory that needs to be synched to Computer B(an exact mirror has to be created). Here the condition is I have to do this using rsync command.
How can I do this? Should I have to do this using hostname of the computers.
Please help me at the earliest. Thanks in advance

share|improve this question

marked as duplicate by mdpc, Khaled, Brent Pabst, John Gardeniers, Dave M Jan 31 '13 at 13:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

The rsync manual is pretty clear, and this is one of the most basic use cases. What have you tried? – ceejayoz Jan 31 '13 at 5:27
Thanks for the reply ceejayoz. Im a learner still, I dont know to this .Can you give me an example. – Rudra Jan 31 '13 at 5:31
If you're a learner then make the effort to learn. Start by reading about the commands you use. On Linux/Unix there will be one or more man pages for each. i.e. type "man rsync" at the command prompt, or type it into Google. – John Gardeniers Jan 31 '13 at 9:00
rsync src_user@src_hostname:src_dir/ trg_user@target_hostname:target_dir/

for options check

rsync --help


man rsync
share|improve this answer
Thanks for the reply Lysergia. But, Im not able to get the t syntax for this. I'm using this for now.But nothing seems to be working. – Rudra Jan 31 '13 at 5:50
What is wrong? Can you post the command you tried? – Lysergia25 Jan 31 '13 at 7:30

If you want to make it automatic you must cover some basics.

1st rsync connects trough ssh. You have to make sure the user, which you will use for rsyncing has ssh key installed on the remote computer (i will use user "root" as example).

2nd make a decision how exactly you will rsyncing (from the server to the backup-server ot from the backup-server to the server) I'll do it as the script is running on the backup server.

  • Generate key on the backup-server (run the command)


  • Copy the generated key to the remote (server which files have to be copied) computer :

    ssh-copy-id -i /root/.ssh/ root@server-ip:

now your server will connect to the remote server without asking for password. from here you can make something like this :

## Rsync script
rsync -auvz root@server-ip:/path/to/directory/ /backup-server/path/to/backup/

be aware of the fact that : 1. if you place a "/" at the end of the paths it means "syncronize the CONTENT of that directory" ( /path/to/dir/ ) 2. if you don't place a "/" it will rsync the whole directory ( /path/to/dir )

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.