Sunday morning post

This morning, Roxie was playing with a little play stroller that they have.  Reagan wanted to play with it, so she offered the little Push-n-Pop toy that they have as a trade.  Reagan started doing this, just recently.  She is a smart girl.  While I was typing that last sentence, Wendy handed Roxie her sippy cup of water and I heard a distinct “Thank you.”  Very cute and polite.  I’m really proud of how my girls are progressing.

Buddy is missing

About 25 minutes ago, I realized that I haven’t seen Buddy in over 4 hours.  So I’m frustrated.  I’ve already checked around the house and Wendy and I have both called for him.  It’s now Midnight and our garage door is open, in the hopes that he’ll find his way home.

Update at 12:17 AM:  Buddy just came in through the garage door.  I’m going to relax.

A backup strategy for nelsonshack.com

So I wanted to backup the web directory on my server, as well as the databases that mysql uses.  Here is how I did it.

1.  First, I wrote a couple of admittedly novice scripts (I am a novice bash scripter), which I placed on the server in question, under /root/scripts, because I needed these to run as root (I’ve since learned that there is a better way, but, here we are, so far).  The first script, which backs up the servers databases, is called backup132db and looks like this:

#!/bin/sh
Date=`date “+%Y-%m-%d”`;
echo $Date “Backing up all databases” >> /root/scripts/scriptlog;
/usr/local/bin/mysqldump -u username -ppassword –all-databases > /home/user/backup/132/databases/alldatabases-$Date.sql;
echo $Date “Database dump finished” >> /root/scripts/scriptlog;
/usr/local/bin/rsync -ave ssh /home/user/backup/132/databases/* user@x.x.x.133:/home/user/backups/backup132/databases/
echo $Date “x.x.x.132’s databases are now backed up to x.x.x.133!!!” >> /root/scripts/scriptlog;
echo ” ” >> /root/scripts/scriptlog;

The second script, which backs up my webserver, looks like this:

/usr/local/bin/rsync -ave ssh /usr/local/www user@x.x.x.133:/home/user/backups/backup132/
echo “x.x.x.132’s websites are all backed up!!!”

I should explain, at this point, that I have set up private and public keys for this set up.  It appears to be necessary for non-intervention backups.  🙂

2.  I set up cron jobs to make this happen, every night at 11:59 PM.  To edit those jobs, as root, I ran crontab -e, which allowed me to add the following:

SHELL=/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/root/scripts
HOME=/var/log
#
#minute (0-59)
#|   hour (0-23)
#|   |    day of the month (1-31)
#|   |    |   month of the year (1-12 or Jan-Dec)
#|   |    |   |   day of the week (0-6 with 0=Sun or Sun-Sat)
#|   |    |   |   |   commands
#|   |    |   |   |   |
#### rotate logs weekly (Sunday at midnight)
00   0    *   *   0   /usr/bin/newsyslog

#### backup x.x.x.132’s databases (every night at 11:59 PM)
59   23   *   *   *   /root/scripts/backup132db

#### backup x.x.x.132 www directory (every night at 11:59 PM)
59   23   *   *   *   /root/scripts/backup132web

Special thanks to the following sites that helped me figure this stuff out:
http://www.aota.net/forums/archive/index.php/t-8362.html
http://www.foogazi.com/2006/12/07/understand-cron-jobs-in-5-minutes/
https://calomel.org/cron_at.html

To recover all databases (tested)

mysql -h localhost -u [username] -p < alldatabases.sql (from http://www.nagpals.com/blog/index.cfm/2008/2/27/Backing-up-and-restoring-all-MySQL-databases)