[juneau-lug] Simple backup script
- From: "James Zuelow" <jamesz@xxxxxxxxxxxxxxxx>
- To: <juneau-lug@xxxxxxxxxxxxx>
- Date: Fri, 28 Feb 2003 09:55:36 -0800
Every month I back up my mail server at work to a CD-R, and finally
realized I should probably just script it and run it from cron.
So, in case someone has a CD-RW and hasn't gotten around to it, here's
what I typed up. There are some things missing. For example, I know
that my data only gets to about 420MB, so I don't check the size of the
image before burning it. And since the physical CD-RW just sits in the
mail server's drive, I don't do anything special for the image aside
from setting the volume ID with the date. Anyway, no Joliet or HFS
support for Windows/Mac.
The /dev/cd0c device is how OpenBSD refers to the IDE CD-RW drive. You
will probably have a different device & speed. Something like
dev=/dev/hdc speed=32 or something.
Anyway, with a modified version of this script running from at or cron,
and a CD-RW sitting in the drive, you could back up important
information automatically. A CD-RW is supposed to give you 100 reliable
writes. This script does two writes, so a weekly backup script would
run 50 weeks - or just about a year before you had to change disks.
###############################
# Written for OpenBSD 3.2
# Your device syntax may differ
# (Linux users use /bin/bash)
#
#!/bin/sh
date=`date "+%y%b%d"`
volume=backup$date
# backups are kept on a scratch partition
# not used for anything else. Ensure that
# it is empty before we start...
if [ -e /data1/root.dmp ]
then
rm /data1/*
fi
# I back up / /usr /home and /var using a
# level 0 dump. Simple and it fits on a CD.
# If you have lots of data, you may need to
# use tar, afio, etc. to make your sets.
dump -0 -u -a -f /data1/root.dmp /
dump -0 -u -a -f /data1/usr.dmp /usr
dump -0 -u -a -f /data1/home.dmp /home
dump -0 -u -a -f /data1/var.dmp /var
# make the image file, overwriting any previous one.
# note that this is a barebones image - no Joliet, etc...
mkisofs -o /data2/dump.iso -V $volume /data1
# blank the CD. Your device and speed may differ
#(/dev/hdc or 0,2,0 for example)
cdrecord dev=/dev/cd0c speed=10 blank=all
# write the CD. Your device and speed may differ...
cdrecord dev=/dev/cd0c speed=10 /data2/dump.iso
exit 0
------------------------------------
This is the Juneau-LUG mailing list.
To unsubscribe, send an e-mail to juneau-lug-request@xxxxxxxxxxxxx with the
word unsubscribe in the subject header.
Other related posts: