koffi@bsu-cs.bsu.edu (There will be enough room in HEAVENS for all of US) (10/09/90)
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
nash@ucselx.sdsu.edu (Ron Nash) (10/13/90)
In article <11885@bsu-cs.bsu.edu> koffi@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@ucselx.sdsu.edu UUCP: ucsd!sdsu!ucselx!nash
rodney@sun.ipl.rpi.edu (Rodney Peck II) (10/13/90)
That's a nice script, but what do you do if you have several machines that should be backed up? Anyone have a script that does backups of /usr and / of the machines with disks on your net? -- Rodney
dag@fciva.FRANKLIN.COM (Daniel A. Graifer) (10/14/90)
I have written a sequence of scripts we use here to get the system into an assured idle state for unattended backup. These depend on init state 4 being available for local site use (We are running Prime Computer's port of AT&T SYSV 3.1.2). The sequence of events is as follows: /etc/bupstart runs out of crontab at 6:00am checks for presence of tape in Excebyte drive, and that tape appears different from last backup tape written (In case you forget to change the tape!) broadcasts a warning message writes backup paramenters ( complete/incremental, device, logfilename, filesystemnames ) to /etc/ustate4.rc does a telinit 4 init looks in inittab to get instructions for changing to state 4. entry for /etc/rc0 now has a 4, so system services are shut down. (This is the same as doing a telint 0 or 1 or S) new script /etc/rc4, similar to rc2, runs scripts in /etc/rc4.d remount file systems read /etc/ustate4.rc and start /etc/autobackup autobackup does the backup (we use /etc/savecpio) and moves ustate4.rc to /etc/backup.done do an init 2 respawn a getty on the console so a failure of the init 2 will not leave the system irretrievably hung. init looks in inittab for instructions on returning to multiuser state. new script S99autotapelog in rc2.d looks for /etc/backup.done, and if it is there, does spawns off /etc/autotapelog This does a cpio -ivtB <$DEVICE >$LOGFILE to verify the readability of the tape. Removes /etc/backup.done This should give you enough clues to write your own, or send me email and I will mail you mine. Dan --- Coastal Capital Funding Corp 7900 Westpark Drive, Suite A130 (703)821-3244 McLean, VA 22102 uunet!fciva!dag -- Daniel A. Graifer Franklin Mortgage Capital Corporation uunet!dag@fmccva.franklin.com 7900 Westpark Drive, Suite A130 (703)448-3300 McLean, VA 22102