Commit 9d416c02 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add roll of the slowqueries log.

Add commented out find -delete command to remove all mysql logs older
than 35 days.  I just run it by hand at the moment, but I'll turn it
on at some point.
parent df145ccc
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -33,6 +33,7 @@ my $BACKUPDIR = "$TB/backup";
my $LOGDIR = "$TB/log/mysql";
my $BASE = "base";
my $UPD = "update";
my $SLOW = "slowqueries";
my $BACK = "tbdb";
my $extension;
......@@ -103,11 +104,13 @@ print "Extension: $extension\n";
my $backname = "$BACK.$extension";
my $basename = "$BASE.$extension";
my $updname = "$UPD.$extension";
my $updname = "$UPD.$extension";
my $slowname = "$SLOW.$extension";
print "Backup file name: $backname\n";
print "Base file name: $basename\n";
print "Update file name: $updname\n";
print "Slow file name: $slowname\n";
#
# Move base log out of the way since flush-logs will reset it too.
......@@ -117,6 +120,11 @@ if (-e "$LOGDIR/$BASE") {
print STDERR "Could not move $LOGDIR/$BASE to $LOGDIR/$basename!";
}
}
if (-e "$LOGDIR/$SLOW") {
if (system("/bin/mv $LOGDIR/$SLOW $LOGDIR/$slowname")) {
print STDERR "Could not move $LOGDIR/$SLOW to $LOGDIR/$slowname!";
}
}
#
# Do a mysqldump. This will reset the log files.
......@@ -144,6 +152,17 @@ if (-e "$updname" && system("gzip -9 $updname")) {
fatal("gzip $updname failed!");
}
if (-e "$slowname" && system("gzip -9 $slowname")) {
fatal("gzip $slowname failed!");
}
# Should do this too, but right now I do it by hand ...
if (0) {
system("find . \( -name 'base.*.gz' -o -name 'update.*.gz' ".
" -o -name 'slowqueries.*.gz' \) ".
"-mtime +35 -print -delete");
}
#SENDMAIL("stoller", "DB Backup Finished", "", undef, undef, ($logname));
unlink("$logname");
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