Ways to back up your OpenEMR/Linux system

rpl122 wrote on Thursday, September 06, 2007:

After going through all the tedium of installing, configuring and debugging OpenEMR, SSL, phpGACL, FreeB etc. I was looking for a way to back up my entire system and not just the data.

Here are two ways that worked for me:

While I installed Linux/OpenEMR in /dev/hda1 of the hard drive, I created another disk partition /dev/hda3 exactly the same size as /dev/hda1 using fdisk utility.  Then I cloned hda1 to hda3 using the dd command, specifying if=/dev/hda1 and of=/dev/hda3 and appropriate bs and counts.  The idea now was to create an additional boot option in the mbr of /dev/hda1 pointing to the kernel copy in /dev/hda3.  I also had to edit the /etc/fstab file to specify that /dev/hda3 rather than /dev/hda1 was to be mounted with that other boot menu option.  Well, it worked as expected.  No surprise, but a potentially useful way to keep a backup of your entire installation in case you mess things up and don’t want to start from scratch.

A second method was to make a tar.gz file of the entire file structure in the hda3 partition.  This required me to boot up in the hda1 partition, mount the hda3 partition and type a tar zcvf command.  My 40 Gig partition was shrunk to a 2 Gig archive.  To test this, I wiped out all content of the /dev/hda3 partition and then restored the blank, mounted, partition from the tar.gz file.  This restored the system, the data and settings perfectly.  Again, no real surprise, but potentially useful.

Next step is to try using the 2 Gig tar.gz file to transport a complete, tweaked and debugged installation of OpenEMR and all the accessories on an entirely different computer.  My hope is that kudzu and plug and play functionality will make this feasible.  If it works, then it should be possible to put the whole configured system into a downloadable file.  One would then have a real system – not a virtual machine.  Now if that works, that WILL be surprising.

Ronald Leemhuis MD

cyberandroid wrote on Thursday, September 06, 2007:

Please do share your results… thanks.

drbowen wrote on Thursday, September 06, 2007:

I agree about sharing. We could potentially post this for download on SourceForge.

Ronald,  Using Debian there is a way to trim the distribution down by shedding unwanted / unused programs.  This could get you down to possibly 650 megabytes (CD size instead of DVD).  I have seen "Kick lists" to use AptGet to do this.  It is likely worth looking into.

Sam Bowen, MD

rpl122 wrote on Saturday, September 08, 2007:

Here are my results so far:

I made an oemr.tar.gz archive file of the entire Debian installation tree.  Without any attempt to remove unnecessary packages beforehand, it compressed to 2.0 Gigs.  I took this home on a DVD to restore to a computer with different hardware.  At this point, the whole system appears to have been duplicated and reconfigured for the new hardware.  Only glitch is that mysqld didn’t start right because of some sort of error, but everything else works fine.  Data and configuration are from the office settings.  Fixed IP address is the one I assigned in the office.  I’m not sure why mysqld had an error – could have been time setting or maybe it somehow recognized that this was a different processor – will have to work on that.  Apache, php, everything else seem to work OK and file structures look good.

How I made the *.tar.gz file:

On the original machine, I booted up in Linux and used dd command to clone the "/" partition containing the entire filesystem to an equal sized partition.  Command was something like this:

dd if=/dev/hda1 of=/dev/hda3 bs=XXXXXXXXX count=XXXXX

I figured out what to use for the X’s by looking at block size and number of blocks in the partition from the fdisk utility.

Once that was done, I created a mount point and mounted this partition:

cd /

mkdir /mnt/oemr

mount /dev/hda3 /mnt/oemr

Then, in the "/" directory I typed

tar zxvf oemr.tar.gz /mnt/oemr/

Then I copied oemr.tar.gz to a DVD to take home.

Then at home I used fdisk to create a new Linux partition.  I then used mke2fs to format it.  Then I created a mount point for this partition thus, and I mounted it:

cd /

mkdir /mnt/oemr

mount /dev/hda3 /mnt/oemr  (replace hda3 with what is appropriate for the partition you chose.

Then I extracted the files from the "/" directory in the home computer:

cd /

tar zxvf oemr.tar.gz

This put all the files into the new partition.

At this point, I went to /boot/grub/menu.lst and created a new boot menu choice for the kernel that is in the new partition.  The kernel name and location will need to be specified, as will the "root" partition.  Also, I went into the /mnt/oemr/etc/fstab file to make sure that when it boots up, the "/" directory and any other directories will be mounted to the new partition.

At this point, I booted the computer and it recognized the hardware changes.  As mentioned above, my only problem was that mysqld showed an error on starting.  I haven’t figured that out yet, but the results so far show that this is definitely a method with potential.

Even if it only works with "most" computers, I think we have something valuable.