Tuesday, October 20, 2009

Backing up MySQL databases

Oxford have installed a simple script to backup the DPM mysql db once a day at 6am.
The script was loosely based on Glasgow's example here .

In order to restrict the file names produced to just 7, I've opted to use the current day rather than date.

[root@t2se01 ~]# cat /root/mysql-dump-pdg.pl
# Loosely based on the Glasgow script but simplified.
# Select the current day only as we want to have just seven unique file names which will be overwritten
# thus reducing the total backup size.

@weekDays = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
$theTime = "$weekDays[$dayOfWeek]";
#print $theTime;


# Read mysql password
open(PW, $mysql_pw_file) || die "Failed to open password file $mysql_pw_file: $!\n";
chomp $mysql_pw;
close PW;

# Dump the db now
chdir $backup_dir || die "Failed to change to backup directory $backup_dir: $!\n";

system "/usr/bin/mysqldump --user=$mysql_user --password=$mysql_pw --opt --all-databases | gzip -c > mysql-dump-$theTime.sql.gz";
die "Mysql failed died with exit code $?\n" if $? != 0;

This is run by /etc/cron.d/mysql-dump
0 6 * * * root /root/mysql-dump-pdg.pl

So far it seems to work in testing!

Monday, October 19, 2009

Oxford Grid now SL5

All but one worker node on the Oxford Grid site has been reinstalled running SL5.
Currently these are served by one ce, t2ce05, but more will be added shortly to offer resilience.

Wednesday, October 14, 2009

Quarterly Report DPM script

Each quarter we needs to report on disk usage at our sites.
This can be tricky but the following script will help at DPM sites:


DAY=`date +%F`
echo $DAY
for zz in `dpns-ls /dpm/physics.ox.ac.uk/home/`;do
dpns-du -z -s /dpm/physics.ox.ac.uk/home/$zz>>Oxford-SE-Usage-$DAY;

You will need to modify it appropriately for your site.
Extra added 20.10.09
This makes use of the dpns-du command in the gridpp-dpm toolkit available from :

Details of the other commands are on the wiki