[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Backup Consensus?



On Sunday 26 January 2003 03:32 pm, Grant Bowman wrote:
> Is there a place where a general consensus has been reached on exactly
> what is necesary to backup a Debian system?  I'm sure this has been
> asked and answered many times before, so I am looking for URLs to where
> this has been discussed in the past.

for what it's worth, here's what I use to backup.

--- cut backup.marsala.sh ---
#!/bin/sh

# jason pepas's backup script - see http://jason.pepas.com
# shell script tutorials:
#  http://www.freeos.com/guides/lsst/
#  http://www.linuxnewbie.org/nhf/intel/programming/introbashscript.html


# --------------------------------------------------
# set variables:
# --------------------------------------------------


directoryname=`date +%Y-%m-%d`"_"`hostname`"_backup"
current="current_"`hostname`
fullbackuplabel="Full Backup of "`hostname`" on "`date '+%B %e, %Y'`
fullbackupname=`date +%Y-%m-%d`"_full.tar.gz"
fullbackuplogname=`date +%Y-%m-%d`"_full.log"
incrementalbackuplabel="Incremental Backup of "`hostname`" on "`date '+%B %e, 
%Y'`
incrementalbackupname=`date +%Y-%m-%d`"_incremental"`date +%H%M`".tar.gz"
incrementalbackuplogname=`date +%Y-%m-%d`"_incremental"`date +%H%M`".log"


# --------------------------------------------------
# functions:
# --------------------------------------------------


fullbackup()
{
    # create backup directory
    if test ! -e /backup/$directoryname; then
	echo "Creating /backup/$directoryname directory"
	mkdir /backup/$directoryname
    fi

    # create (or update) a shortcut called current to this directory
    echo "Updating /backup/$current pointer"
    rm /backup/$current
    ln -s /backup/$directoryname /backup/$current

    # keep track of creation date of full backup (used with incremental 
backups)
    echo "Updating /backup/$current/lastfullbackupdate"
    date>/backup/$current/lastfullbackupdate
    
    # create backup
    echo "Running tar..."
    tar --create  --label "$fullbackuplabel" --files-from 
/root/scripts/whattobackup --exclude-from /root/scripts/whatnottobackup 
--ignore-failed-read --absolute-names --verbose --gzip --file 
/backup/$current/$fullbackupname > /backup/$current/$fullbackuplogname 2>&1
    gzip /backup/$current/$fullbackuplogname
    echo "Done. Created /backup/$current/$fullbackupname"
    echo "To view the log, type:"
    echo " zcat /backup/$current/$fullbackuplogname"
}


incrementalbackup()
{
    # create variable with date of last full backup
    lastfullbackupdatevar=`cat /backup/$current/lastfullbackupdate`
    
    # check for existence of incremental backup
    if test -e "/backup/$current/$incrementalbackupname"; then 

        echo "Your last incremental backup was less than 60 seconds ago."
    	echo "Wait a minute and try again."

    else 

	# create incremental backup
    	echo "Running tar..."
	tar --create --label "$incrementalbackuplabel" --files-from 
/root/scripts/whattobackup --exclude-from /root/scripts/whatnottobackup 
--ignore-failed-read --after-date "$lastfullbackupdatevar" --absolute-names 
--verbose --gzip --file /backup/$current/$incrementalbackupname > 
/backup/$current/$incrementalbackuplogname 2>&1
	gzip /backup/$current/$incrementalbackuplogname
	echo "Done. Created /backup/$current/$incrementalbackupname"
        echo "To view the log, type:"
	echo " zcat /backup/$current/$incrementalbackuplogname"

    fi
}


# --------------------------------------------------
# main routine:
# --------------------------------------------------

# first get a list of all packages installed.
dpkg --get-selections > /etc/apt/selections

# clear out apt's packages
#apt-get clean

# now perform the backup.
echo "---------- Backup Script Running... ----------"

if test `date +%A` = "Sunday" && ! -e "/backup/$directoryname"; then

    # if it is sunday and you havent yet done a full backup, do so
    echo "Performing Weekly Full Backup..."
    fullbackup;

elif test ! -e /backup/$current/*full.tar.gz; then

    # if there is no current fullbackup, make one
    echo "No Current Full Backup - Performing Full Backup Now..."
    fullbackup;

else

    # otherwise, do an incremental backup
    echo "Performing Incremental Backup..."
    incrementalbackup;

fi # end if statement

echo "---------- Backup Script Done ----------"

--- cut ---

(pts/6)jason@marsala:/root/sbin-scripts$ cat whattobackup.marsala 
/boot
/etc
/home
/root
/temp
/usr/local
/var

(pts/6)jason@marsala:/root/sbin-scripts$ cat whatnottobackup.marsala 
*.mp3
*.mpg
*.avi
*.wav
*.mov
*.asf
*.rm
*.iso
*.flac
*.zip
*.exe
data.bin
/usr/local/fonts
/usr/local/games
/usr/local/j2re
/usr/local/j2re1.4.0
/usr/local/winbackup
/var/cache/apt/archives


-jason pepas



Reply to: