Announcement

Collapse
No announcement yet.

Set up GRsync?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Set up GRsync?

    Hi all

    I am using Grsync to backup my home directory to a USB drive. It works well and everything else I tried returned errors that stopped the entire process (keep was the worst) and it was not very reassuring to have to press "autoskip" on a backup

    My question however is this - I thought that GRsync would actually synchronise the backup location with its source. I'm satisfied that it copies any new files over, and any updated files - in fact it seems to do the lot. However, it does not appear to do a proper synchronization as I would understand it as files I have deleted from the source remain in the backup. Am I doing something wrong here, or is there an application that will do what I am seeking to achieve?

    Thanks

    Ian

    #2
    Re: Set up GRsync?

    Originally posted by The Liquidator
    Hi all

    I am using Grsync to backup my home directory to a USB drive. It works well and everything else I tried returned errors that stopped the entire process (keep was the worst) and it was not very reassuring to have to press "autoskip" on a backup

    My question however is this - I thought that GRsync would actually synchronise the backup location with its source. I'm satisfied that it copies any new files over, and any updated files - in fact it seems to do the lot. However, it does not appear to do a proper synchronization as I would understand it as files I have deleted from the source remain in the backup. Am I doing something wrong here, or is there an application that will do what I am seeking to achieve?
    Hi, Ian -

    You probably already know this but grsync is just a frontend for rsync - and by default rsync doesn't delete files on the target that no longer exist on the host. if you were trying to restore something you'd accidentally deleted it wouldn't help if your backup utility also deleted it

    I don't use the graphical frontend, I have a short script that dumps my home partition to an external drive and I run it as a nightly cron job. The script looks like this -

    rsync -rltEmqu --exclude-from=/home/wizard/.rsync/exclude /home/wizard /media/ARCHIVE/home
    rsync -rltEmqu /etc /media/ARCHIVE
    rsync -rltEmqu /boot/grub /media/ARCHIVE
    rsync -rltEmqu /var/cache/apt/archives /media/ARCHIVE/apt

    This script copies /home, /etc, /boot/grub and /var/cache/apt/archives to an external drive mounted at /media/ARCHIVE - the exclude file mentioned in the first line looks like this - everything with a trailing slash is a directory name, the rest are filenames.

    .rnd
    .gvfs/
    .VirtualBox/
    lock
    Desktop/
    download/
    temp/

    You might want to look at rsync's man page - there's a wealth of information there.

    Hope this helps -
    we see things not as they are, but as we are.
    -- anais nin

    Comment


      #3
      Re: Set up GRsync?

      Originally posted by wizard10000

      You probably already know this but grsync is just a frontend for rsync - and by default rsync doesn't delete files on the target that no longer exist on the host. if you were trying to restore something you'd accidentally deleted it wouldn't help if your backup utility also deleted it
      Thanks for your input. You make a very valid point - I suppose a failsafe would come in handy from time to time. In fact, now you mention it, my work has now changed a little, involving an element of going "back to my roots". I can actually think of some files I deleted many moons ago that I now wish I hadn't!

      Ian

      Comment


        #4
        Re: Set up GRsync?

        If you really want rsync to delete things on the backup that you've deleted locally you can use the --delete option. Along the same lines as what wizard posted, here's the script I wrote (based on Mike Rubel's rsync snapshots work). It uses hard links so that each backup doesn't take up very much space and does delete anything that is deleted in the source directory.

        Code:
        #!/bin/bash
        # Derived from [url]http://www.mikerubel.org/computers/rsync_snapshots/[/url]
        
        unset PATH
        
        # Command Locations
        ECHO=/bin/echo
        RM=/bin/rm
        MV=/bin/mv
        CP=/bin/cp
        TOUCH=/bin/touch
        MOUNT=/bin/mount
        GREP=/bin/grep
        WC=/usr/bin/wc
        RSYNC=/usr/bin/rsync
        DATE=/bin/date
        
        # File Locations
        SNAPSHOT_DIR=/media/backup
        SNAPSHOT_MAX=7
        SNAPSHOT_FILE=snapshot
        BACKUP_DIR=/home/tnorris
        RSYNC_DEST=tnorris@192.168.1.6::tnorrisbackup
        EXCLUDES=/home/tnorris/.exclude
        PASSWORD_FILE=/home/tnorris/.rsync_pw
        
        log_info () {
         $ECHO "`$DATE` - $1"
        }
        
        log_error () {
         $ECHO "`$DATE` - $1" >&2
        }
        
        log_info "Starting snapshot"
        
        # Check if BACKUP_DIR is mounted
        if [ `$MOUNT | $GREP "$SNAPSHOT_DIR" | $WC -l` -eq 0 ]; then
         log_error "Exiting. Snapshot Directory is not mounted."
         exit
        fi
        
        # Delete the oldest snapshot, if it exists:
        if [ -d $SNAPSHOT_DIR/$SNAPSHOT_FILE.$(($SNAPSHOT_MAX-1)) ]; then
         $RM -rf $SNAPSHOT_DIR/$SNAPSHOT_FILE.$(($SNAPSHOT_MAX-1))
         status=$?
         if [ $status -eq 0 ]
         then
          log_info "Removed $SNAPSHOT_DIR/$SNAPSHOT_FILE.$(($SNAPSHOT_MAX-1))"
         else
          log_error "Removal of $SNAPSHOT_DIR/$SNAPSHOT_FILE.$(($SNAPSHOT_MAX-1)) failed."
          exit $status
         fi
        fi
        
        # Shift each snapshot back one
        for ((i=($SNAPSHOT_MAX-2); i>=0; i--))
        do
         FROM=$i
         TO=$(($i+1))
         if [ -d $SNAPSHOT_DIR/$SNAPSHOT_FILE.$FROM ]; then
          $MV $SNAPSHOT_DIR/$SNAPSHOT_FILE.$FROM $SNAPSHOT_DIR/$SNAPSHOT_FILE.$TO
          status=$?
          if [ $status -eq 0 ]
          then
           log_info "Moved $SNAPSHOT_DIR/$SNAPSHOT_FILE.$FROM to $SNAPSHOT_DIR/$SNAPSHOT_FILE.$TO"
          else
           log_error "Move of $SNAPSHOT_DIR/$SNAPSHOT_FILE.$FROM to $SNAPSHOT_DIR/$SNAPSHOT_FILE.$TO failed."
           exit $status
          fi
         fi
        done
        
        # rsync from the $BACKUP_DIR into the most recent snapshot
        $RSYNC -a --stats --delete --delete-excluded --exclude-from="$EXCLUDES" --link-dest=../$SNAPSHOT_FILE.1 --password-file="$PASSWORD_FILE" "$BACKUP_DIR/" "$RSYNC_DEST"/$SNAPSHOT_FILE.0
        status=$?
        if [ $status -eq 0 ]
        then
         log_info "Rsynced $BACKUP_DIR/ to $RSYNC_DEST/$SNAPSHOT_FILE.0 linked to ../$SNAPSHOT_FILE.1"
        else
         log_error "Rsync of $BACKUP_DIR/ to $RSYNC_DEST/$SNAPSHOT_FILE.0 linked to ../$SNAPSHOT_FILE.1 failed."
         exit $status
        fi
        
        
        # Update the mtime of $SNAPSHOT_FILE.0 to reflect the snapshot time
        $TOUCH $SNAPSHOT_DIR/$SNAPSHOT_FILE.0
        status=$?
        if [ $status -eq 0 ]
        then
         log_info "Touched $SNAPSHOT_DIR/$SNAPSHOT_FILE.0"
        else
         log_error "Touch of $SNAPSHOT_DIR/$SNAPSHOT_FILE.0 failed."
         exit $status
        fi
        
        log_info "Snapshot Complete"

        Comment


          #5
          Re: Set up GRsync?

          Thanks for that but the more I think about it the more it makes sense to leave them - at least until I'm sure I'll never ned a file again

          Comment


            #6
            Re: Set up GRsync?

            Don't forget also that if you do not want to have a GTK+ front-end for RSync, there's Krsync as well.
            http://www.kde-apps.org/content/show...?content=68586

            Looks great in KDE4.
            ​"Keep it between the ditches"
            K*Digest Blog
            K*Digest on Twitter

            Comment


              #7
              Re: Set up GRsync?

              There's also an application in the repos called backintime, which has a kde frontend. Anyone with any experirnce of that one?

              Comment

              Working...
              X