mysqldump to multiple files

It is a good idea to run mysqldump by cron to regurlarly make backups of your MySQL databases. An easy way to do this is by adding the –all-databases parameter.  This way you will have a backup of all your databases – in one file though. If the amount of data and the number of databases is small this might be ok.

After the first session of restoring just one database or one table from your one-file-backup you realize that it would be nice to have the dumps split up in some convenient way. Like dumping each database to one file, one for each database.

This little shell script does the trick for you. It is really simple and has no error handling what so ever. It is released under GNU GPLv2 license. If you modifiy it or add features (like error handling or so), please do send me a copy or post it as a comment here.


#!/bin/sh
# mysqldump-multi.sh
# Copyright HelTech Communication, Stefan Helander 2010
# stefan@heltech.se, http://www.heltech.se
#
# Licensed under GNU GPLv2
#
# Dumps all MySQL databases. Each database stored in a single file.
#
# settings

DUMPDIR=/root/mysql-backup/backups
MYSQL_HOST=localhost
MYSQL_USER=root
MYSQL_PASS=YOUR-PASSWORD-HERE
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump

# dump each db

for DB in `echo 'show databases' | $MYSQL -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS --batch -N`
do
$MYSQLDUMP -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS --quote-names --create-options --force $DB > $DUMPDIR/$DB.sql
done

Prestashop 1.2.x not showing Categories box

Problem: In the front system (FS) Prestashop is not showing the Categories box. In the back system (BS), clicking on the Catalog tab shows just a blank page, or an error message saying the page is unavailible. The probable reason is that your Home category is missing or messed up. The problem is that you can’t get into the Catalog tab in the backend system to fix it. I ended up in this situation by trying to import categories as a CSV (comma/semi colon separated file) and I had a category in that file with ID = 1. Category ID number 1 is reserved for the Home category. Prestashop did not filter this or issue a warning during the import. So take it from me – do not try to import a category with ID = 1. Prestashop table ps_category in phpmyadminSolution: I opened my database with phpmyadmin and went to the ps_category table. The row for id_category 1 was messed up and by comparing it to a backup I set it to: id_category = 1, id_parent = 0, level_depth = 0, active = 1. The dates I left as they were. Then I went into the table ps_category_lang and made sure that there were entries for id_category 1 for all languages that I had installed (I had two in my system). Voila, back and front system now works. By adjusting the ID:s in my category import file (making sure no ID was 1) it worked like a charm to import it.

FON 2.0n router sharing 3G over Wifi

When you’re travelling as a professional nerd, you regularly needs to access the Internet. Internet cafés can be expensive and 3G… don’t think about using it abroad. It ususally costs a fortune.

I joined the FON network where you share your broadband connection at home to other FON-users and in return you are able to use the 1.5 million (and growing) FON hotsposts around the world for free.

In 2009 FON launched a new router, the FON 2.0n. It is packed with features (to read more about it, see FONs website), but most important is the USB port where it is possible to attach a 3G device. This enables you to share your 3G internet connection over the FON 2.0n wifi router. I usually bring this router on trips where I need to share my 3G internet connection to several computers over Wifi.

Read more

ASCII animated Star Wars movie

Star wars ASCII movie

To see it, you need a telnet client installed. In Linux and Microsoft Windows previous to Vista a telnet client is built in (obviously Microsoft figured no-one uses telnet anymore in Vista).

To see the movie, just do telnet towel.blinkenlights.nl

In Windows XP, click Start and then Run and type the line above in the run-command window. Then click OK.