Restore of Backup

emrtech wrote on Thursday, February 18, 2010:

I’ve used the backup procedure in OpenEMR, under an Ubuntu dist…  I was wondering what the restore procedure is for the backup, if that ever becomes necessary or if one is installing onto another computer and transferring the data over.  I didn’t see that in the tutorial.  Thanks

sunsetsystems wrote on Thursday, February 18, 2010:

There is a restore script in the distribution at contrib/util/restore.  Do not assume your backups are worth anything until you have tested with a successful restore.

Rod
www.sunsetsystems.com

sunsetsystems wrote on Thursday, February 18, 2010:

P.S. - I have deleted your duplicate questions in the Developers forum, as they do not concern developer issues.

Rod
www.sunsetsystems.com

visolveemr wrote on Friday, February 19, 2010:

Hi,

If you are planning to restore the openemr setup in another Linux machine, there is a restore script already present in contrib/util/restore  (as Rod mentioned)

Here goes the detailed information in case if you need…

1. Copy the following files to the destination Linux machine where you want to perform the new setup
a. restore script (from the location contrib/util/restore)
b. The backup file - emr_backup.tar

2. Execute the “restore” script file in the destination Linux machine

3. Provide the following information during restoration. You can accept the default values in case if you like to use the same.

Path of the backup file
OpenEMR database name
OpenEMR database user
OpenEMR database password
OpenEMR web directory
MySQL root password

Then the script restores the database and the web application in the specified path.

4. Modify apache configuration file for the new openemr location and restart apache

5. Enjoy playing with the new system!!

Thanks
ViCarePlus Team

emrtech wrote on Sunday, February 21, 2010:

Thank you everyone - well said

mnordfors wrote on Thursday, June 09, 2011:

This is above my computer skill level. before I manage to use PHP myadmin to restore data.
Now I reinstalled my ubyúntu Linux distribution, reinstalled oemr, but did not manage to restore using phpmyadmin. I only got 80 tables back in the database instead of 118.
I use to delet all the tables, then import the stored database.
Please help me. I use OEMR 4,0 and Ubuntu latest version

mschap wrote on Tuesday, September 13, 2011:

This works for me up to a point.  When I get to a certain point in the script then I get this error:

Error: The phpGACL directory path ’  $phpgacl_location = dirname(__FILE__).’/…/gacl’;’ does not start with ‘/’.

I am using 10.04 LTS and openemr 4.0.1

Any help would be appreciated.

Michael

kodusote wrote on Tuesday, February 04, 2014:

I have problem restoring my database backup. I had done a backup of my openemr database and wanted to test restore in case of future problems.

So I dropped the openemr database, created a new one and imported the one I had backed up. On launching my openemer site, I get an error - “Check that mysqld is running”.

I am sure that the server is running using phpmyadmin and was able to run other applications using the same DBMS. I tried the process from the terminal and also with phpmyadmin with the same result.

Any guidance as to how to correct this or do it differently.

Kayode

openemrdev wrote on Tuesday, February 04, 2014:

Kayode

Please make sure you have entered the correct database/user name/pwd on openemr/sites/your_site/sqlconf.php

openemrdev@gmail.com

mschap wrote on Wednesday, February 05, 2014:

I wish this would work for me. Tmp folders seem to have changed somehow in Linuxmint in the last 6 months – can’t create backups which used to be no problem and now cannot restore on a new machine. More info below

https://sourceforge.net/p/openemr/discussion/202504/thread/ad473126/

xiaoanri wrote on Saturday, August 09, 2014:

last few days i have to do a restore from the backup file. after multiple tries, i was able to restore openemr from scratch. it was manual, but it did work.

i have to do a fresh install of ubuntu, i choose 14.04.1LTS. i installed LAMP server. after that, i moved the backup file to a working directory, and decompressed the file:

tar xvf oemr_backup.tar

from working directory, go to var/backup/oemr_backup/latest, you will find daily_openemr.sql.gz and daily_openemr.tar.gz.

