Difference between revisions of "OpenEMR Backup Tools"

From OpenEMR Project Wiki
 
 
(27 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Overview ==
== Overview ==
 
Words of advice on backing up:
I am going to get on a little small soapbox for all the newbies using OpenEMR.
* The first most basic requirement of any database is a regular, frequent, comprehensive backup system.
* Losing data should terrify you.
Electronic Medical Records are your livelihood and exist to protect the health of your patients. If you are going to be your own IT manager you have to approach this professionally. The first most basic requirement of any database is a regular, frequent, comprehensive backup system.
* Hardware fails. Lightning strikes happen.
* A good backup strategy is drudgery but nothing will give such a warm, glowing, fuzzy, feeling like successfully recovering your system from a recent backup after a lightning strike that burns out a critical component on your server.
My system does real time back-ups to a second server. I also run a MySQL dump every 24 hours. I do this myself and I don't trust it to anyone else.
* Backup your databases on a regular basis (daily is best).  Make frequent secure backups of the MySQL data and the data in the openemr web directory.
* If you have the resources it is best to back up to an off site facility.  This can be done electronically over a secure internet connection (VPN) or you can burn CDs / DVDs and carry them off site.
Losing my data terrifies me and it should terrify you.
* Always backup before starting an upgrade.
 
I have not this happen to me, but some of our local practices have had break-ins where all the computers were stolen.  If they carry off your server you'll be in a big mess.
Hardware fails. Lightning strikes happen. I have had both occur since I started running OpenEMR. A good backup strategy is drudgery but nothing will give such a warm, glowing, fuzzy, feeling like successfully recovering your system from a recent backup after a lightning strike that burns out a critical component on your server.
Please backup your databases on a regular basis (daily is best).  Make frequent secure backups of the MySQL data and the data in the openemr / documents directory.  These are the irreplaceable parts.
 
I back up my data on a daily basis.  If you have the resources it is best to back up to an off site facility.  This can be done electronically over a secure internet connection (VPN) or you can burn CDs / DVDs and carry them off site.
 
Always backup before starting an upgrade.
 
 
Sam Bowen, MD
 


== Linux ==
== Linux ==
* [http://www.bradymd.com/appliance/manual3/#6.0.0.0.0.5.Automatic%20Backup%20Setup|outline Mandriva Backup] : This method/script will backup the complete MySQL database, the complete PostGreSQL database, the OpenEMR patient scanned documents file directories, the OpenEMR directory containing patient billing files, and the FreeB directory containing patient billing files. It will automatically backup to a secure local directory and burn the encrypted data to a multisession DVD(so, you can just leave the same DVD in the drive).
* [http://www.bradymd.com/appliance/manual9/#__RefHeading__5628_695817034 Ubuntu Backup] : This method/script will backup the complete MySQL database and the complete OpenEMR web directory. It will automatically backup encrypted data to a local directory and burn the encrypted data to a multisession DVD(so, you can just leave the same DVD in the drive). Here is a link to the raw script, if wanted: [[Media:Fullbackup4_sh.zip|fullbackup4_sh.zip]]
* [http://www.bradymd.com/appliance/manual5/#6.0.0.0.0.5.Backup%20(Automatic)%20Setup|outline Ubuntu Backup] : This method/script will backup the complete MySQL database and the complete OpenEMR web directory. It will automatically backup to a secure local directory and burn the encrypted data to a multisession DVD(so, you can just leave the same DVD in the drive).
* [[Backing Up Using the Built In Tools]] : OpenEMR has a built in 'backup' facility. this page describes how to use it, and how to manually perform the same task.
 
* [http://www.openhealthit.info/2010/06/openemr-dump-database/ Dump Database - Hourly ] : This procedure creates a database dump every hour and cleans out old backups once a day.
 
* [[Automated Backups to an Alternate Server]] : Rod's preferred method (documentation sponsored by IPPF).


== Windows ==
== Windows ==
[[Windows OpenEMR Backup and Recovery| Windows Backup/Recovery]] a Downloadable HowTo using Windows Batch Routine Files (text copy below) written by [http://www.holzerent.com Joe Holzer].
*[[Windows OpenEMR Backup and Recovery| Windows Backup/Recovery]] a Downloadable HowTo using Windows Batch Routine Files (PDF Copy Enclosed) written by [http://www.holzerent.com Joe Holzer].
*[[Windows OpenEMR Restore using emr_backup.tar|Windows Restore from OpenEMR native backup file]] - Restore from your previously backed-up file (emr_backup.tar)
*[[Windows OpenEMR Backup and Recovery over Amazon Web Services]] A way to automate the encrypted backup of my windows server to Amazon web services (S3 cloud).
*[[Windows Backup And Restore Made Easy]]  A third way to backup.


=====Backup & Recovery In Windows Using Batch Routine Files Including Automation=====
== OS-X ==
 
:*[http://www.openmedsoftware.org/wiki/File:Windows_Backup_in_OpenEMR.pdf][PDF] Backup & Recovery in Windows - a Downloadable HowTo using Windows Batch Routine Files (text copy below) written by [http://www.holzerent.com Joe Holzer].


              '''Backup & Recovery In Windows – Protecting Your Data'''
[[Category:Backup]][[Category:Configuration Guide]]
 
The internal Backup in OpenEMR (Admin – Backup) has problems in Windows, so avoid using it.  This is intended as a preferred method of providing backup for your OpenEMR data.  You can expand it and simplify it to backup your complete Windows install, albeit at the cost of time and added disk space.
 
The fundamental issue is to make copy(s) of your real data which could be used to restore if your disk drive crashes.  So, although there can be advantages to having a backup copy on the same physical drive, it is more important to have them on multiple different physical servers and at different physical locations for protection from fire, flood, etc., so long as they can be secure at those locations.  For example, you might backup to a LAN mapped drive location called X:\oemr-backup\mon\  which will contain subfolders openemr, documents, edi, era and letter_templates which were saved on Monday morning.  Similar storage protocol could allow saving up to seven days worth as you will see below.
 
So let us examine the restore process first.  You would install a new Xampp and OpenEMR on another machine, and successfully login to that setup.  If you were previously using the “Services” type configuration for Apache and MySQL, you should do that again, otherwise, you must turn off the Apache and MySQL manually to do the restore, then start them back up again once you were finished and ready to start using OpenEMR again.  You will replace the various folders in the new install with those you had saved with a prior backup.  The batch file which would do that in a normal Windows install from a backup storage location X:/oemr-backup/mon/ for example looks like: (Replace “mon” with whichever day you need):
 
 
del c:\xampp\mysql\data\openemr /y
 
del c:\xampp\htdocs\openemr\documents /y
 
del c:\xampp\htdocs\openemr\edi /y
 
del c:\xampp\htdocs\openemr\era /y
 
del c:\xampp\htdocs\openemr\custom\letter_templates /y
 
copy x:\oemr-backup\mon\openemr c:\xampp\mysql\data\
 
copy x:\oemr_backup\mon\documents c:\xampp\htdocs\openemr\
 
copy x:\oemr_backup\mon\edi c:\xampp\htdocs\openemr\
 
copy x:\oemr_backup\mon\era c:\xampp\htdocs\openemr\
 
copy x:\oemr_backup\mon\custom\letter_templates c:\xampp\htdocs\openemr\custom\
 
 
At that point all your prior logins and data should be operable.
 
After verifying any restore or new install, always save a copy of c:\xampp\htdocs\openemr\library\sqlconf.php to someplace safe.  It contains your database login and password data which is essential, and not found elsewhere.
 
Backing up databases has some issues to consider.  These methods are not strictly adhering to MySQL protocol.  But as long as ALL your databases backup between writes to ANY databases, all will be properly operable as a group.  That means you must prevent access to the databases during the backups.  For a small clinic which does not operate 24/7, that is simple – schedule the backup for when they are not working.  But for a hospital, that may not be sufficient.  In that case, you must temporarily shutdown the databases, make the backup, then re-start the database.  In that case, You are STRONGLY advised to use ONLY the “services” configuration for Apache and MySQL, ie they will be services which automatically start with Windows, and can be accessed via the Windows Ctrl-Panel – Admin – Services, where they can be started and stopped, rather than the manual Xampp control.  The services can be stopped and started then by the batch program to assure safe backups with minimal interference with normal operations. 
We use Xcopy because it only copies files changed since the last backup to that location, saving bandwidth and time.  And you can make a separate backup batch program for each day, and schedule them using the Windows scheduler, by changing the “mon” below to “tue”, etc. Batch program backup without need for the services shutdown (you can leave the manual Xampp controlled Apache and MySQL running so long as nobody can write to the databases during the backup) looks like (check.bat is a blank batch file in the root directory to prevent network delays):
 
 
cmd /c cd x:\              rem  This line connects the X drive if it is available.
 
if exist x:\check.bat xcopy c:\xampp\mysql\data\openemr\*.* x:\oemr-backup\mon\openemr\ /d /e /c /i /f /h /k /y
 
if exist x:\check.bat xcopy c:\xampp\htdocs\openemr\documents\*.* x:\oemr-backup\mon\documents\ /d /e /c /i /f /h /k /y
 
if exist x:\check.bat xcopy c:\xampp\htdocs\openemr\edi\*.* x:\oemr-backup\mon\edi\ /d /e /c /i /f /h /k /y
 
if exist x:\check.bat xcopy c:\xampp\htdocs\openemr\era\*.* x:\oemr-backup\mon\era\ /d /e /c /i /f /h /k /y
 
if exist x:\check.bat xcopy c:\xampp\htdocs\openemr\custom\letter_templates\*.* x:\oemr-backup\mon\letter_templates\ /d /e /c /i /f /h /k /y
 
 
If you use the OpenEMR continuously, you would need to stop the MySQL service, which would prevent writes while you backed up, then re-start it which would allow normal operation, once the backup had occurred.  You should generally backup to at least two different locations, ideally separated physically as well.  An offsite storage location is advised also, as is at least daily backups.  To stop the MySQL service, place the following before the first line in the batch program above:
 
 
net stop “mysql”  rem  Note the quote marks and the order shown
 
net stop “apache2.2”  rem  Note the version number may be different for you, but use the full name
 
 
and to restart, place the following after the last line in the batch program above:
 
 
net start “apache2.2”
 
net start “mysql”
 
 
That should be a robust backup and restore system for Windows users.
 
 
If you have the manual Xampp for Apache and MySQL and you want to instead use the services, you can run the following (go to each and double-click on the file in the order shown, then follow prompts).  It need only be run a single time unless you run the uninstall batch files found at the same locations:
 
 
c:\xampp\apache\apache_installservice.bat
 
c:\xampp\mysql\mysql_installservice.bat
 
 
Note that you could simplify by xcopying everything in c:\xampp to a backup folder, with the trailing configuration letters (arguments) as shown, and then copy it all back over a new install to restore AFTER you first made a copy of the sqlconf.php file as noted above from the new install, as you might need to restore that separately once all the other copying has been done.
]
 
== OS-X ==

Latest revision as of 22:00, 21 May 2016

Overview

Words of advice on backing up:

  • The first most basic requirement of any database is a regular, frequent, comprehensive backup system.
  • Losing data should terrify you.
  • Hardware fails. Lightning strikes happen.
  • A good backup strategy is drudgery but nothing will give such a warm, glowing, fuzzy, feeling like successfully recovering your system from a recent backup after a lightning strike that burns out a critical component on your server.
  • Backup your databases on a regular basis (daily is best). Make frequent secure backups of the MySQL data and the data in the openemr web directory.
  • If you have the resources it is best to back up to an off site facility. This can be done electronically over a secure internet connection (VPN) or you can burn CDs / DVDs and carry them off site.
  • Always backup before starting an upgrade.

Linux

  • Ubuntu Backup : This method/script will backup the complete MySQL database and the complete OpenEMR web directory. It will automatically backup encrypted data to a local directory and burn the encrypted data to a multisession DVD(so, you can just leave the same DVD in the drive). Here is a link to the raw script, if wanted: fullbackup4_sh.zip
  • Backing Up Using the Built In Tools : OpenEMR has a built in 'backup' facility. this page describes how to use it, and how to manually perform the same task.
  • Dump Database - Hourly  : This procedure creates a database dump every hour and cleans out old backups once a day.
  • Automated Backups to an Alternate Server : Rod's preferred method (documentation sponsored by IPPF).

Windows

OS-X