Tale of a Server Rebuild Part 1

As the old adage goes “the worst car on the road is driven by a mechanic” and the same can be true for techies and their servers.

My personal hosted server has been chugging along quite nicely for the last 6 years with only a need for the occasional reboot and regular security updates. It has survived bad code, Brute force attacks and numerous experiments …

Imagine my recent surprise when I logged in to update php to a more recent version to discover that some of my repositories seemed to fail, a quick google later and I found the my OS was no longer supported by Ubuntu.

So for the first time I contacted my hosting company to find out what the upgrade plan was. The news I received wasn’t good. I found that there wasn’t one, worse still the newer versions of the server used a different control panel, so a rebuild was going to be more complicated than I wanted.

Step One, The Plan
Now I’m not saying that I have OCD or anything but the first thing I started doing was making lists. The lists were:

Domains hosted on the server.
Email addresses for each domain.
Which domains had databases.
User names and passwords for everything listed above.

Now I was confident that when I built everything again on the other side all email accounts and db connections would work properly.

Step Two, The Backup
Starting with the home directories I starting tarring them up, of course checking first to see how much space I had left incase I would have to tar a few and then move them off hut. Thankfully over 50% of my home partition was still free so I figured I’d be ok.

For those who haven’t used Tar before its really quite easy, it create a g zipped tar file use the following;

tar czf david.tar.gz /home/david/public_html/*

This will save the tar.gz file into your current directory. I then just went through all the home directories and made these backups.

Next came the mail boxes. I know that the new server will use qmail instead of sendmail so some googling to make sure I do it right and I found the following:

http://qmail.jms1.net/sendmail-migration.shtml

So I got the makeusers file and all the relevant mailboxes, remembering to back up the password and shadow files in /etc ready for the new build. Ideally you would be moving onto new hardware, but I was going to be rebuilding on the same box so I had to hope that this would all work on the other side.

Finally the databases. This was easy now that I had my list of db users and passwords, I decided to not be lazy and use the root user as this would give me a chance to test the passwords as I went along. Using mysqldump I backed them up one at a time.

Mysqldump -u[username] -p [database name] > [filename].sql

Step Three, The Download
Once I had all of this I kicked off an scp to download all the files to my local machine and went for a cup of tea. If you don’t use linux at home as well you can move the files to an ftp accessible directory and download them that way as well.

When this had completed I sent the email to the hosting company giving them the OK to rebuild, then I would find out if I had missed anything.

I will cover the trials of configuring the new server in part two.

This entry was posted in Managed Hosting. Bookmark the permalink.

Comments are closed.