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 ...
- 08-25-2010 #1Just 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
- 08-26-2010 #2
- 08-27-2010 #3Just 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
- 09-01-2010 #4Just 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
- 09-01-2010 #5Just 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.
- 09-01-2010 #6Just 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
- 09-01-2010 #7Just Joined!
- Join Date
- Aug 2010
- Posts
- 18
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.Code:LOG=$BACKUP_DIR/backup.log.
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/.


Reply With Quote