#!/bin/sh

read -p "Customer box short hostname: " BOX    # set variable to customer box short hostname
mkdir -p /var/log/backups
mysqldump backups > /var/log/backups/backups.$(date +%s).sql  # backup database
mysql backups -e "select * from iscsimounts i, server s where i.plabel like '$BOX%' and i.bboxid = s.serverid;"
read -p "Enter bboxid of the old backup server: " BBOXID    # set variable to bboxid of old backup server
mysql backups -e "delete from iscsimounts where plabel like '$BOX%' and bboxid = $BBOXID;"    # delete specific backup box
echo "Result..."
mysql backups -e "select * from iscsimounts i, server s where i.plabel like '$BOX%' and i.bboxid = s.serverid;"
echo "We're done here. Next, work on old backup box."
exit  # we're done with backupmaster

