Commit 6d184e82 authored by Robert Ricci's avatar Robert Ricci

New script: backupswitches. Just a little front-end to

grabswitchconfig, suitable for daily running from cron.
parent fbfd52bf
......@@ -2232,6 +2232,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
utils/opsreboot utils/deletenode utils/webdeletenode utils/spewleds \
utils/grabwebcams utils/loghole utils/webcopy \
utils/setdest utils/websetdest utils/grabswitchconfig \
utils/backupswitches \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 www/xmlrpc.php3 \
www/swish.conf www/websearch www/garcia-telemetry/GNUmakefile \
vis/GNUmakefile vis/webvistopology vis/dbvistopology \
......
......@@ -727,6 +727,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
utils/opsreboot utils/deletenode utils/webdeletenode utils/spewleds \
utils/grabwebcams utils/loghole utils/webcopy \
utils/setdest utils/websetdest utils/grabswitchconfig \
utils/backupswitches \
www/GNUmakefile www/defs.php3 www/dbdefs.php3 www/xmlrpc.php3 \
www/swish.conf www/websearch www/garcia-telemetry/GNUmakefile \
vis/GNUmakefile vis/webvistopology vis/dbvistopology \
......
......@@ -19,7 +19,7 @@ BIN_SCRIPTS = delay_config sshtb create_image node_admin link_config \
SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
eventping grantnodetype import_commitlog dhcpd_wrapper \
opsreboot deletenode node_statewait grabwebcams \
grabswitchconfig
grabswitchconfig backupswitches
LIBEXEC_SCRIPTS = webcreateimage newnode webdeletenode spewleds webcopy \
websetdest
......
#!/usr/bin/perl
#
# EMULAB-COPYRIGHT
# Copyright (c) 2005 University of Utah and the Flux Group.
# All rights reserved.
#
my $BACKUPDIR = '@prefix@/backup/switch-config';
my $TMPFILE = "/tftpboot/switch-backup";
my $GRAB = "@prefix@/sbin/grabswitchconfig";
use lib '@prefix@/lib';
use libdb;
use strict;
use English;
sub usage() {
print "Usage: backupswitches <switches...>\n";
exit 1;
}
if ($UID && !TBAdmin($UID)) {
die "*** $0:\n" .
" Sorry, only admins get to run this script\n";
}
if (!@ARGV) {
usage();
}
#
# Get today's date, nicely formatted
#
my ($junk,$junk,$junk,$mday,$mon,$year,$junk,$junk,$junk) = localtime(time);
$year += 1900;
$mon = sprintf("%02d",$mon + 1);
$mday = sprintf("%02d",$mday);
my $datestr = "$year-$mon-$mday";
#
# Back up each switch in turn
#
foreach my $switch (@ARGV) {
system "$GRAB $switch $TMPFILE"
and die "Unable to grab config for $switch\n";
system "mv $TMPFILE $BACKUPDIR/$switch-$datestr\n"
and die "Unable to move config file to $BACKUPDIR/$switch-$datestr\n";
}
exit 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment