Results 1 to 7 of 7

Thread: Rsync incremental backup script

Threaded View

  1. #1

    Rsync incremental backup script

    Hello, currently I am using rsync in a shell script to do incremental backups of a couple of systems. I know, it isn't glamorous, and can be done in much better ways, but I am trying to keep it simple, and not have to force myself to learn to program in the next... year, just to keep up. Anyways...
    I am using a fairly common script online, and I modified it a bit, just to satisfy my anal-retentiveness, and make it a bit easier to decipher. The script is as follows:


    #! /bin/bash
    #

    ################################################## #################
    # This is a script to run my backups. Put together from sources all over the 'net, it will, #
    # in theory, wake up the remote server, perform an rsync-style incremental backup, then shut #

    # the the server down. This script is a modified version of one found in an article of Linux #

    # Journal in Jan 06 titled 'Build a Home Terabyte Backup System'. I am not sure who the #
    # author was, but their script was a modified version of one created by rsync creator Andrew #
    # Tridgell. #

    ################################################## #################

    ###########

    # VARIABLES #



    # Login name

    LOGIN=ron

    # Backup server name
    BUSRVR=
    backups

    # Backup server MAC address
    BUMAC=
    xx:xx:xx:xx:xx

    # Directory to be backed up
    BUSRC=
    /home/ron/test/

    # Directory on server to back up to
    BUDEST=
    /backups/ron/rsync.test

    # This is the backup subdirectory, dictated by date and time
    BUSUBDIR=
    `date +%A`

    # Log file location

    LOGLOCATION=
    /home/ron/Desktop

    # Options to pass to rsync
    OPTS=
    "--delete -vv --modify-window=2 --force --ignore-errors --backup --backup-dir=$BUDEST/ -az --stats --partial-dir=RSYNC.PARTIAL --progress -e ssh"

    ###########

    # Commands #
    ###########

    # Dump output to log

    date
    > $LOGLOCATION/backuplog.$BUSUBDIR.txt

    # Wake up the remote server
    sudo
    /usr/local/bin/ether-wake $BUMAC

    # Wait an amount of time to allow the server to boot and get ready for data transfer

    sleep
    180

    # This section deletes the last week's incremental backups
    [
    -d /tmp/emptydir ]
    || mkdir /tmp/emptydir
    rsync --delete -a /tmp/emptydir
    $LOGIN@$BUSRVR:$BUDEST/$BUSUBDIR/
    rmdir /tmp/emptydir


    # Actual file transfer
    rsync $OPTS $BUSRC $LOGIN@$BUSRVR:$BUDEST/current >> $LOGLOCATION/backuplog.$BUSUBDIR.txt


    Can someone please explain to me how the Bold/Underlined part works? When I run the script, it does run and creates a subdirectory for 'current' and copies all source files over as it should. But when it runs the increment, it will create a another directory for the day of the week, then run a full backup to it, instead of an increment. I am just not seeing how '-d /tmp... ' is a command and can actually do something. I am a rookie to scripting though (and Linux in general, having only dealt with it for about a year). Any help would be greatly appreciated.
    Last edited by vwgtiturbo; 05-24-2006 at 10:11 PM.
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

Similar Threads

  1. backup script
    By berto in forum Linux - General Topics
    Replies: 12
    Last Post: 12-29-2009, 05:17 PM
  2. Automatic MySQL Backup Script
    By peter in forum Tutorials
    Replies: 1
    Last Post: 09-22-2009, 09:13 AM
  3. about incremental backup using tar
    By vikrant in forum Redhat / Fedora
    Replies: 1
    Last Post: 04-21-2007, 01:55 PM
  4. Automatic MySQL Backup Script
    By canela in forum Programming
    Replies: 2
    Last Post: 12-20-2006, 04:59 AM
  5. MySQl backup script
    By girlygeek in forum Programming
    Replies: 5
    Last Post: 11-11-2006, 11:23 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
  •