Wanted to share that Rackspace has an excellent collection of configuration guides for Ubuntu 10.04 server. Aside from Ubuntu they’ve got guides for every other big Linux distribution as well, such as Fedora, Red Hat, Debian and CentOS. I don’t use those distributions myself but thought it would be nice to mention it. Check their List of Articles for a complete list of Linux distributions. Aside from Linux they’ve also covered Windows Server 2003 and 2008.
Now that I’m using a CloudServer I figured I had to do something about backups as well. I’ve been using rsnapshot at work for a few years now and it’s an ideal backup solution. Because rsnapshot (which uses rsync as its base) makes use of hard links backups are very efficient. Basically it means that if a file isn’t changed it’s not duplicated, but a hard link is created instead. This way only changed and new files get copied. Deleted files will eventually be removed as well as soon as one of the backups expires.
Using rsnapshot for file backups is easy and the configuration explains this easy enough. Backing up MySQL databases however is a different story. When using MyISAM tables you might get away with copying and pasting the database files. With InnoDB not so much. Proper backups can be made with mysqldump. In my case I don’t have many databases so I want one big SQL backup file.
First, lets set up our backup script. I’ve stored it under /usr/local/bin/backup_mysql.sh with permissions set at 0700. The reason for these permissions is that I store my password inside the script and only want root to be able to open it. It also needs to be executable. I know it’s better to use a configuration file and use source to include the variables, but for my current use it’ll do (do note at work I’ve done this the proper way!). I also use the root user instead of a special read-only user. I know this is bad practice, but again I’ve done this the proper way at work. It’s an exercise for you to do it properly (hehe, that’s another way to put that I’m lazy). Anyway, here’s the script.
-
#!/bin/bash
-
mysqldump –all-databases -uroot -pmypassword –opt > mysqldump.sql
Nothing exciting. Change the credentials as required. Again, use source if you want to store the credentials inside a proper configuration file. Now, calling this script ./backup_mysql.sh will backup all databases inside the file mysqldump.sql in the current work directory.
Next is setting up /etc/rsnapshot.conf which is easy as well. At the end of this file you’ll find all the instructions of which directories to backup. Enter the next line. Do note that rsnapshot.conf uses a tab to separate values.
-
backup_script /usr/local/bin/backup_mysql.sh mysql/
To enable daily backups uncomment the next line:
-
#interval hourly 6
-
interval daily 7
-
#interval weekly 4
-
#interval monthly 3
To make rsnapshot run every day update /etc/cron.d/rsnapshot:
-
# 0 */4 * * * root /usr/bin/rsnapshot hourly
-
30 3 * * * root /usr/bin/rsnapshot daily
-
# 0 3 * * 1 root /usr/bin/rsnapshot weekly
-
# 30 2 1 * * root /usr/bin/rsnapshot monthly
Finally, try running rsnapshot. After it has run check your backup directory, which on Ubuntu 10.04 defaults to /.snapshots/. Be sure to mount /.snapshots/ on a separate drive. Because what use is it if your data drive contains your backup and decides to commit suicide?
$ sudo rsnapshot daily
Your MySQL backup file should now be located at /.snapshots/daily.0/mysql/mysqldump.sql. You can restore this file with the MySQL commandline client, or through MySQL Administrator from the MySQL GUI Tools.
Which apparently is the slogan for launching Ubuntu 10.04. I think this is going to be a very nice LTS release. It’s too bad that they didn’t include Perl 5.12 in it, but that’s understandable as it just got released; although compiling your own is very easy. On the other hand, PHP 5.3 got in there thanks to the pressure of some fellow Dutchmen. Not that I’m a big fan of PHP, but PHP 5.3 has some nice additions such as closures.
A little while ago I posted about waiting for Ubuntu 10.04 to be released to upgrade our webserver at work to. We were running Ubuntu 7.04 which already wasn’t supported anymore. Due to ClamAV stopping support for the specific ClamAV version on Ubuntu 7.04 we decided not to wait and upgrade as soon as possible. Which was earlier this week.
I had already created a well prepared upgrade procedure, which I finished somewhere in august 2009. Almost 5 months later I was happy to find out that upgrading was still a painless process and all went without problems. As upgrading from 7.04 to 8.04.4 isn’t directly possible I had to upgrade to 7.10 first, which also isn’t supported anymore. Luckily all the packages are still available online. Just not in the official repositories.
The only problem I’ve run into was with Postfix and the IMAP protocol. Some old accounts had their Maildir folder set to the user nobody (which was strangely deleted by the way). For some reason Postfix only accepts it when the group on the folder is users. All Maildir folders for the new(ish) accounts were already owned by the group users and didn’t give me any problems. A quick call chgrp fixed this issue.
Other than that no outstanding issues. So overall I’m VERY HAPPY with how painless upgrading from 7.04 to 8.04.4 was. Of course at the time I was working on my upgrade procedure there were quite some issues, such as HP Tools (hpasm, hpasmcli, hpOpenIPMI) not working. But all were resolved before doing the actual upgrade on the live server. In case of hpasm, in case somebody wonders, you no longer need the hpOpenIPMI driver, as there’s now a open-source driver for it called openipmi. No more recompiling this driver when upgrading the kernel
.
A month has gone by and winter has come!
My latest post was already a month ago!
So what’s up? For starters, winter has come and a lot of snow has fallen down. Other than that, not much really. I did start with my LPIC-1 study and hope to get a lot more done when Christmas comes. The current plan is to take the LPIC-1 101 exam around February, with 102 done somewhere before the summer. If successful I’ll be LPIC-1 certified around July 2010!
Other than that I’ve also been reading a bit from the books that I’ve listed on my bucket list. Game Coding Complete, 3rd edition is particularly interesting. Read about some cool stuff like a process manager and being able to execute a chain of processes after process gets killed. It’s not like it’s some sort of rocket science, but it’s an interesting technique to help write clean code. Another thing that gets quite some attention is resource handling and sticking it in a cache. All of this should make writing game prototypes a lot easier.
One particular thing that’s also on my bucket list is forming or joining a band. This was something I didn’t mean to happen very soon, but I got in contact with a drummer and we’re planning to jam very soon. Still looking for a bassist though. Looking forward to it!
Anyhow, although I just said that not much is up it looks like there is. I also plan on writing some articles on topics I come across whilst studying for my LPIC-1 certificate. Most of these articles will probably be reference material for myself.
Recent Comments