[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 ---

# 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"
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, 
incrementalbackupname=`date +%Y-%m-%d`"_incremental"`date +%H%M`".tar.gz"
incrementalbackuplogname=`date +%Y-%m-%d`"_incremental"`date +%H%M`".log"

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

    # create backup directory
    if test ! -e /backup/$directoryname; then
	echo "Creating /backup/$directoryname directory"
	mkdir /backup/$directoryname

    # 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 
    echo "Updating /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"

    # 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."


	# 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"


# --------------------------------------------------
# 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..."

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..."


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

fi # end if statement

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

--- cut ---

(pts/6)jason@marsala:/root/sbin-scripts$ cat whattobackup.marsala 

(pts/6)jason@marsala:/root/sbin-scripts$ cat whatnottobackup.marsala 

-jason pepas

Reply to: