Administration
  Home arrow Administration arrow Page 5 - File Synchronization With Rsync
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
ADMINISTRATION

File Synchronization With Rsync
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 91
    2002-12-04


    Table of Contents:
  • File Synchronization With Rsync
  • Getting The Skinny
  • Building Blocks
  • Temporary Insanity
  • Remote Control
  • Doing More
  • What's In A Name?
  • Mirror, Mirror, On The Wall
  • Link Out

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    File Synchronization With Rsync - Remote Control
    ( Page 5 of 9 )

    So that takes care of local sync - now how about remote sync?

    In order to synchronize files between two hosts, it's necessary to run rsync in daemon (server) mode on one of the hosts. When running in this mode, rsync exposes a list of directories on the server; any remote host running rsync can then connect to this server and copy files to or from it.

    Before you can run rsync in daemon mode, you need to configure it. This is accomplished via a configuration file, usually "/etc/rsyncd.conf" (although you can specify a different file as well, via the "--config" command-line argument). Here's an example:
     log file = /var/log/rsyncd.log
    
    [home]
       path = /home/me
       comment = My Home Area
       list = yes
       read only = no
    As you can see, this configuration file is similar to a standard Windows INI file, in that it is broken up into different sections or "modules", each containing variable-value pairs. Modules are identified by square braces around the module name, and lines beginning with semi-colons (;) or hashes (#) are treated as comments and ignored.

    The first part of the file sets up global variables for rsync to use - in this case, it specifies the log file for rsync to use. It's also possible to specify, in this section, a welcome message that is displayed when a client attempts to connect to the server.
    log file = /var/log/rsyncd.log
    motd file = /var/log/message.txt
    The second part sets up a module on the server - this is simply a directory that is available to all connecting clients. In this case, I've selected the "/home/me" directory, given it the share name "home" and set it to be writeable by all users.
    [home]
       path = /home/me
       comment = My Home Area
       list = yes
       read only = no
    The
       path = /home/me
    option tells rsync where to locate the module on the server, while the
       list = yes
    option tells it to include the module in the list returned to connecting clients.

    By default, modules on the server are not writable - that is, clients cannot upload files to the corresponding directories. This default behaviour cane be corrected via the extra
       read only = no
    option.

    Once the configuration file has been saved, it's time to start up rsync in daemon mode.
    [me@olympus] $ rsync --daemon
    If the rsync daemon starts up OK, you can attempt to connect to it from another host. Let's assume that this second host is named "xanadu", and already has rsync installed on it. What I'd like to do is transfer my home directory on "olympus" - the same one I backed up on the previous page - to "xanadu". Here's how I'd go about it:
    [me@xanadu] $  rsync  --verbose --progress --stats --recursive
    olympus::home/ .
    
    Number of files: 230
    Number of files transferred: 187
    Total file size: 1054649 bytes
    Total transferred file size: 1054649 bytes
    Literal data: 1054649 bytes
    Matched data: 0 bytes
    File list size: 4318
    Total bytes written: 3052
    Total bytes read: 1066527
    
    wrote 3052 bytes  read 1066527 bytes  713052.67 bytes/sec
    total size is 1054649  speedup is 0.99
    
    [me@xanadu] $ ls
    bin  Desktop  mail  public_html  test  tmp
    Synchronization need not be in one direction only. Using exactly the same setup as above - an rsync server on "olympus" and an rsync client on "xanadu" - it's also possible for me to transfer files in the other direction. Consider the following example, which illustrates by copying the "sql" directory to my home area on "olympus":
    [me@xanadu] $ rsync --verbose --progress --stats --recursive sql
    olympus::home/


     
     
    >>> More Administration Articles          >>> More By icarus, (c) Melonfire
     

       

    ADMINISTRATION ARTICLES

    - Network Booting via PXE: the Basics
    - Scalix: Linux Administrator`s Guide
    - Network Administration with FreeBSD 7
    - Components of an Information Architecture
    - The Anatomy of an Information Architecture
    - Configuring Load-Balanced Clusters
    - Load-Balanced Clusters
    - UNIX Time Format Demystified
    - Making Changes in the CVS
    - Building Your First CVS Repository
    - CVS Quickstart Guide
    - Authorizing Users in Samba
    - Handling User Accounts in Samba
    - Authentication in Samba
    - Accounts, Authentication, and Authorization





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek