I have worked on rsync for the whole afternoon. I have set a rsync server,but I don't know how to use it.

I have two machines:66 and 12. 66 is the server,I want to back 66's data to 12,so I use rsync.

I have done the following:

In 66:

sudo apt-get install xinetd 

sudo vim /etc/xinetd.d/rsync 
service rsync 
        disable         = no 
        socket_type     = stream 
        wait            = no 
        user            = root 
        server          = /usr/bin/rsync 
        server_args     = --daemon 
        log_on_failure  += USERID 

sudo nano  /etc/rsyncd.conf 

max connections = 2 
log file = /var/log/rsync.log 
timeout = 300 

  comment = Public Share 
  path = /home/wwwroot 
  read only = no 
  list = yes 
  uid = nobody 
  gid = nogroup 
  auth userusers = user 
  secrets file = /home/rsync.secrets

sudo /etc/init.d/xinetd restart  

in 12:

rsync -v  user@  /home/young001/backup --password-file=/home/rsync.pass 

and it tells:

skipping directory .

sent 4 bytes  received 6 bytes  2.86 bytes/sec
total size is 0  speedup is 0.00

the log is:

2013/06/12 03:18:18 [30477] name lookup failed for Name or service not known
2013/06/12 03:18:18 [30477] connect from UNKNOWN (
2013/06/12 10:18:18 [30477] rsync on ctp/ from young001@UNKNOWN (
2013/06/12 10:18:18 [30477] building file list
2013/06/12 10:18:18 [30477] skipping directory .
2013/06/12 10:18:18 [30477] sent 98 bytes  received 54 bytes  total size 0
2013/06/12 03:19:59 [30484] name lookup failed for Name or service not known
2013/06/12 03:19:59 [30484] connect from UNKNOWN (
2013/06/12 10:19:59 [30484] rsync on ctp/ from young001@UNKNOWN (
2013/06/12 10:19:59 [30484] building file list
2013/06/12 10:19:59 [30484] skipping directory .
2013/06/12 10:19:59 [30484] sent 98 bytes  received 54 bytes  total size 0

it seems to tell that the directory is empty,but I don't know which directory is empty.

/home/young001/backup is a empty directory,and /home/wwwroot is not a empty directory.

I want to sync wwwroot to backup,so where did I do wrong?

  • 2
    rsync isn't recursive unless you tell it to be, just like cp.
    – depquid
    Jun 12, 2013 at 14:23
  • Good tutorial: everythinglinux.org/rsync
    – slm
    Jun 12, 2013 at 16:26
  • 2
    I'm kinda sure that rsync setup and operations have been asked and answered several times in the SE groups including SuperUser and ServerFault SE. Have you consulted the archives before asking your question?
    – mdpc
    Jun 12, 2013 at 16:36

2 Answers 2


On the 12 box ( the one that is pulling the backup from the server) use this command instead:

rsync -av  user@  /home/young001/backup --password-file=/home/rsync.pass 

The -a option is the rsync archive mode : is designed to do recursion into directory and to preserve almost everything. Check rsync man.

Rsync do not copy directories recursively by defaul, you have to use -a or -r option.


1.This will sync remote directory to local directory

sudo rsync -r -a -v root@xx.xx.xx.xx:/path/to/remote/directory/ /path/to/local/directory/ 2>&1

2.this will sync local directory to remote directory

sudo rsync -r -a -v /path/to/local/directory/ root@xx.xx.xx.xx:/path/to/remote/directory/ 2>&1 

In 2>&1, 1 denotes standard output (stdout). The 2 denotes standard error (stderr).

So 2>&1 says to send standard error to where ever standard output is being redirected as well. Which since it's being sent to /dev/null is asking to ignoring any output at all.So that you can see what is the error if there is an error.

--delete : delete files that don't exist on sender (system)
-v : Verbose (try -vv for more detailed information)
-e "ssh options" : specify the ssh as remote shell
-a : archive mode
-r : recurse into directories
-z : compress file data

For more informations about rsync use this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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