Restore of Backup

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…

yehster wrote on Tuesday, August 12, 2014:

sites/default/documents

is the directory where scanned documents are stored.

If you backup those files, you can copy them into the same directory of your fresh install, and have them available on the new copy. You might need to alter permissions on those files too depending on your operating system, but assuming an OpenEMR installation without customizations, backing up the database, and copying the sites/default/documents directory all of the information needed for a restore is present.

fsgl wrote on Tuesday, August 12, 2014:

Great to hear that you have no problem with the built-in backup. Your 64 bit device saved you from the hassle of the gzopen bug some of us experienced with our 32 bit machines.

If I understand correctly, your backup method is described here but modified for daily instead of hourly mysqldumps.

I have attached a screenshot of the openemr/sites/default folder components. With a fresh install of OpenEMR there will be a brand new openemr web directory. The problem is that this web directory will be missing data not found in the database. Folder 1 will not have your scanned documents including copies of insurance cards. Folder 2 will not have Office Ally reports of accepted/rejected claims. Folder 3 won’t have the electronic remittance advice reports if your office downloads 835’s from Office Ally. Folder 4 won’t have the mysql user name and password if they had been changed. Not talking about the mysql root password which is another animal altogether. Folder 5 contains the code to generate the patient statements. Most practices have tweaked it a little bit. If you’ve never changed it, then it’s not a concern.

Chances are that Folders 1 and 2 are unique to your practice, thus you cannot just do a backup with only mysqldumps. You need to copy the openemr web directory from your office copy of OpenEMR as well.

The nice thing about the built-in backup is that it dumps your database and copies your openemr web directory fairly effortlessly. The task before you is to create a cron job for the built-in backup. In order to use the restore script, the backup utility has to be done first. It is equally easy to recover with it. This section in the Wiki provides very explicit instructions. Even your dog/cat can do it (tongue-in-cheek).

xiaoanri wrote on Wednesday, August 13, 2014:

fsgl, i totally agree my previous back up was not complete with sql data only, and am happy the restore script works for you, not sure why it was not working for me. Kevin also mentioned how to manually backup the documents if a fresh install is done.

the back up cron script was derived from the same link you just updated: http://www.open-emr.org/wiki/index.php/Backing_Up_Using_the_Built_In_Tools#Using_the_Terminal

the cron script is as the following:


0 1 * * * tar -C /var/www/openemr/ -zcf openemr.tar.gz ./
40 1 * * * mysqldump --opt --quote-names -umysqluser -pmysqlpassword openemr | gzip > openemr.sql.gz
20 2 * * * tar -cvf emr_backup.tar openemr.sql.gz openemr.tar.gz
10 3 * * 1 sshpass -p ‘password’ scp emr_backup.tar user@ip-adress:/…/monday
10 3 * * 2 sshpass -p ‘password’ scp emr_backup.tar user@ip-adress:/…/tuesday
10 3 * * 3 sshpass -p ‘password’ scp emr_backup.tar user@ip-adress:/…/wednesday
10 3 * * 4 sshpass -p ‘password’ scp emr_backup.tar user@ip-adress:/…/thursday
10 3 * * 5 sshpass -p ‘password’ scp emr_backup.tar user@ip-adress:/…/friday
10 3 * * 6 sshpass -p ‘password’ scp emr_backup.tar uuser@ip-adress:/…/saturday
10 3 * * 7 sshpass -p ‘password’ scp emr_backup.tar user@ip-adress:/…/sunday


this will generate the 2 backup files at 1am every day and tar the 2 files into one, and put it in a different remote directory on each day of the week, so you get the most recent 7 days of backup any time you want. i do not know how to update the wiki, feel free to post it there should it be of any help. of course, one will need to change the password, user, ip-address, etc accordingly.

i believe this could be written into one shell script and have the cron doing the script, but do not have time to study that yet, as it is, it works well for me. only thing is you would want to have enough time in between each task so that it would have finished the previous one when the next task is scheduled to start. i leave 40min, that is ample time for a small practice like us.

fsgl wrote on Wednesday, August 13, 2014:

It’s clear that the restore script will not work with openemr.sql.gz because it lacks the backup of the web directory and phpGACL, the other components of emr_backup.tar.

However it is not clear why it failed if the emr_backup.tar was successfully created in Ubuntu 14.04 and if both script and tar file were copied to the home directory for recovery.

Thanks for offering to add to the Wiki article. Info on how found here.

Please help.
MySQL database. Restoration of back up data causes application to stop responding (OpenEMR 7.0.2 running on Docker 4.32.0, MacOS 14.5).

This is probably due to the security key found in sites/documents/logs_and_misc/methods
There are two files there, sixa and sixb. Using sudo permissions rename them to sixa.bk0 and sixb.bk0. When you log back into OpenEMR it will generate new files called sixa and sixb.

Please let me know if this helps.