Looking for shell script for backup on BSD 4.3
Ron Nash
nash at ucselx.sdsu.edu
Sat Oct 13 07:48:24 AEST 1990
In article <11885 at bsu-cs.bsu.edu> koffi at bsu-cs.bsu.edu (There will be enough room in HEAVENS for all of US) writes:
>
>Hello,
>
>Is there any best way to do backups using a shell script program which will
>automatically kill the idle users on the systems, turn off the acct and the
>login file, etc ...
>
>Is it advised to write this type of shell script or C program to perform a
>one shot backup - from beginning to finish?
>
Koffi,
I have written a csh script that you may want to edit to do a
level 0 dump after disabling logins, warning users and logging them out
if they don't. It ignores background jobs - possibly a bug depending
upon your viewpoint. Feel free to edit at will.
#!/bin/csh
# Weekly level 0 dump - Ron Nash
#
echo "Weekly Full Backup"
echo "The weekly backup disables logins and terminates users on"
echo "ucselx.sdsu.edu. This backup will remove all users after"
echo -n "5 minutes and disable logins. Proceed (No)? "
set ANS = $<
if ( $ANS == "" ) set ANS = "no"
switch ( $ANS )
case 'Y*'
case 'y*'
umask 033
echo "No Logins: System down for full backup" > /etc/nologin
echo "Logins disabled..."
set tty = `tty | sed -e 's./dev/tty..'`
set i = (`ps ag | grep "[-][c,k]sh" | grep -v " $tty " | awk '{print $1}'`)
if ( $#i == 0 ) then
echo "No users logged on..."
else
echo -n "Notifing $#i users..."
ps aug | grep "[-][c,k]sh" | grep -v " $tty " | awk '{printf("%s ", $1)}'
echo " "
echo "System going down in 5 minutes for full backup" | wall
sleep 180
echo "System going down in 2 minutes for full backup" | wall
sleep 60
echo "System going down in 60 seconds for full backup" | wall
sleep 30
echo "System going down in 30 seconds for full backup" | wall
sleep 30
echo "System going down NOW" | wall
echo "Removing users... "
/bin/kill -9 $i >& /dev/null
echo "Users removed..."
endif
sync
breaksw
default:
echo "Weekly backup not run"
exit
breaksw
endsw
# make backup copies of passwd and group
cp /etc/passwd /usr1/adm
cp /etc/group /usr1/adm
cp /dev/null /etc/dumpdates
echo "Weekly backup proceeding..."
dump 0unsdf 2200 6250 /dev/rmt1h /usr1
rm -f /etc/nologin
echo "Logins enabled"
echo "Weekly full backup has finished"
#mt offline >& /dev/null
exit
--
Ron Nash
San Diego State University
Internet: nash at ucselx.sdsu.edu
UUCP: ucsd!sdsu!ucselx!nash
More information about the Comp.unix.admin
mailing list