Checking xtrabackup has worked

As part of running backups I like a notification if one has failed. As far as I can find so far there are no return codes from the innobackex script that I could use so at the moment I am just checking the output for the line innobackupex-1.5.1: completed OK

/usr/bin/innobackupex-1.5.1 $BACKUP_DIR 2> /home/backup/logs/backup-$BACKUP_FILE.log
less /home/backup/logs/backup-$BACKUP_FILE.log | grep “innobackupex-1.5.1: completed OK”
if [ $? -ne 0 ] # string not found, ie. backup failed
echo “Backup failed”
mail -s “MySQL Production Backup failed” ????@????????.com
exit 1
echo “Backup Ok”

Checking xtrabackup has worked

/bin/tar: Argument list too long

Sometimes you have too many files in a directory for tar to handle


tar -cvf jan2010.tar *.xml

does not work and you get

/bin/tar: Argument list too long

They way I got around this was to use find

find . -name ‘*.xml’ -print > /tmp/tar_list
tar -cvzf jan2010.tar.gz –files-from /tmp/tar_list
find . -name ‘*.xml’ -exec rm -f {} ;

/bin/tar: Argument list too long

Changing Settings for all tables

As part of my migration to MariaDB I wanted to change all the wordpress tables from MyISAM to INNODB. Of course you can do this one table at a time with

alter table fred engine=innodb;

Personally I prefer to automate where ever possible so  I created the following linux shell script to convert all the tables in one database in one go

for t in $(mysql -u$DBUSER -p$DBPWD –batch –column-names=false -e “show tables” $DBNAME);
echo “Converting table $t”
mysql -u$DBUSER -p$DBPWD -e “alter table $t engine=innodb” $DBNAME;

This script could of course be used for many things by just changing the SQL in line 7

Changing Settings for all tables