SAMBA : Backup
Glenn Burkhardt
glenn at aoi.ultranet.com
Tue Jan 2 21:56:06 GMT 2001
Here's a script you can run on a Linux machine (or probably any other
Unix box) that we use to backup our Windows machines (Win95, Win98, WinNT).
Just create the shares with a full access password (find the word 'PASSWORD').
You can make a cron entry to run this at night ...
-------------- next part --------------
#! /bin/bash
if [ $# = 0 ] ; then
fileno=0
else
fileno=$1
fi
SMBC=/usr/local/samba/bin/smbclient
cd /root/backup
TAPE=/dev/nst0
FAILED_MSG="\
Backups were not done this evening because your machine is not available on\n\
the network. Please be sure to leave your machine on each night so backups\n\
can be done. Thank you!"
EXCLUDE='windows winnt dos xnfs orcadwin MAXPLUS2 emacs OmniX OmniNFSXe \
MSOffice Office wpwin60 Acrobat3 engr wpc20 DMI ATI PAGEMGR KPCMS OPLIMIT \
wpwin60 dell mouse vibra16 teac winmcad win32app acroread acrobat3 \
bsdl pkware ACADR13 DTEXT23 MCVHDL RECYCLED lotus Corel Eudora/eudora.log \
ACER MAX2WORK ticd abel3 clipart HPFONTS ORCADWIN ICM98 OrCad2 gs \
ALLIED99 CKWIN7 gstools PSFONTS synplicity WINPROJ'
# Hosts with pcadmin remote access account
#
#
blAppend()
{
n=${#hlist[*]} # appednd to host list
hlist[$n]=$1
n=${#slist[*]} # append to share list
slist[$n]=$2
n=${#olist[*]} # append to owner email name list
olist[$n]=$3
}
# Build list of
# host share user-to-notify
blAppend drachma C sandra
blAppend kopek C johnf
blAppend masada C mike
blAppend vishnu C maureen
blAppend aries C laura
blAppend fujin C jim
blAppend fujin D jim
blAppend pellinore C ellen
blAppend sappho C dolores
blAppend diana C pbm
blAppend osimo C yvan
i=0
while [ $i -lt ${#hlist[*]} ] ; do
echo
date
echo ping ${hlist[$i]}
ping -c 1 ${hlist[$i]}
if [ $? != 0 ] ; then
echo email to ${olist[$i]} for ${hlist[$i]} not available
echo $FAILED_MSG | mail -s "Backup for ${hlist[$i]} failed" ${olist[$i]}
echo $FAILED_MSG | mail -s "Backup for ${hlist[$i]} (${olist[$i]}) failed" backuplist
else
echo File ${fileno}: ${hlist[$i]}
$SMBC \\\\${hlist[$i]}\\${slist[$i]} "PASSWORD" -TcbX 126 $TAPE \
"Program Files" $EXCLUDE &> ${hlist[$i]}-${slist[$i]}.log
fileno=$(($fileno + 1))
fi
i=$(($i + 1))
done
echo "PC backups complete"
date
More information about the samba
mailing list