Friday, December 31, 2010

Backup script for Solaris

#!/usr/bin/sh
# author : Christian ALT
# module name: /export/bin/backupfw
# Copyright : Telecom and Logistics Associates, all rights reserved
# Installation : DO NOT FORGET .netrc
# Will backup necessary files for FW-1 and Solaris. It will then transfer the files to my-backup-host by doing an ftp
# from the firewall to an FTP server.
# This script must be scheduled in crontab with an entry like the following
#      0 5 * * * /export/bin/backupfw
# 8.9.99 Adaptation to fw-1 version 4.0
# 25.10.99 added backup of /etc/hosts and /etc/hostname.*
# 27.10.99 added backup of /usr/local/etc

## User part to adapt to system

HOST=my-backup-host
FWDIR=/opt/CKPfw
FWTK=/usr/local/etc
BACKUP=/export/backup
GUI=/opt/CKPfwgui/clients
VAR=/var/opt/CKPfw
BIN=/export/bin
SAVE=backup-ssn/pluton-1/conf

# End of user modifications

# we clean the backup directory before to backup anything
rm $BACKUP/*
tar cvf $BACKUP/fw.tar $FWDIR /etc/fw.boot $GUI $VAR
compress $BACKUP/fw.tar

# If on your firewall you have a DNS installation uncomment the following 2 lines
#tar cvf $BACKUP/named.tar /var/named /etc/resolv.conf /etc/named.boot
#compress $BACKUP/named.tar

# Solaris configuration
cp /etc/rc3.d/S99route $BACKUP
cp /etc/inetd.conf $BACKUP
cp /etc/services $BACKUP
cp /etc/defaultrouter $BACKUP
cp /etc/nsswitch.conf $BACKUP
cp /etc/hosts $BACKUP
cp /etc/hostname.* $BACKUP
cp /etc/security/audit_control $BACKUP
cp /.profile $BACKUP
cp $BIN/backuplog $BACKUP
cp $BIN/backupfw $BACKUP
cp /var/spool/cron/crontabs/root $BACKUP

echo "starting FTP"

# FTP transfer part to
cd $BACKUP
ftp -i $HOST <cd $SAVE
bin
mput *
bye
!

echo "Transfer finished"
echo "Removing files in Backup"
rm $BACKUP/*

No comments: