System Files Backup
Over the Christmas weekend, we had an important machine fail.  Nothing Y2K related.  The system disk just died.  :-(
Fortunately, we had a fairly recent backup of the system disk, but it was not fully up-to-date.  And what if we had no backup for some reason?
I have developed another Pikt script to prepare for such situations. Here it is:
#ifndef generic # if ! no_usr_local SysFilesBackupNotice init status active level notice task "Do system files backup to a central repository" input file "=sysfiles_obj" dat $name 1 begin // so as not to clobber /usr/local from all machines at // once, put in this random pause pause #random(3600) // up to a one-hour pause rule // bypass all but regular text files if ! -f $name || $command("=file $name") !~~ "ascii text" next endif rule // get the basename (strip away the directory) set $base = $basename($name) rule =execwait "=cp -p $name /usr/local/etc/precious/$base\." . $hostname() # endif // ! no_usr_local #endifdef // generic
To test this, I followed my usual procedure of registering it as a Test alert in alerts.cfg:
Test timing =piktnever mailcmd "=mailx -s 'PIKT Alert on =pikthostname: Test' pikt-test" alarms SysFilesBackupNotice
After installing with
piktc -iv +A Test +H cologne
I logged into the cologne machine and ran the script directly with
pikt +A Test
(Actually, for the test, I reduced the pause to #random(60).)
After several minutes, here was the result:
rootcologne:398> ls ./ hosts.deny.cologne protocols.cologne ../ hosts.cologne resolv.conf.cologne .rhosts.cologne inetd.conf.cologne rpc.cologne PIKT.conf.cologne inittab.cologne services.cologne aliases.cologne magic.cologne shadow.cologne auto_master.cologne mnttab.cologne shells.cologne defaultrouter.cologne networks.cologne syslog.conf.cologne dfstab.cologne nsswitch.conf.cologne termcap.cologne group.cologne ntp.conf.cologne ttydefs.cologne hostname.le0.cologne passwd.cologne vfstab.cologne hosts.allow.cologne piktd.conf.cologne
Once satisfied with the result (actually I had to go through several trials until I got everything specified just right), I deleted all traces of the Test script with (on the piktmaster):
piktc -tv +A Test +H cologne processing cologne... disabling alert(s)... Test disabled deleting file(s)... Test.alt deleted deleting file(s)... Test.hst deleted deleting file(s)... Test.log deleted
Because of the pause, I added this script to the end of the Notice alarms list (in alerts.cfg).  Our Notice alert runs nightly at 3:50 AM, so the "precious" files will get backed up daily before 5 AM.
I hope it's obvious by now, but here is the command I used to install (almost) everywhere:
piktc -iv +A Notice -H no_usr_local downsys
A few other details.  "=sysfiles_obj" is a macro, specified in macros/piktfiles_obj_macros.cfg, as
I could have specified a separate set of "precious" system files in objects.cfg, but I decided it was most convenient to use the existing SysFiles object list.
Note the '#if ! no_usr_local' wrapper around this script.  'no_usr_local' is a host group defined in systems.cfg for those systems that, for one reason or another, don't have a the commonly shared /usr/local NFS cross-mounted.  This implies that several of our systems won't have their precious files backed up.  I'll get around to fixing this problem one of these days, but that's good enough for the moment.
Now, if a system disk dies, or if an important file gets corrupted, we will have system files backups on-line.
I've done this sort of system files backup before, pre-PIKT, and no doubt you
have, too.  But it's never been so easy to manage or as sophisticated as this.
For more examples, see Developer's Notes.