Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm currently in the process of setting up and playing with my new Linux box. Being a newcomer to these things, I'm doing alright, but one small mistake can screw everything up for me. I've currently got Apache and some other things successfully installed and working how I want them to, and I really don't want to be able to screw the environment up.

What is the easiest way to backup the actual environment itself so that I can restore the backed up copy (with Apache etc. fully working) should I need to?

share|improve this question
    
If you don't mind paying linode have a backup service which has automated backups and you can do manual snapshots. –  Rwky Sep 3 '11 at 0:15
    
Unfortunately I don't have the money to pay for this service :( –  joesavage Sep 3 '11 at 8:16
add comment

3 Answers

up vote 7 down vote accepted

So there's two things,

  1. back up your data and configuration files
  2. write down / record the commands you used to build the environment and why

For number 1, there are several options, one of which Alex has already mentioned. rsync is a nice approach, and I rsync everything I care about on my Linux VPS to a Linux machine here at home on a regular basis.

But for me, you can't beat #2 as well, and here's why. Just having the config file doesn't help if you can't remember why it's like that.

Sometimes I fight for ages getting Exim to do one little thing, make a change 400 lines deep into a config file, and then forget it.

Even if I don't recover the server from a backup, I might want to build another server later and do the same thing, but suddenly I can't remember how, and you can't necessarily copy config files verbatim.

So, as you build and configure your server,

  1. write down every command you run (i.e. apt-get, yum, dpkg --reconfigure exim4-config, etc.)
  2. make a note of config changes you make and why (i.e. added these 4 lines to /etc/apache2/apache2.conf because I needed X and Y)

Keep that build document up-to-date when you add packages or change configs and then if you need to build a new server from scratch, it's easy.

I run a news (Usenet) server, and I basically have a document which describes how to go from bare Debian Squeeze to fully working news server. If I lose everything, I can rebuild it in about 2 hours (obviously, no data, but full config). Same for my web server, I know what changes I've made to Apache and why, which perl and php modules are installed and why, etc.

That way you can focus on backing up your data, and config, but you won't ever have to restore the config to a fresh box (which I think can be risky due to potential software / distribution changes) and can instead follow your build sheet and then restore your data.

  • rsync for data and config
  • paperwork for config on top
share|improve this answer
1  
gnu screen or script might provide you useful alternatives to writing everything down, but you will need to be able to get basic access to the system to review your logs. For your exim config example. Almost every configuration file supports comments. I usually leave a comment like #MYNOTE in config files. Something that will help me find it in the future with a simple grep. –  Zoredache Sep 2 '11 at 23:26
    
The 'history' command will help but it only goes back so far, and doesn't show which files you've changed. –  EightBitTony Sep 3 '11 at 9:14
    
Ended up just using rsync - works a treat! –  joesavage Sep 3 '11 at 20:12
add comment

I usually use etckeeper for backing up configuration files in /etc (actually for revisioning them), I set it to perform commit every 20 minutes and BackupPC for backing up everything else. BackupPC is probably an overkill in your situation so I suggest you to use just rsync -a to some other host.

share|improve this answer
    
Is the etc directory the only real important one though, or are there other things I need to backup? –  joesavage Sep 3 '11 at 8:10
    
It depends. Your best bet is to just rsync the entire drive –  Frank Thornton Dec 27 '13 at 2:58
add comment

If you wanted to backup the entire environment as it was, either to download to a local virtual machine or even put on a dedicated server, it can very easily be done with tar.

There is a nice guide here, http://ubuntuforums.org/showthread.php?t=35087

To Backup

sudo su
cd /
tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

To Restore

tar xvpfz backup.tgz -C /
share|improve this answer
    
Thanks, we don't really care about duplicating the internet (although more research on the part of OPs would be good) but we really do care about link rot. –  Iain Jun 22 '12 at 8:13
1  
The -v option is unnecessary and way overused. All it does is slow the process down by displaying the name of every file to the screen, too fast for you to be able to follow anyway. If you need a list of included files to check to make sure something wasn't left out, -t will take care of you after the fact, and has the added advantage that it doesn't slow things down if you don't need a listing. –  Steely Dan Dec 27 '13 at 3:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.