[OLUG] can we talk backups?
Brian Weber
brian at cbiowa.com
Sun Mar 19 07:25:59 UTC 2000
I won't be able to go to your meeting but I also have a backup script
that I have been using religiously for the past 8 years. I have it
setup in cron to run. I have attached the two files it takes to run
this. Any questions about it I would be more than happy to help out.
This script goes out and looks for any files that have been updated for
the past two days and only backs up those files. I am using the gzip
option with tar so that is the best it gets. I was planning on switch
to the bzip2 compression because it seems to work better I just haven't
done it.
Vincent wrote:
>
> Just to get the subject fired up a little, here's a script I've made to
> do back-ups. I pasted it as a quote in case word-wrap mangles it...).
> I run rhis every night on two different machines and a copy of each is
> stored on each and deletes the old ones. My bu-list contains /etc
> /home/httpd /var/log and /home/name/\.* The tar file is typically 4MB.
> It could probably use some work, but it's better than nothing.
>
> > #!/bin/sh
> >
> > PC=`/bin/uname -n`
> > BIN=/root/bin
> > BLOC=/var/backup
> > JDATE=`/bin/date +%Y%j`
> > export PC BIN BLOC JDATE
> > BUF=${BLOC}/${PC}.daily_backup.${JDATE}.tar.gz
> > BLOG=${BLOC}/${PC}.daily_backup.${JDATE}.log
> > LIST=${BIN}/bu-list
> > OLD=`/usr/bin/expr $JDATE - 10`
> > export BUF BLOG OLD
> >
> > /bin/echo "Starting Back-up ..be patient"
> > /bin/date >> ${BLOG} 2>&1
> > /bin/df -hal >> ${BLOG} 2>&1
> > /bin/tar -czvf ${BUF} -T ${LIST} >> ${BLOG} 2>&1
> > /bin/rm -f ${BLOC}/*.daily_backup.${OLD}.* >> ${BLOG} 2>&1
> > /usr/bin/rcp ${BUF} mypc2:${BLOC}
> > /bin/sleep 5
> > /usr/bin/rsh mypc2 ls -lah ${BLOC} >> ${BLOG} 2>&1
> > /bin/sleep 3
> > /usr/bin/rsh mypc2 /bin/rm -f ${BLOC}/*.daily_backup.${OLD}.* >> ${BLOG} 2>&1
> > /bin/sleep 3
> > /usr/bin/rsh mypc2 df -hal >> ${BLOG} 2>&1
> > /bin/sleep 3
> > /usr/bin/rcp ${BLOG} mypc2:${BLOC}
> > /bin/sleep 5
> > /bin/df -hal >> ${BLOG} 2>&1
> > /bin/date >> ${BLOG} 2>&1
> > /bin/echo "Finished" >> ${BLOG} 2>&1
> > /bin/echo "Finished"
>
> Mike Hostetler wrote:
> >
> > I have a possible subject for a discussion. I am by no means qualified to do it, but
> > I could help.
> >
> > The subject is backups. Things to consider:
> >
> > o how often (obviously, not often enough)?
> > o which is better - tar or cpio?
> > o best way to script it?
> > o is it worth buying a commercial program for this (i.e. BRU)?
> >
> > This is a very sysadmin-ish subject, but is important to anyone that runs a system.
> > I, myself, have had problems and had to reload Linux (usually due to hardware issues,
> > not necessarily OS issues), and sometimes I have had recent backups and sometimes . .
> > er, let's just say that I was hard to talk to for about four weeks.
> >
> > *If* no one jumps up and volunteers, I'll be brave enough to go up in front of the
> > group and advertise my ignorance on the subject. But there has to be someone that has
> > instutited better plans than what I have, which is:
> >
> > find /* -depth|grep -v var |grep -v proc|grep -v tmp > backup.txt
> > cpio -o -H crc -F /dev/tape < backup.txt
> >
> > - mikeh
>
> -------------------------------------------------------------------------
> Sent by OLUG Mailing list Manager, run by ezmlm. http://olug.bstc.net/
> To unsubscribe: `echo unsubsribe | mail olug-unsubscribe at bstc.net`
--
Brian Weber
Computer Consultant
Cap Gemini
brian at mail.cbiowa.com
-------------- next part --------------
# Sample script to run a backup from a cron session as root.
# Created by Brian Weber
# July 28, 1996
# brian at cbiowa.com
#
# This will use tar and a list of files that you have created and
# create a backup file. Then it will place that in the location that
# specify for later backup by a tape program. I am doing backup like
# this because I have windoze backing up my files and it doesn't keep
# any of the file permissions set my linux.
# The backup program will check to make sure these directories exist
# before starting the backup.
TMPDIR=/tmp
TAPE=/dev/nst0
# Don't put an extension on the file. A .tgz will be added for you!
BACKUPFILE=backup
BACKUPLIST=/etc/.backuplist
NOTIFY=root at myhome.nightstalker.com
# You shouldn't need to edit beyond this point!
###############################################################################
if [ ! -w $TMPDIR ]; then
echo "You don't have permission to write to $TMPDIR" \
| mail -s "Problems backing up" $NOTIFY
exit
fi
# create a list of paying dialup customers and print the list excluding
# the ftp directory.
cd /
grep -ve /usr/home /etc/passwd > /tmp/test.txt
grep -e /home /tmp/test.txt | awk -F: '{ print $6 }' - > /tmp/test.tmp
EDATE=`date --date '1 day ago' +%m/\%d/\%Y`
echo "Creating List"
echo -n '# ' > /tmp/files.txt
echo `date` >> /tmp/files.txt
grep -ve home/ftp /tmp/test.tmp >> /tmp/files.txt
grep -v -e '#' $BACKUPLIST >> /tmp/files.txt
# Make sure we are appending to the existing backup
mt -f $TAPE eod
echo "Create the backup file now."
grep -v -e '#' /tmp/files.txt > /tmp/files.tmp
echo $EDATE
tar cz --totals -N $EDATE -f $TAPE tmp/files.txt -T /tmp/files.tmp
sleep 30
echo "Back Track for difference report."
mt -f $TAPE bsf 2
tar -f $TAPE -dz 2> /dev/null > /dev/null
DIFFEDFILES=`tar -f $TAPE -dz`
sleep 30
mt -f $TAPE bsf 2
tar -f $TAPE -tz 2> /dev/null > /dev/null
sleep 30
BACKEDUPFILES=`tar -f $TAPE -tz`
echo -e "Backup was successful.\n" \
"This is a list of the files different since backed up: \n\n\n" \
"$DIFFEDFILES\n\n\n" \
"This is a list of the files backed up: \n\n\n" \
"$BACKEDUPFILES\n" \
| mail -s "Successful Backup on `date`" $NOTIFY
rm /tmp/test.txt
rm /tmp/test.tmp
rm /tmp/files.txt
rm /tmp/files.tmp
-------------- next part --------------
# Created by Brian Weber
# July 28, 1996
#
# List of files and directories that will be backed up and stored
# in a file to be transfered to a tape leter.
# If a file is specified than only that file will be backed up.
# Example file: /etc/passwd
# If a directory is specified than every file in the directory will
# be backed up. If thier are any symbolic links in the directory than
# the backup program will follow those links and backup anything under
# those directories also. Warning: don't include /usr/src/linux or
# /etc as directories in your list of files to backup!
# Example directory: /etc/ppp
etc/profile
etc/ppp
etc/dns
etc/resolv.conf
etc/named.conf
etc/rc.d
etc/XF86Config
etc/aliases
etc/HOSTNAME
etc/skel
etc/conf.modules
etc/smb.conf
etc/watchdog.conf
etc/serial.conf
etc/auto.master
etc/auto.ibm
etc/auto.shariah
etc/auto.mnt
etc/.backuplist
sbin/backup
var/log
var/spool/mqueue
var/spool/mail
var/spool/cron/crontabs
opt/pgsql/data
-------------- next part --------------
-------------------------------------------------------------------------
Sent by OLUG Mailing list Manager, run by ezmlm. http://olug.bstc.net/
To unsubscribe: `echo unsubsribe | mail olug-unsubscribe at bstc.net`
More information about the OLUG
mailing list