by admin on January 12, 2010
I have never been a big fan of new years resolution since they often go by the way side. But on the other side of the coin I think everyone should have goals, both long and short term. So in that vein here are my goals for this year. (in no particular order)
- Simplify and de-stress – I want to try to stress less about work and other things this year and concentrate on the things that are important.
- Move, which hopefully is a good opportunity for the above.
- Try to blog regularly
- Spend more time with my wife and son
- Get back into developing (not full time but I feel I should do it to maintain my perspective in what I do)
- Encourage others to help more with local conferences (new blood is always good)
- Follow up with contacts
- Continue reading in the evenings which I started to do again a lot recently
Over the coming year I may edit this list as a kind of checklist as to where I am at the moment so stay tuned.
by admin on January 7, 2010
I am starting a few new blogging series this year the first one will consist of Tech tips that I find during the course of work or when working on private projects. I have alot of these bookmarked in firefox or delicious as I am sure many if not most of you also have. I personally find that it helps me remember better if I write it down and it certainly helps if you have it in one quickly accessible location.
Now lets get down to the nitty gritty of of it. As many of you know to backup MySQL databases, there is the well known and handy executable called mysqldump. It has one big shortcoming though, you can either backup one database to a file or all databases to one giant file with the “–all-databases” option but you can’t backup every database to separate dump files.
This is not very practical if you have big databases and need to restore only a part of them…So I searched for a way to backup every database to separate files. The process is quite simple with a little scripting:
- Find a way to list all databases
- For each database, dump it to a file using mysqldump
Here is the solution that I found with some updates
#!/bin/bash
# This script backups every MySQL database to its own file
#Some variables you can set how you like
USER=’root’
PASSWORD=’mypassword’
OUTPUTDIR=’/root/backup’
MYSQLDUMP=’/usr/bin/mysqldump’
MYSQL=’/usr/bin/mysql’
#Clean up any old backups
rm -f $OUTPUTDIR/*
#Get a list of databases names except the system one
databases=`$MYSQL –user=$USER –password=$PASSWORD -e ‘SHOW DATABASES;’ | grep -Ev ‘(Database|information_schema)’`
#Dump each database in turn and compress the output
for db in $databases; do
$MYSQLDUMP –opt –hex-blob –force –user=$USER –password=$PASSWORD $db | gzip > $OUTPUTDIR/$db.gz
done
PS: Wordpress seems to replace double dashes (- -) with a single one (-) in the code, so just be aware of that.
I also strongly advise you to use the –hex-blob option for mysqldump if you have any blobs (binary files like executables, images…) in your database, otherwise you may end up with an un-restorable database, even if the backup process went well.