This script will backup all the major operating system files and save them within /var/tmp. It was also log the MD5 of the backup after each successful backup and rotate the backups to ensure you dont run into disk space issues.
#!/sbin/sh
##
## SunOS Backup Script v1.3
##
## Backups up the the following file to /var/tmp/solaris-backup_`hostname`_`/bin/date +"%Y%m%d"`.tgz
##
## /etc/passwd
## /etc/system
## /etc/group
## /etc/shadow
## /etc/syslog.conf
## /etc/nsswitch.conf
## /etc/hosts
## /etc/nodename
## /etc/hostname.*
## /etc/etheraddr*
## /etc/inet/netmasks
## /etc/inet/ntp.conf
## /etc/rc3.d/*
## /etc/init.d/*
## /etc/ssh
## /var/spool/cron
## /usr/local/bin
## /usr/local/log
## /var/tmp/`hostname`_runconfig_`date +"%Y%m%d"`.txt = arp -an / ifconfig -a / netstat -nvr
##
## ENV VARIABLES
if [ -r /.profile ]
then
. /.profile
else
exit 1
fi
## VARIABLES
BKUPFILE=/var/tmp/solaris-backup_`hostname`_`date +"%Y%m%d"`.tgz
## Backup Rotatation
find /var/tmp/ -name *backup\* -mtime +2 -exec rm {} \;
## BACKUP
if [ `uname` = SunOS ]
then
arp -an > /var/tmp/`hostname`_runconfig_`date +"%Y%m%d"`.txt
netstat -rvn >> /var/tmp/`hostname`_runconfig_`date +"%Y%m%d"`.txt
ifconfig -a >> /var/tmp/`hostname`_runconfig_`date +"%Y%m%d"`.txt
tar -cf - /etc/passwd /etc/system /etc/group /etc/shadow /etc/syslog.conf /etc/nsswitch.conf /etc/hosts /etc/nodename /etc/hostname.* /etc/etheraddr* /etc/inet/netmasks /etc/inet/ntp.conf /etc/rc3.d/* /etc/init.d/* /etc/ssh /var/tmp/`hostname`_runconfig_`date +"%Y%m%d"`.txt /var/spool/cron /usr/local/bin /usr/local/log 2>/dev/null | gzip -6c > "${BKUPFILE}"
RC=$?
rm -f /var/tmp/`hostname`_runconfig_`date +"%Y%m%d"`.txt
MD5=`md5 "${BKUPFILE}"`
else
logger -t cp_backup -p daemon.err "Backup unsuccessful. Wrong OS."
fi
## LOGGING
if [ "${RC}" != 0 ]
then
logger -t cp_backup -p daemon.err "Backup unsuccessful."
exit 1
elif [ "${RC}" = 0 ]
then
logger -t cp_backup -p notice "Backup successful. "${MD5}""
exit 0
fi
Latest posts by Rick Donato (see all)
- Fortinet– How to configure NTP on FortiGate - January 13, 2026
- How to Configure a BIND Server on Ubuntu - March 15, 2018
- What is a BGP Confederation? - March 6, 2018