Find the answer to your Linux question:
Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #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
    Take a look at:

    man rsync

  3. #3
    umask 077
    TODAY=$( date +%A )
    DATEPREFIX=$( date +%y%m%d-%H%M )
    function inc_backup()
        tar -g $BACKUP_DIR/ -zcf $BACKUP_DIR/backup-inc-$DATEPREFIX.tar.gz $DIR 2> /dev/null 1>> $LOG
    function full_backup ()
        tar -g $BACKUP_DIR/ -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

  4. $spacer_open
  5. #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


  6. #5
    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
    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


  8. #7
    Yes, log will be created in backup directory -
    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