Find the answer to your Linux question:
Results 1 to 7 of 7
Hi all, I take responsibility for data backup my centos server. Please help me backup data using tar. following scenario: - Sunday - full backup - the rest of differential ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2005
    Posts
    1

    Help me to create backup script


    Hi all,

    I take responsibility for data backup my centos server. Please help me backup data using tar. following scenario:

    - Sunday - full backup
    - the rest of differential backup.

    We're back up to full as follows:

    tar-cvzf / backup / backup-date.tar.gz / data


    thanks a lot

  2. #2
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    Take a look at:

    Code:
    man rsync

  3. #3
    Just Joined!
    Join Date
    Aug 2010
    Posts
    18
    Code:
    #!/bin/bash
    umask 077
    
    BACKUP_DAY="Sunday"
    DIR="/data/"
    BACKUP_DIR=/home/backup
    LOG=$BACKUP_DIR/backup.log
    TODAY=$( date +%A )
    
    DATEPREFIX=$( date +%y%m%d-%H%M )
    
    function inc_backup()
    {
        tar -g $BACKUP_DIR/backup.inc -zcf $BACKUP_DIR/backup-inc-$DATEPREFIX.tar.gz $DIR 2> /dev/null 1>> $LOG
    }
    
    function full_backup ()
    {
        tar -g $BACKUP_DIR/backup.inc -czf $BACKUP_DIR/files-full-$DATEPREFIX.tar.gz $DIR 2> /dev/null 1>> $LOG
    
    }
    
    function delete_daily_inc () { \rm -f $BACKUP_DIR/*inc* 1> /dev/null 2>&1 ; }
    
    if [ "$TODAY" == "$BACKUP_DAY" ] ; then
        delete_daily_inc
        full_backup
    else
       inc_backup
    fi

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Aug 2010
    Posts
    4
    Here i have some doubts on this

    1. I assume this backup script is used to backup to tape. how can i backup to the backup server?
    2. here you used one log file in backup folder. Do you want to create this log file in backup folder? how can we get the files info in log file?

    Please clarify

    thanx

  6. #5
    Just Joined!
    Join Date
    Aug 2010
    Posts
    18
    1. This script make backups of specified directories to backup folder.
    And then you can upload backups to backup server by ncftpput or rsync.
    2. What do you mean files info in log file? If you want to write files lists in log you can simply user tar with -v oprion. It's verbose mode.

  7. #6
    Just Joined!
    Join Date
    Aug 2010
    Posts
    4
    Thanx for your reply

    what i am asking is here you are using one log file backup.log in backup directory. what is the use of it? do you want to create that log file in backup DIR.

    i want to backup /var/www/html/ folder and its subdirectories for both full and incremental. i understood that i need to change $DIR variable.

    i am a php developer. i am new to this shell scripting. that's why i am unable to understand the logic under the below steps.

    please clarify

    thanx

  8. #7
    Just Joined!
    Join Date
    Aug 2010
    Posts
    18
    Yes, log will be created in backup directory -
    Code:
    LOG=$BACKUP_DIR/backup.log.
    If you don't need log it you can just redirect output of tar or something to /dev/null.

    This script doesn't write anything to log.
    I leave it in script just to simplify further editions. You need just to enable -v option in tar and you'll get all info in log.

    And yes, you need to change variable $DIR to backup /var/www/html/.

Posting Permissions

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