Backing up a CentOS webserver
Linc
OwnerDetroit Icrontian
I have an old CentOS 5 webserver in an old Dell running a LAMP stack that has a bunch of old twisted code and configurations on it. Basically, if it died, that'd be the end of the setup because no one has the resources to redo it all. I'm not sure I could even remember enough to do it. And, it's important to an old client's business.
What's my best strategy for creating a backup that I could get the machine running again with without recompiling and reconfiguring all the things?
I have root access. I can physically get to the machine and could remove the hard drive if necessary to do this, but it's a bit of a drive if I gotta do that.
PS: I have no goddamn idea how to even mount a drive in Linux and have no idea what the state of the drivers are on this thing. I've never done anything with it physically since popping in the CentOS discs back in 2007.
What's my best strategy for creating a backup that I could get the machine running again with without recompiling and reconfiguring all the things?
I have root access. I can physically get to the machine and could remove the hard drive if necessary to do this, but it's a bit of a drive if I gotta do that.
PS: I have no goddamn idea how to even mount a drive in Linux and have no idea what the state of the drivers are on this thing. I've never done anything with it physically since popping in the CentOS discs back in 2007.
0
Comments
There are numerous ways of making a full system backup for any Linux distribution. They range from the simple to the super complex. I assume that you're going to want the simple, not so much the complex.
rsync is your friend. It is the best tool for doing simple snapshot backups of a single system. In order to make a full snapshot backup of the whole server, it takes a bit of tweaking and scripting. Not sure how good your bash scripting chops are. I could probably help you build a backup solution if you want in my off-time. Get in touch with me if you want and I'll see what I can do.
What would I be doing, rsync-ing the whole thing to my local machine?
Actually, if you just want to make a single backup (not automate the process for unattended backup love) then scripting probably isn't necessary. You can just run the rsync manually. It will likely take a long time though, just throwing that out there.
The most basic backup of a full linux system using rsync can be accomplished like so:
exclude.txt should be a plain text file with any paths, files or file name patterns you don't want backed up. One per line. At the very least, you will want the following in exclude.txt You may also want to exclude /var/lib/mysql (or wherever you are keeping your mysql backups) as rsync has no ability to make a clean backup of live mysql databases. You would then want to back up the databases through some other method (phpMyAdmin or simply mysqldump).
The easiest way to restore from this after a failure would be to install a new server with a basic CentOS 5 build, set up SSH, then basically do the rsync in reverse to push all the data back to the server. Once complete, reboot and it should be back as it was when the backup was taken. Take special care not to overwrite /etc/fstab though unless you manually confirm that the old one will work. (It's a good idea to back it up, for reference purposes, but restoring it usually leads to disaster).
We often use this method when a customer wants to upgrade a server to a larger drive. It works well.
ssh myhost.com 'tar -zcf - /' > backup.tar.gz
I'm missing a whole bunch of important flags and details there, but that's the gist.
The pro: You get a compressed archive on your local system. The con: If the process gets interrupted, you start over. The big nicety of rsync is that you can stop and restart it at any point and it'll pick up where it left off.