make openemr directory under /var/www, and move the daily_openemr.tar.gz to /var/www/openemr. now decompress the file by: tar -vxzf daily_openemr.tar.gz, then delete the file. you will find the openemr directory is now restored.

now back to working directory and do: gunzip daily_openemr.sql.gz, you will see the new file daily_backup.sql.

log on to mysql by: mysql -uroot -p and put your password, and do: mysql> create database openemr;

then import the database by mysql -uroot -p openemr < openemr.sql

then the restore is working. go back and delete the tar, and gz files.

1 Like

fsgl wrote on Saturday, August 09, 2014:

Thanks for posting the Linux recovery steps. The Wiki article gives directions for manual backup but not specifically manual recovery. Restore can be deduced from the Windows article .

This webpage lists the folders which had been relocated with Ubuntu 14.04/Linux Mint 17. It appears that reshuffling of the folders is a recurrent problem with new Linux distributions. For all its warts, very grateful that Windows does not have this problem.

The Linux restore script asks for the path of emr_backup.tar.gz; as well as site id, location and mysql password; but not where to place the restored openemr web directory.

Presumably your web folder is now in var/www/html. The questions are whether the script “knows” where to restore the web directory and is the script failing to complete as a result.

Are there any fatal errors logged with the restore script attempts?

Backup & recovery are so important to any practice that it would be good to nail this one down. Hopefully a few tweaks of the script will bring about resolution as it did for the gzopen backup difficulty for 32 bit devices.

1 Like

xiaoanri wrote on Saturday, August 09, 2014:

hi. fsgl, thanks for the note. just logged into openemr, and so far it seems all files are found in place… will report if any issues down the road.

the restore script did not work for me, i got the same error as posted here: http://sourceforge.net/p/openemr/discussion/202504/thread/ad473126. also not sure where to look for the error log, where does the error log stay?

i did find the ubuntu 14.04 apache server is somehow different. when i first restored the openemr directory, it would not load, indicating the directory is not found. i know apache works since it served the html page fine. from reading the info, it seems there are additional procedure to “enable” websites? but i did not go into detail, i changed root directory from /var/www/html to /var/www/openemr, it worked. as such,however, i can only have this one site on the server, at the moment.

i also managed to get backups in a cron job, with the helpful info here:
http://www.open-emr.org/wiki/index.php/Backing_Up_Using_the_Built_In_Tools

and finally use the scp commend to copy the backup off the server to another location in the network. it seems working fine, actually the backup file i used this time is from this setup.

fsgl wrote on Saturday, August 09, 2014:

Good news is that I was able to restore emr_backup.tar using the restore script.

For future reference in Ubuntu/Linux Mint:
path to php error log: var/log/apache2/error.log
path to mysql error log: var/log/mysql/error.log

Would suggest the following:

  1. Install Brady’s package. (Thank, Brady.)
  2. If backup utility hangs, try this. (Thanks, Rod & Stephen.)
  3. Follow these recovery directions. (Thanks, Frankie.)

Some finer points:

  1. I was unable to run the restore script by double clicking it. Needed the command line.
  2. Put both the emr_backup.tar and restore script in the home directory & work from there.
  3. sudo ./restore
  4. When asked the path of the backup file, /home//emr_ backup.tar
  5. When asked site id, location, name of database, database user; use the defaults in the brackets & hit enter each time if the practice has only 1 site. If multiple sites; site id, etc. must be known.
  6. The mysql root password must be supplied for the script to complete.
1 Like

fsgl wrote on Sunday, August 10, 2014:

Hui,

What part of the backup utility & restore script was problematic?

It’s not clear if M.S. had difficulties with backup as well as restore.

A clarification, the restore script does ask where to put the web root directory, as illustrated below.
restore

xiaoanri wrote on Monday, August 11, 2014:

fsgl, i got similar error as the following from post by MS:

Extracting /home/alpinehealth/openemr/emr_backup.tar …
Extracting /tmp/emr_backup/openemr.tar.gz …
tar (child): …/openemr.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Error: tar could not extract ‘/tmp/emr_backup/openemr.tar.gz’.

