Backing up System

esears1 wrote on Monday, November 14, 2005:

Hi all,

I was wondering how ya’ll backup your system.  I am in the process of getting openemr ready for deployment.  We are moving from a windows based EMR application to openemr which runs on linux.  Previously I have a HP Tape drive and I use Veritas to backup the database and other files to tape.

Does anyone use a tape drive to backup?

sunsetsystems wrote on Monday, November 14, 2005:

There are two methods of backing up that I commonly use for my clients:

(1) Daily backups to CD.  You can create a script that dumps the database(s), runs mkisofs to create the CD image on disk, and then runs cdrecord to write it to CD.  The nice thing about this is that the write-once CDs are cheap, and over time you collect a nice stack of them that can serve as an audit trail in case you ever need to do some investigation.  You can similarly back up to DVDs if you have more data than will fit on a CD.

(2) Automated network backups.  Here a script is executed periodically, perhaps several times daily, automatically as a cron
job.  Ideally you have a backup server in a professional hosting facility, or even on a fast DSL line at someone’s home.  Using rsync, you can efficiently and easily back up database dumps as well as entire directory trees.  Rsync will automatically transmit only the files or portions of files that have changed.

Tape is also an option, but I think a pretty obsolete one now that disk and CD storage, as well as bandwidth, have become so cheap.

Send me a note if you’d like any assistance.

– Rod (http://www.sunsetsystems.com/)

esears1 wrote on Tuesday, November 15, 2005:

Hi Rod,

That sounds great.  Yeah I know tape systems are starting to be obsolete.  Can you give me a sample script of both options?

Edward

sunsetsystems wrote on Tuesday, November 15, 2005:

Sure, I’ll put some sample scripts on my web site sometime in the next couple of days.

– Rod
http://www.sunsetsystems.com/

jimbo456 wrote on Wednesday, November 16, 2005:

I think I will throw in my 2 cents here. Backup schemes are great but you need to consider server design also. ie my server has Raid 5. Partitioning is also part of the formula. I have a / partition, swapfile, /home and a /data partion. Programs go on the root ie apache, mysql ect. Home is the user-admin files and data is the openemr data files. In data I place my postgres and mysql data files. Along with my apache files and my freeb, plus logs. When I backup I can burn an image of the partition. Any program upgrades can be handled on the / patition.  This helps with any out of control logs or databases. At least the server can run while you take care of the logs.
This also allows me to unmount the data partition for what ever reason. Also my data is separate from my root patition making hacking a little harder. 

I haven’t spent a long time as a Linux admin and this is what I have come up with for server design.

Jim Proctor

esears1 wrote on Wednesday, November 16, 2005:

Thanks Rod…

sunsetsystems wrote on Friday, November 18, 2005:

See http://sunsetsystems.com/tips.php for a couple of sample backup scripts.

– Rod
http://www.sunsetsystems.com/

xiaoanri wrote on Tuesday, December 30, 2008:

Hi, Rod,

I finally learned a few basics about Linux and moved OEMR to Ubuntu 8.04, after suffering from the other OS for years… I found a backup script here: https://sourceforge.net/projects/automysqlbackup/, which works by backing up to an external drive via USB connection. 

I am hoping to back up to another server at a different location, or to a CD as you suggested.  I followed this thread and tried to look for your sample scripts at your website, but did not get that. Could you update me with a new link if they are moved?

Thanks a lot!

Hui

cfapress wrote on Monday, January 05, 2009:

Just a Linux partition tip…

When working with a Linux system you ought to create a separate partition for the /var directory. If /var fills up on your server and it’s not a separate partition you’ll have a locked up box. With /var living on its own partition it can merrily fill up and slow the system down but at least you can still SSH/Telnet into the machine and fix the problem.

Here’s a more authoritative look at partitioning
http://www.linuxdevcenter.com/pub/a/linux/2001/10/11/filesystem.html

Jason

drbowen wrote on Tuesday, January 06, 2009:

My own version of a partition scheme has served pretty well but depends on the size of the overall hard drive system:

/boot 100-500 megabytes
/         1-2 gigabytes
/swap 2 x system RAM
/tmp   1-2 gigabytes
/usr    40 gigabytes
/var    as much as possible
/home 20-40 gigabytes

For most systems the log files and the openemr database end up in the /var partition.  Trying to back up your data to the local hard drive is necessary for upgrades.  As your database needs grow what used to sound really huge keeps shrinking.  You don’t need much size in the / directory if you have separate /var, /usr and /home directories. 

The log files can stop the Apache web server if they get too big.  Plan on turning logging off for a production server or run logrotate to control the size of these log files. (or both)

You need to plan on backing up:

The openemr web page
The mysql database
and the openemr/documents directory (this is where all of the scanned images are normally kept).

The old saying goes, there are two types of computer administrators:

1) Those that don’t have hard drive failures
2) Those that make frequent back ups.

Here in my office I have had sudden catastrophic power outages (usually a car running into a telephone pole with a important power transformer),  lightning strikes, and Apache crashing because the log file got too big.  I’ve had my /var drive “shrink” until I could not perform local backups. 

I have backed up to usb drives.  They have an unfortunate habit of turning off to "save power" and then not waking up in time the backup to work correctly.

Believe me, you will need these backups and you will be very glad that you have them.

Sam Bowen, MD

voipbound wrote on Friday, January 09, 2009:

Great post.  Should I stop the services before we back up.  Then, how can we optimize the system so that it stay lean and mean.  I was thinking of having sql on a different disk, web on another disk and document on a different disk.  Is that feasible and doable?

cfapress wrote on Friday, January 09, 2009:

VOIPBound,

I’m not sure how big your OpenEMR installation will be but we have over 18,000 patients in our system, all imported from our billing software. Not very many encounters or appointments though. The server is running Debian Linux with all the typical stuff (Apache, PHP, MySQL, Exim, Mailscanner, Spamassasin, etc). This machine handles all of our web apps and all of our email. It does it without breathing hard. I doubt you’ll need to split services between machines. In fact, you might find a performance loss if you’re not working on a gigabit ethernet between the servers.

Now, you do want sufficient horsepower in your machine. For a basic OpenEMR system I’d suggest, at a minimum, PIII-700, 512mb RAM, 20GB HDD. Our server is newer and we’re running a quad-core Xeon E5410, 4gb RAM, and 148gb HDD RAID-1 with tape backup.

As for stopping the services before doing a backup… that’s not a bad idea. Especially if you know that you can shut down the MySQL database for as long as it takes to make a backup. But, you can also do a MySQL dump of a database without stopping the service and then back up the dumped data. Check out the mysqldump documentation here:
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

Jason