-   Linux - Newbie (
-   -   How to backup a Unix machine? (

tezarin 10-11-2012 08:51 AM

How to backup a Unix machine?
I have two Unix machines and they both are file servers. I have Samba installed on both of them and there are files which are being shared remotely by my Windows users.

I would like to have backups of the structure in case something happens in the future and the boxes get corrupted (I've already gotten the files backed up) so that if the machine burns out, then I can quickly install CentOS on another machine and get the box up and ready to go in less time.

What is the best way to back up the structure of the machine and which files/directories need to be backed up?


MensaWater 10-11-2012 09:21 AM

You say "UNIX" then mention "CentOS". CentOS is Linux. Although there are lots of similarities because Linux started as a clone of Linux it isn't really proper to call it UNIX. Most people when speaking of UNIX and Linux say *nix.

So are both the system's you're talking about CentOS?

If so I'd recommend MondoRescue:

It lets you create an install CD or DVD that looks like the system you created the image from.

As to what to include in it the answer would be anything you're NOT including in other backups. In general the system directories you need are /etc, /var, /usr, /bin and /sbin, /root and any individual files in / itself. What we do here is setup our applications and databases in separate filesystems (e.g. /application, /database) and exclude those from OS backups because we back those up separately (not using Mondo).

Ideally you should create the Mondo image, do a backup of the OS say once a week, do a backup of any application/data that changes at least that often. In a rebuild scenario you'd reload from the Mondo image, restore the most recent OS backup then restore the most recent application/data backups.

Of course if your system is small enough you could actually put it all in a Mondo image. Since Mondo generates iso files you don't even have to burn them to media - you can simply copy them off to other locations and burn them when you need them (or use other install methods).

JaseP 10-11-2012 09:47 AM

If they are simple file servers running SAMBA, and this is a personal/small business setup, you don't have to go hog-wild backing up everything,... Just the directories with data, user accounts and the SAMBA config. If they are running other services, then that's different. Basically, anything you change from a standard install needs to be backed up. You can do that simply with something like rsync (or grsync for graphical interface).

If this is an enterprise setup, that's different. In that case you might want to virtualize the SAMBA servers, clone the virtual machines and store them away as backups, and, obviously, your data. If the machine fails, you get a machine that'll run your virtualization software (VMware, KVM, VirtualBox, whatever), and pull over your cloned backup,... & presto! you're back up again. Some servers require special access to hardware that doesn't lend itself to virtualization ... For those situations, you need a complete backup solution.

oneindelijk 10-11-2012 09:59 AM

If you rather have a full disk backup, give DriveImage a try.
It makes an image from a running system and it's free

tezarin 10-11-2012 10:11 AM

Thanks for your replies, very helpful.

Two servers are just simple Samba servers. The third server is the mail server. The OS for all three are CentOS. The mail server software is Zimbra.

Since I'm new to this, let me make sure I understand everything correctly:

1) For the Samba servers, I copy these directories: /user, /etc, /var, /usr, /bin and /sbin, /root and the directory where the actual shared files are.

2) For the mail server, I copy the above directories as well as the /opt/zimbra directory (per zimbra forum folks that's where Zimbra files are)

But how would I copy them? I grabbed a 500 GB external hard drive, installed WinSCP and copy the files remotely from my CentOS machines to my Windows XP machine and paste them into that 500 GB drive? Sorry if that sounds silly, I'm trying to learn, please bear with me.


JaseP 10-11-2012 10:37 AM


I suggest you study a bit more about Linux file/directory structure in general, and CentOS in particular. The default SAMBA config file is located at /etc/samba/smb.conf ...

In CentOS, SAMBA configuration is complicated by the SELinux stuff and iptables rules. You don't necessarily have to backup everything. You'll want to capture SAMBA configurations, security configurations, logs, maybe user accounts,... etc. In your #1, above, you are basically stating that you'll be backing up above 80% of the entire system,... for what is probably, more or less a standard CentOS install. Wasteful at best,... missing important info at worst... At that point, you might as well just clone the entire system, imaging the entire drive. If you did that, you (or someone helping you) would be able to recover the system...

The directories, /usr, /etc, /var, /bin, /sbin, etc. are going to contain A LOT of data totally unrelated to the SAMBA file server,... just standard system install stuff...

How many users do you have? How much file space is being utilized in the shared files? How many files? What kind of data, and what kind of operation is this? Why are there two SAMBA servers versus one?

Why would you try to throw backups on a WinXP machine (Windows doesn't respect Linux file/directory structure very well, you know)?

Those questions, and their answers, are going to determine what type of backup plan you are going to implement.

eyanu 10-11-2012 10:49 AM

One command i like using is rsync, it lets you synchronize files from one server to another, you can create a cron to do that to whatever time you want so your files will be in sync, one machine has to be be a client while the other the server.

tezarin 10-11-2012 10:51 AM

I already have backed up the files (Excel, Word, etc) as well as the samba conf file. It would be super easy for me to set up a new machine, install CentOS on it followed by a clean install of Samba. But I would like it to make it fast to get that new box up and running if I need to.
So you're right, I probably don't need to back up all those directories.
I was trying to move them to the external hard drive which I have attached to my Windows machine (remotely) simply because I didn't know what else I can do to backup the data.

You mentioned cloning, how does that work? I need to make sure if something happens to the mail server, I have a clone that I can easily put to use immediately.


oneindelijk 10-11-2012 10:59 AM

if you have the space you can clone your partitions with dd

dd if=/dev/sda1 of=/media/USBDISK/IMGFILE.img
Where you should replace sda1 with the partition you are backing up, USBDISK with the name of the target filesystem, and IMGFILE with the name you want to give to the backup.
This can take a long time though, depending on the size of the partition

JaseP 10-11-2012 11:13 AM

You want my REAL suggestion?!?!

If this is one physical location....

* Use ONE relatively powerful machine that has hardware virtualization support. Install KVM. Create two virtual machines,...
* One as file server, the other for mail server.

* Use the external drive as your file storage area.
* Have a second external for storing backups (1 TB drives are relatively cheap now,... I suggest Seagate over WD, because WD puts a lot of crap on their drives).
* Format your external drives as EXT4.
* Do not use Windows file formats on the servers or their external drives,... SAMBA will take care of compatibility for you.

Duplicate your existing SAMBA setup on the file server VM, and the Zimbra mail server on the other. (Copy the necessary config files if you can, or just use them for reference when setting up the new ones)

When the VM servers are set up,... clone them (using the KVM management utility).
For the uninitiated, KVM is pretty much like VirtualBox in the way it works, or similar enough, anyways.

For backups, clone them on a regular basis (during off-peak hours). That can be set up as a cron job, eventually, so it's more hands-off.

Then,... Learn Linux,... well,... basic shell scripting,... security,... how a system I initializes,... etc.

Oh,... and I'm sure others will have competing ideas for what you should do... take them all in, and make an informed decision. There's more than one way to skin a cat...

MensaWater 10-11-2012 11:30 AM

I think the discussion has gotten off track. The OP mentioned backups but his post seemed to indicate his real concern was how to quickly build a NEW server if the current one failed.

While installing a new server from scratch and copying in the application/data files sounds reasonable on its face in reality it ignores the possibility that the applications he's running require special files in other locations such as /etc, /var, /usr/lib, /usr/share or /usr/local even though the application itself is mainly installed in a completely different area. If so he'd be losing times on a fresh build because he'd have to reinstall or at a minimum reconfigure such files for the application to work properly. Additionally there are other setups that aren't part of the application but are required for it (e.g. networking).

This is why I suggested Mondo - it creates an image of the system as it is but moreover creates it as an installable ISO so it can be used to install on new hardware doing the same setup.

It appears the suggestion for DriveImage may be for the same but I'm not familiar.

The suggestions for cp, rsync etc... don't address what the OP asked originally.

tezarin 10-11-2012 11:52 AM

Thanks everyone. I appreciate all the info.

I would like to try Mondo, the KVM solution is good, but MensaWater is right, I would like to be able to quickly put a server back in the rotation should things go wrong one day (God forbidden of course).

How do I start with Mondo? What do I need to do?


JaseP 10-11-2012 12:02 PM

Then go with Mondo,... but research and explore virtualization for the (near) future,...

If you want to be back up fast,... there's nothing like firing up a backup virtual machine clone after the one in use has failed. We're talking minutes (provided you have other running hardware), versus hours...

However, I suspect that your hardware is going under-utilized. Having two SAMBA servers in the same physical location just smacks of overkill. I also suspect that your operation is on the small-ish size (around 10-35 users, or less). For mail and file serving, more than one physical server is often overkill for an organization of that size.

tezarin 10-11-2012 12:45 PM

JaseP, dopesn't Mondo do the same thing? It gets an image of the machine which can later on be installed on the new machine?

Is there anywhere I can ready more on your solution (virtualization and KVM)?


MensaWater 10-11-2012 12:55 PM

Virtualization is a good thing and as Jase says can be used to very quickly getup a clone of your virtual host. Unfortunately it is on the same physical hardware so having that hardware fail would kill both the live VM and the clone.

There ARE methods for copying VM clones from one physical server to another but it requires having the virtualization setup on both hosts at the same time. I've seen a lot of discussion on that for VMWare so possibly KVM allows for it as well.

KVM is the virtualization that later versions of RHEL5 and all versions of RHEL6 want you to use. Since CentOS is a binary compile from RHEL source it has much the same functionality so any document you find discussion RHEL KVM setup would be applicable to CentOS.

You haven't mentioned what version of CentOS you're running (type cat /etc/issue to find out). Earlier versions of RHEL5 (and therefore CentOS 5) supported Xen rather than KVM.

All times are GMT -5. The time now is 08:15 PM.