Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2012
    Location
    Wisconsin, USA
    Posts
    18
    Thanks
    0
    Thanked 2 Times in 1 Post
    Rep Power
    0

    A quick introduction to rsyc

    As a Linux noob, I recently discovered the rsync command and come to love it very quickly! Rsync stands for remote sync(hronization) and is typically used for backup operations in Linux by synchronizing files and directories from one location to another, either local or remote, in an effective way.

    Rsync is fast! The first time you sync files, rsync replicates the entire contents of the source to the destination. Once the entire source has been replicated, subsequent transfers only sync data that has been changed, rather than copy everything over again.

    Rsync allows data encryption using the SSH protocol, making is safe to use across public and other untrusted networks.

    Rsync uses less bandwidth than conventional file copying mechanisms like cp and FTP by using compression and decompression of data block by block.

    No special privileges are required to install and use rsync!

    I've already implemented rsync in a simple bash script to backup the Linux-based file server on my home network, check it out:


    Code:
    #!/bin/bash
    
    DEST1=/mnt/soho_storage/samba/shares/BACKUP_001
    DEST2=/mnt/soho_storage/samba/shares/BACKUP_002
    
    rsync -varhP --delete ./aud-books $DEST1
    rsync -varhP --delete ./aud-misc $DEST1
    rsync -varhP --delete ./aud-music $DEST1
    rsync -varhP --delete ./docs-books $DEST1
    rsync -varhP --delete ./docs-cards $DEST1
    rsync -varhP --delete ./docs-comics $DEST1
    rsync -varhP --delete ./docs-misc $DEST1
    rsync -varhP --delete ./img-misc $DEST1
    rsync -varhP --delete ./img-photos $DEST1
    rsync -varhP --delete ./sft-apps $DEST1
    rsync -varhP --delete ./sft-emu $DEST1
    rsync -varhP --delete ./sft-games $DEST1
    rsync -varhP --delete ./sft-misc $DEST1
    rsync -varhP --delete ./sft-system $DEST1
    rsync -varhP --delete ./vid-comedy $DEST1
    rsync -varhP --delete ./vid-edu $DEST1
    rsync -varhP --delete ./vid-home $DEST1
    rsync -varhP --delete ./vid-misc $DEST1
    rsync -varhP --delete ./vid-music $DEST1
    rsync -varhP --delete ./vid-toons $DEST1
    rsync -varhP --delete ./private $DEST1
    rsync -varhP --delete ./_incoming $DEST1
    
    rsync -varhP --delete ./vid-tv $DEST2
    rsync -varhP --delete ./vid-movies $DEST2
    The syntax for rsync (on this system at least) is:

    Code:
    Usage: rsync [OPTION]... SRC [SRC]... DEST
      or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
      or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
      or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
      or   rsync [OPTION]... [USER@]HOST:SRC [DEST]
      or   rsync [OPTION]... [USER@]HOST::SRC [DEST]
      or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
    The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
    to an rsync daemon, and require SRC or DEST to start with a module name.
    Use rsync --help to get the proper syntax for your system.

    The command I am using in my backup script, rsync -varhP --delete [SRC] [DEST] means "synchronize verbosely, in archive mode, recursively, with human readable numbers, preserving permissions, and deleting extraneous files in the destnation directory, the contents of [this directory] to [that directory]. I define the destination directories at the beginning of the script to make it easier to adjust them. Rather than edit every line of the script, I just edit the values of the variables at the top of the script.

    Rsync can do a whole lot more than what you see here in my little script so check it out and harness the power of rsync!

    Check out How to backup Linux? 15 rsync Command Examples for more on what you can do with the handy command.
    Last edited by encryptedbytes; 04-01-2012 at 04:18 PM.
    ~ EncryptedBytes

  2. The Following 2 Users Say Thank You to encryptedbytes For This Useful Post:

    Rob (04-02-2012),scotty (04-18-2012)




  3. #2
    Join Date
    Apr 2012
    Posts
    84
    Thanks
    5
    Thanked 1 Time in 1 Post
    Rep Power
    2
    Awesome! Thank you! I have nevr heard of the rsync command before. This looks exactly like something I would use when copying files from mounts! You are my hero!

  4. #3
    Join Date
    Oct 2011
    Location
    Dublin, PA
    Posts
    381
    Thanks
    33
    Thanked 18 Times in 16 Posts
    Rep Power
    10
    We use rsync in our backups at our hosting company.. it's a huge script, but in reality it's just rsync grabbing changed files.

 

 

Similar Threads

  1. Replies: 0
    Last Post: 01-13-2012, 03:27 PM
  2. How To: Create Custom Quick Lists in Ubuntu 11.10
    By theZUDreport in forum Linux-Howtos
    Replies: 0
    Last Post: 01-11-2012, 03:00 PM
  3. Linux games on sale - get them quick!
    By Fred in forum Linux News
    Replies: 0
    Last Post: 11-24-2011, 07:34 PM
  4. A Quick Tour Of Oracle Solaris 11
    By Fred in forum Linux News
    Replies: 0
    Last Post: 11-11-2011, 08:30 PM
  5. Replies: 0
    Last Post: 11-03-2011, 10:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
           








Check out Linux Central for Linux software and other goodies!





» Stats

Members: 3,573
Threads: 3,920
Posts: 9,442
Top Poster: Fred (1,486)
Welcome to our newest member, Ronald de Souza

» Links



Powered by vBadvanced CMPS