[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dump to remote machine
- To: misc_(_at_)_openbsd_(_dot_)_org
- Subject: Re: dump to remote machine
- From: "J.D. Bronson" <jeff_(_at_)_xpec_(_dot_)_com>
- Date: Wed, 16 Apr 2003 08:04:32 -0500
-=-=-=-=-=-=-=
Hi !
First.... I hope you want to secure your session and use SSH... right ?
Hope the script below can help you...
But you have to modify the script to dump to local tape instead of disk....
(And maybe some modification caused by the fact I wrote this for Solaris)
1.
Create an SSH keypair without a password on the machine holding the tape
station.
2.
Put the public key on the machines you want to back up, and make sure you can
log on without a password from the tape machine to the machines you want to
backup.
3.
Run the script below (on the machine holding the tapestation) with the config
file as an argument. This will give you nice dump files of the selected
filesystems of the remote machines in the specified home directory (se script
below) of the tape machine.
(As said... you have to modify the script to dump to tape instead of disk..)
The script will also mail the result to the specified e-mail address in the
config file.
---dump script on the machine holding the tape station--
#!/bin/sh
#
# dumpscript
#
###configuration parameters
GLBEXC= # global exclude
DFPATH=/usr/bin # remote path of 'df' cmd
UFSPATH=/usr/sbin # remote path of 'ufs' cmd
SSHPATH=/usr/local/bin # Path to local ssh binary
MAILPATH=/usr/ucb # Path to local mailer
HOME=/home/backups/dump # installation path.
###
DATE=`date '+%Y-%m-%d'`
while read MAIL HOST ADD INC EXC foo; do
if [ "`echo "$MAIL" | grep '#'`" ] || [ ! "$MAIL" ] ;then continue;fi
if [ "$ADD" = "Y" ];then
INC=`$SSHPATH/ssh -n $HOST "$DFPATH/df -F ufs" | grep -v cdrom | cut
-d' '
-f1 | tr '\n' ':'`
fi
EXC=`echo $EXC | tr ':' ' '`
BS=GOOD
for TRG in `echo $INC | tr ':' ' '`; do
if [ "`echo "$EXC" | grep $TRG`" ];then continue;fi
if [ "`echo "$GLBEXC" | grep $TRG`" ];then continue;fi
TRGNAME=`echo "$TRG" | sed 's/\//!/g'`
echo "$DATE dumpscript: backing up $HOST:$TRG" | tee -a
$HOME/log/$HOST.$DATE.log
$SSHPATH/ssh -n $HOST "$UFSPATH/ufsdump 0f - $TRG" >
$HOME/output/$HOST.$TRGNAME.$DATE 2>> $HOME/log/$HOST.$DATE.log
#verify status of ufsdump result
ufsrestore thf $HOME/output/$HOST.$TRGNAME.$DATE > /dev/null 2>&1
if [ "$?" != 0 ];then
echo "$DATE BACKUP_FAILED: $HOST:$TRG" | tee -a
$HOME/log/$HOST.$DATE.log
BS=FAIL
else
cd /tmp; cd $HOME/output
ls | grep $HOST | grep -v $DATE | xargs rm -f # remove old backup
files
fi
done
cat $HOME/log/$HOST.$DATE.log | $MAILPATH/mail -s "BACKUP IS $BS $DATE from
$HOST" $MAIL
rm -f $HOME/log/$HOST.$DATE.log # remove old logs
done
# < $HOME/conf/input
-----------------------------------------
--- config file to use as an argument to the script above----
# This is the input file for
# the backup script
# Syntax of this file:
# Mailaddress -- where to send logfile of each backup-result
# Hostname/IP -- address of target machine
# Autodetectfs -- use 'df -F ufs' to automatically detect partitions
# Include -- partitions to include
# Exclude -- partitions to exclude
# Example:
# testuser_(_at_)_testdomain_(_dot_)_com 130.100.31.250 Y : :
# testuser_(_at_)_testdomain_(_dot_)_com 130.100.31.250 Y : /opt:/export/home
# testuser_(_at_)_testdomain_(_dot_)_com 130.100.31.250 N /usr:/var :
# testuser_(_at_)_testdomain_(_dot_)_com 130.100.31.250 N /var :
# testuser_(_at_)_testdomain_(_dot_)_com 130.100.31.201 N /usr :
# testuser_(_at_)_testdomain_(_dot_)_com 130.100.31.202 N /opt :
backup_(_at_)_testdomain_(_dot_)_com machine1.testdomain.com Y : :
backup_(_at_)_testdomain_(_dot_)_com machine2.testdomain.com Y : :
------------------------------------------------------------
Regards
Per-Olov
--
Per-Olov Sjöholm
Flowsystems AB
www.flowsystems.se
-=-=-=-=-=-=-=-=-=-=-=
well that is some script! - although I like this, it is quite overkill....
:(
I only need some tips on how to do a backup via ssh to the backup machine...
Something to modify this so that it works under ssh:
#!/bin/sh
/sbin/dump -0au -f /dev/nrst0 /dev/sd0a
?
Visit your host, monkey.org