Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: [SOLVED] Questions on rsync

  1. #11
    Join Date
    Apr 2009
    Beans
    80
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Questions on rsync

    Hi hyper_ch,
    Thanks for this info, your incremental backup script helps me a lot.

    Now 1 quick question, if client using Windows XP, how can they see the backup files? (from your example, they are under old/<date> folder)...as they are just links to the same inode in Linux, but when you open it in Windows using Samba connection, they are just bunch of random name directory (ie: 2RNSRZ~7, 2XC1GQ~0, etc)

    Should I remove the link beforehand to some temporary directory?

    Thanks

    Quote Originally Posted by hyper_ch View Post
    Yes, but I'd rather setup a script that runs at boot to do the backup.


    That's simple just mount the separate partition into your local filesystem (I have used /backup on my machine) and sync into it.

    What I do is to make incremental snapshot-style backups. That means I make hardlink copies of my backed up files so that I have for each backup a "full" backup copy.

    backup.sh
    Code:
    #!/bin/bash
    unset PATH
    
    # USER VARIABLES
    BACKUPDIR=/backup        # Folder on the backup server
    MYSQLUSER=root
    MYSQLPWD=***************
    MYSQLHOST=localhost
    MYSQLBACKUPDIR=/mysql_backup
    EXCLUDES=/backup/backup_exclude        # File containing exludes
    DAYS=90         # After how many days shall the backups be deleted?
    
    # PATH VARIABLES
    CP=/bin/cp;
    MK=/bin/mkdir;
    DATE=/bin/date;
    RM=/bin/rm;
    GREP=/bin/grep;
    MYSQL=/usr/bin/mysql;
    MYSQLDUMP=/usr/bin/mysqldump;
    RSYNC=/usr/bin/rsync;
    TOUCH=/bin/touch;
    FIND=/usr/bin/find;
    
    ##                                                      ##
    ##      --       DO NOT EDIT BELOW THIS HERE     --     ##
    ##                                                      ##
    
    # CREATING CURRENT DATE / TIME
    $MK $BACKUPDIR/current
    $MK $BACKUPDIR/old
    NOW=`$DATE '+%Y-%m'-%d_%H:%M`
    MKDIR=$BACKUPDIR/old/$NOW/
    $MK $MKDIR
    
    # CREATE MYSQL BACKUP
    # Remove existing backup dir
    $RM -Rf $MYSQLBACKUPDIR
    
    # Create new backup dir
    $MK $MYSQLBACKUPDIR
    
    #Dump new files
    for i in $(echo 'SHOW DATABASES;' | $MYSQL -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST|$GREP -v '^Database$'); do
      $MYSQLDUMP                                                    \
      -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST                         \
      -Q -c -C --add-drop-table --add-locks --quick --lock-tables   \
      $i > $MYSQLBACKUPDIR/$i.sql;
    done;
    
    # RUN RSYNC INTO CURRENT
    $RSYNC                                                          \
            -avzp --delete --delete-excluded                        \
            --exclude-from="$EXCLUDES"                              \
            /                                                       \
            /$BACKUPDIR/current ;
    
    # UPDATE THE MTIME TO REFELCT THE SNAPSHOT TIME
    $TOUCH $BACKUPDIR/current
    
    # MAKE HARDLINK COPY
    $CP -al $BACKUPDIR/current/* $MKDIR
    
    # REMOVE OLD BACKUPS
    for file in "$( $FIND $BACKUPDIR/old/ -maxdepth 1 -type d -mtime +$DAYS )"
    do
      $RM -Rf $file
    done
    
    exit 0
    It's very simple that script. First I define a few things (where I want to have backups to, how long I want to keep them, ....)
    I also have mysql databases, so I need to back them up also - you probably can just skip that.

  2. #12
    Join Date
    Apr 2009
    Beans
    80
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Questions on rsync

    Apparently I put way too long directory name in Linux, which confuse XP/Vista.

    If I put something like 2009-05-16_20:48 directory name, XP/Vista detects it as 2RNSRZ~7.

    Once I changed to backup0 / backup1, XP/Vista able to read it properly, yay!

    Quote Originally Posted by televisi View Post
    Now 1 quick question, if client using Windows XP, how can they see the backup files? (from your example, they are under old/<date> folder)...as they are just links to the same inode in Linux, but when you open it in Windows using Samba connection, they are just bunch of random name directory (ie: 2RNSRZ~7, 2XC1GQ~0, etc)

  3. #13
    Join Date
    Sep 2012
    Beans
    3

    Lightbulb Re: Questions on rsync

    Hello

    you can also look at a script that i wrote to backup the whole disk with rsync here: http://blog.pointsoftware.ch/index.p...th-hard-links/

    It uses file deduplication thanks to hard-links, uses also MD5 integrity signature, 'chattr' protection, filter rules, disk quota, retention policy with exponential distribution (backups rotation while saving more recent backups than older).
    It was already used in Disaster Recovery Plans for banking companies, in order to replicate datacenters, using only little network bandwidth and transport encryption tunnel.

    Can be used locally on each servers or via network on a central remote backup server.
    windows server could also be backuped by using a linux box that mount smb shares from them.

    i hope it will be useful to you guys

    francois

  4. #14
    Join Date
    Apr 2009
    Beans
    80
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: [SOLVED] Questions on rsync

    Hi scheuref,
    Thanks for this, will definitely check out your blog

Page 2 of 2 FirstFirst 12

Tags for this Thread

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
  •