I did put the backup file as well as the restore script (from /var/www/openemr/contrib/util) in the same directory before starting the process.

I thought the restore script might not be finding the correct path somehow. so that means it never gets to the step asking site ID, and other info.

for backup, i used the manual backup as shown here, http://www.open-emr.org/wiki/index.php/Backing_Up_Using_the_Built_In_Tools, that is working well.

fsgl wrote on Monday, August 11, 2014:

It appears that M.S. was unable to use the backup utility and had to resort to the manual method. Perhaps there were errors in the manual file. The path was not that complex, but the script was unable to “find” it. M.S. is not likely to rejoin this thread to provide more details, so let’s concentrate on you.

Questions:

  1. Any problems with the backup utility in Ubuntu 12.04/13.10?
  2. Have you tried the restore script with both the script and emr_backup.tar in the home folder? That path is fairly simple, lessening the chance for error.
  3. Did the restore script problem appear only after upgrade to Ubuntu 14.04? I assume that you’ve used the script many times in the past.
  4. Are you able to use the backup utility in Ubuntu 14.04 after the manual recovery?

There has been a bug involving gzopen in Ubuntu 14.04/Linux Mint 17 causing the backup to hang with 32 bit devices. Apparently it was replaced. The backup script uses the old version which is responsible for hanging. I see tar zxf in the script but no mention of gzopen anywhere.

It’s good you have a workaround, but the utility and script are more efficient and less time consuming, until the backup file gets too big; but that is a subject for another thread.

We just need to persevere to get to the bottom of this.

xiaoanri wrote on Monday, August 11, 2014:

fsgl, unfortunately, i do not have answers for most of the questions, i am not certain which backup utility you are referring? if it is this one by brady: http://www.bradymd.com/appliance/manual9/#__RefHeading__5628_695817034 , i am not using it since it backs into a DVD. Or it is the manual backup when you log in to openemr as admin from a workstation? i am not using that either since it is not automated. or is there another backup utility i am not aware of?

what i did is to put the manual commands in the servers cron tab, and have the backup running every night, then copy the file to a remote directory, which is different on each day of the week. this way i will have 7 days worth of off-site backup files anytime i need it. i did the restore manually but it may not be difficult to put it into a small script to run this automatically, but i will need to study more to do it. if there is interest on this from community, i can do some writeup later.

fsgl wrote on Monday, August 11, 2014:

I was referring to the second answer, left navigational sidebar ->Administration ->Backup. Not Brady’s backup in a V.M. No other built-in backup utility mentioned in the Wiki.

Did you have a problem with the built-in backup in Ubuntu 12.04/13.10?

How did you back up before using the cron job?

Did you get the restore script to work in the past?

Trying to get a sense of backup/recovery before the Ubuntu upgrade. If the built-in backup and the restore script both worked in the past, it would help with the diagnosis.

I would think that the backup script, found in var/www/openemr/interface/main/backup.php can be automated as well.

Good idea to have 7 days worth of backups. Recovery should be tested for accuracy periodically but it should not be necessary to restore every day of the week.

xiaoanri wrote on Tuesday, August 12, 2014:

i just tried the left navigation sidebar–> admin–>backup, it works ok, and generated the backup as usual. this is on ubuntu 14.04.1 x 64 server. i never recall there was any issue in the past with previous ubuntu editions, 12.04, etc. it does hang sometimes as i recall, but restart the process usually solves the problem. i imagine since this process involves transferring large amount of data across the network, there could be some network errors that might hang the process.

i am still using the older version 4.1.1(12).

i did manual backup from admin manual intermittently before i have the cron process installed.

i never did use the restore script in the past, the way i did the back up was the do a fresh install of openemr and import the mysql data only. i thought the backup will restore every detail of the openemr the exact way it was running, most importantly, are the scanned documents. in our case, we only started to more rely on the scanned/faxed documents since about 1 year ago, and never had to do a restore since then, and we always have paper chart still, till now…