howto setup an rsync server (debian/ubuntu)

rsync is a great tool for synchronizing 2 directories (or files) either one of them is remote and the other is local, or 2 local folders (it doesn't support synchronizing 2 remote servers, yet). the power of rsync comes from that it doesn't transfer anything unless it detects that it's changes since last run. moreover, it transfer the changes in files only (unless you specified otherwise), and it can even compress files before sending which makes it ideal for continuous backups and mirroring.

to use rsync, you have 2 options. either to start rsync daemon which handles the connections, or use it through ssh tunnel. each way has its positives and negatives. rsync daemon is indeed faster in intiating connections cause it doesn't exchange keys or encrypt data, which makes its load on the server is less too. the overhead of keeping the daemon alive is so small that you can simply ignore. the ssh tunnel doesn't require a special configuration on the server side, but you must have ssh access to the server, which means that you can't grant anonymouse access to your data. the main positive of ssh tunnel is that data is sent through the secure tunnel and can't be sniffed.

  1. to connect through ssh tunnel: first, you'll need to install rsync:
    apt-get install rsync
    then you are ready, just issue the command directly
    rsync -avz -e ssh [email protected]:/remote/dir /this/dir/
    remember to check the permissions for ssh user on the remote server. (the remote server must have rsync installed too).
  2. to connect through rsync server:
    1. install rsync:
      apt-get install rsync
    2. create "/etc/rsyncd.conf" and put the following in it:
      max connections = 1
      log file = /var/log/rsync.log
      timeout = 300
      comment = Cache of Mongrels
      path = /usr/local/cache
      read only = no
      list = yes
      uid = nobody
      gid = nogroup
      #auth users = mongrel
      list = yes
      hosts allow =
      #secrets file = /etc/rsyncd.secrets

      note that the first few lines are global (for all modules) and the other one is specital for the public module.
      comment the last two lines to grant anonymouse access, note that you can still limit by ip/netmask
    3. create ''/etc/rsyncd.secret'', and put the usernames and passwords for the ones who can access rsync, in the form of username:password , note that passwords are saved here as clear text. so don't forget to chmod it to 400 to keep the passwords somehow safe
    4. make rsync to start as daemon:
      edit ''/etc/inetd.conf'' and put the following line in the end:
      rsync stream tcp nowait root /usr/bin/rsync rsync --daemon
    5. voila, you are done, test your settings by typing:
      rsync rsync://your_ip_or_domain_name/
      this should list the modules
      rsync rsync://your_ip_or_domain_name/public
      this shuold list the files in your 'public' modules
      rsync -avz rsync://your_ip_or_domain_name/public
      synchronozing should start the transfer now.
      don't forget to check the rsync man page to check what flags do you really need.
    thanks to this page.

لم استطع تنفيذ البرنامج

هل باستطاعتك نقل الترجمة لاى العربية مع توضيح كيفية عمل

rsync -avz -e ssh [email protected]:/remote/dir /this/dir/




نقل الترجمة الى العربية يحتاج منى وقت يصعب توفيره..

بالنسبة للأمر المذكور، فقط أكتبه كما هو مع تغيير remoteuser, remotehost, /remote/dir /this/dir/ للقيم الصحيحة عندك..
من المفترض أن يعمل مباشرة

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
zero plus eight equals
Solve this math question and enter the solution with digits. E.g. for "two plus four = ?" enter "6".