Category / code

Pyweek April 17, 2010 at 4:22 pm

2 weeks ago me and my friend made a game for pyweek 10 where you ride a unicycle.

You can see the project page here to download the game.

Voting ends tonight so we’ll be able to see how we did. You can see a video of the game here: http://www.youtube.com/watch?v=yQrzsNs6br4

Cheap backups via google mail February 27, 2010 at 5:26 pm

If you need or want a cheap(free) remote backup option for a small website, consider using google’s generous mail service.
This script runs in the middle of the night each day:

#!/bin/bash
#Make dump of the database from mysql
mysqldump --user=dbuser --password=dbpass --databases dbname --opt --quote-names --complete-insert | bzip2 -c > /tmp/dbbackup.bz2

#Move yesterdays backup to .old, just in case we want to keep it for some reason
mv /home/user/backup.tar.gz /home/user/backup.tar.gz.old

#tar up all the files
tar -cf /home/user/backup.tar /path/to/some/data /path/to/more/data /tmp/dbbackup.bz2

#compress them
gzip -9 /home/user/backup.tar

#Split the files up into 5mb chunks called backup.aa, backup.ab, backup.ac etc.
split -b 5m /home/user/backup.tar.gz /home/user/pieces/backup.

cd /home/user/pieces
FILES="*.*"
for f in $FILES
do
        #uuencode the file and send it as an attachment
        uuencode $f $f | mail mybackupmailaddress@googlemail.com
done

Recovering your backups requires downloading all the pieces for that day(this is the longest part of the process) and performing:

cat backup.* > backup.tar.gz