LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to backup a Unix machine? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-backup-a-unix-machine-4175431661/)

tezarin 10-11-2012 07:51 AM

How to backup a Unix machine?
 
Hi,
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?

Thanks

MensaWater 10-11-2012 08: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: http://www.mondorescue.org/

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 08: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 08: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 09: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.

Thanks

JaseP 10-11-2012 09:37 AM

Uhmm,...

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 09: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 09: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.

Thanks,
h

oneindelijk 10-11-2012 09:59 AM

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

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 10: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 10: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 10: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?

thanks

JaseP 10-11-2012 11:02 AM

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 11:45 AM

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)?

Thanks

MensaWater 10-11-2012 11:55 AM

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.

JaseP 10-11-2012 12:11 PM

The point of virtualization is that you are running a virtual machine from within a physical machine,... and can actually run several VMs at once. That way, one (sufficiently powerful) machine can do the job of several others. By limiting the VM to one particular server task, it can be more efficiently administered. For instance, if the mail server goes down, or requires maintenance to the point that it requires a restart,... you are not restarting the file server as well.

Many times, the computers are sitting at idle states,... under-utilizing their CPU capacity, while another machine, sucking electricity, is idling in the same way... So, double the electric bill (power and air conditioning), and the same (wasted) performance.

Also, starting up a clone of a VM is arguably easier than installing a drive image to a new machine and expecting it to work... Hardware differences, making sure the image boots,...,etc. ... can be very challenging. A Virtual Machine is a pristine environment. The exact hardware that the VM's OS expects is emulated within the VM's defined environment. So, there's no crying and gnashing of teeth when a particular piece of hardware that a backed up drive image expected (Ethernet chipset, southbridge, etc.) is missing or different.

There are downsides... obviously. Among them are; slowdowns when overbooking the CPU, (potential) lack of direct access to hardware, some configuration issues (notably with networking), the chance of having older/inadequate hardware to run virtualization efficiently, and some services that might not play nice inside a virtual machine,... But, overall, virtualization is a terrific solution to a number of problems.

MensaWater 10-11-2012 01:11 PM

Here's a thread that talks about how to copy a KVM guest from one physical host to another. I haven't done this myself.

http://serverfault.com/questions/156...ost-to-another

Again unless you've got at least TWO PHYSICAL hosts virtualization isn't going to solve a general hardware failure but it can solve many other issues short of that. The reason I didn't suggest virtualization is because the OP specifically asked about hardware failure.

tezarin 10-11-2012 01:14 PM

Quote:

Originally Posted by MensaWater (Post 4803181)
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.

Thanks, I use:

Mail server:
uname -a && cat /etc/*release
Linux servername 2.6.18-238.12.1.el5 #1 SMP Tue May 31 13:22:04 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
CentOS release 5.6 (Final)


Share server 1:
Linux servername 2.6.18-194.32.1.el5PAE #1 SMP Wed Jan 5 18:43:13 EST 2011 i686 i686 i386 GNU/Linux
CentOS release 5.5 (Final)


Share server 2:
Linux servername 2.6.18-194.32.1.el5PAE #1 SMP Wed Jan 5 18:43:13 EST 2011 i686 i686 i386 GNU/Linux
CentOS release 5.5 (Final)

The Samba servers have to stay separate for security purposes.

If I decided to go with Mondo, how do I start?

Thanks

tezarin 10-11-2012 01:32 PM

Quote:

Originally Posted by MensaWater (Post 4803232)
Here's a thread that talks about how to copy a KVM guest from one physical host to another. I haven't done this myself.

http://serverfault.com/questions/156...ost-to-another

Again unless you've got at least TWO PHYSICAL hosts virtualization isn't going to solve a general hardware failure but it can solve many other issues short of that. The reason I didn't suggest virtualization is because the OP specifically asked about hardware failure.

Let me mention that we were using Bacula before, it got corrupted and I wanted to do a clean install but it is a very complicated tool. Let's see how Mondo works, any tips on how to start? Thanks in advance

chrism01 10-12-2012 12:40 AM

For Mondo, read
http://www.mondorescue.org/
http://www.mondorescue.org/docs/mond...VERVIEW-SYSREQ
http://www.dedoimedo.com/computers/mondo.html

Just a do few practice backups until you get the hang of it. Its actually quite straightforward.

The main problem with backing up the entire OS with eg Mondo and similar tools such as Clonezilla is that the new system has to have the same HW, because you are backing up the kernel+drivers etc.
That's why, in commercial scenarios, its common to backup the NON-OS files separately, in case you have to install, on new HW.
Of course over time, you'll most likely want to upgrade the HW.
Mondo will allow you to do this as well, see the links.

RE KVM: your version of Centos is new enough I think (KVM was issued from 5.4 or 5.5 iirc), but it will be an older version.

Potentially you could use your practice backup+recovery tests to upgrade to Centos 6 (currently 6.3).

NB:
"Its not a backup unless you've done a SUCCESSFUL recovery, otherwise its just an interestingly arranged collection of bits"

tezarin 10-12-2012 10:28 AM

Thanks Chris, I will read that. I will need to purchase a new machine to be used for this purpose, right? If so, what do you recommend i should get?

Thanks

Thad E Ginataom 10-12-2012 01:14 PM

Whatever you choose, do make sure that it works, and that means, somehow, test it!

tar is still, in my book, a great candidate for a backup tool. You mentioned Windows external drives, and it was rightly commented that Windows file systems do not respect *nix directory and file elements: these (ownership, group, permissions etc) are absolutely vital for systems files. However, you can write a tar archive to an ntfs file, and all the necessary stuff will be maintained within it.

I no longer have any other users or commercial aspects to consider (apart from wife!) but what I do is:

regular data-file backups with rsysnc.

occasional systems-file backups (/, non-data files in /home...) with tar.

I write to external NTFS drives. I keep one off-site, and if this was an office I'd be doing that daily, not every-so-often.

I love the look of Mondo. Never made it work on my (Ubuntu) system.


All times are GMT -5. The time now is 12:14 PM.