Read about OpenEMR's Response to the COVID-19 Pandemic at https://www.open-emr.org/covid19/

How to "recover" a database on aws to a new instance

I am attempting to restore a database backup to a new stack/instance. I created the stack and instance without undue difficulty.

Now I am reading/trying-to-figure-out how to recover/restore a database file from my laptop to the new stack/instance.

Here is what it says in the online wiki/manual:

"Recovery

  1. Restore script can be found in openemr/contrib/util as an executable file."

My first problem is … where is this “openemr” directory?
–RBL

hi @Ralf_Lukner, have you looked at openemr-devops/README.md at master · openemr/openemr-devops · GitHub ?

Yes, I have looked at that. Now I know how to see the huge restore script. Thank you.

Now … how do I get the restore script and the tar file into the same “context” where the script needs to be executed. Specifically, does the tar file need to be moved into the “docker” world or the script need to be moved into the non-docker world before execution?

I could manually copy the contents of the restore script into a new restore.sh file and place it into the non-docker world. I’m not sure how I would go the other way tar-> docker world

Thank you,
–RBL

I progressed a bit further. Now I know how to place the tar file and restore script into the /home directory inside the docker container. However, the restore script wants to execute under a bash shell, which apparently isn’t available. Attempting to execute the script under a ‘sh’ shell generates a huge number of errors and doesn’t seem to work either.

Get the docker container_id:

docker ps

Copy the tar file into the container:

ubuntu@ip-10-0-1-107:~$ sudo docker cp emr_backup_3.tar <container_id>:/emr_backup_3.tar

Access the docker container

sudo docker exec -it <container_id> sh

Then go to ~/ and move the tar file into /home

/var/www/localhost/htdocs/openemr # cd ~/
/ # mv emr_backup_3.tar home
/ # cd home

Copy the restore shell into /home

/home # cp /var/www/localhost/htdocs/openemr/contrib/util/restore .

Rename the restore script and make it executable

/home # mv restore restore.sh
/home # chmod u+x restore.sh

Note the database password in the sqlconf.php file

more /var/www/localhost/htdocs/openemr/sites/default/sqlconf.php

<?php // OpenEMR // MySQL Config $host = 'hosthosthosthost.us-east-1.rds.amazonaws.com'; $port = '3306'; $login = 'openemr'; $pass = '(((password)))'; $dbase = 'openemr'; At this point, I run into a roadblock. The bash shell doesn't seem to be available: ubuntu@ip-10-0-1-107:~$ sudo docker exec -it /bin/bash rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory" modifying the first line of the restore script from /bin/bash -> /bin/sh allows the script to execute, but it generates a huge number of errors .... I also tried correcting the name of the directory, but that did not work either. I guess the next step is to attempt to execute the relevant statements of the restore script manually one-by-one at the command line ... To be continued....

Is it possible to explain with more details for this part:
Then go to ~/ and move the tar file into /home

/var/www/localhost/htdocs/openemr # cd ~/
/ # mv emr_backup_3.tar home
/ # cd home

trying to execute this part but getting errors like this :

robert@robert-Vostro1310:~$ sudo docker cp emr_backup122019.tar.tar bda01b2da835:/emr_backup122019.tar
[sudo] password for robert:
lstat /home/robert/emr_backup122019.tar.tar: no such file or directory
robert@robert-Vostro1310:~$ sudo docker cp emr_backup122019.tar bda01b2da835:/emr_backup122019.tar
robert@robert-Vostro1310:~$ sudo docker exec -it bda01b2da835 sh
/var/www/localhost/htdocs/openemr # mv emr_backup122019.tar home/robert
mv: can’t rename ‘emr_backup122019.tar’: No such file or directory
/var/www/localhost/htdocs/openemr # mv emr_backup122019.tar home
mv: can’t rename ‘emr_backup122019.tar’: No such file or directory
/var/www/localhost/htdocs/openemr # mv emr_backup122019.tar robert
mv: can’t rename ‘emr_backup122019.tar’: No such file or directory
/var/www/localhost/htdocs/openemr # mv emr_backup122019.tar robert/home
mv: can’t rename ‘emr_backup122019.tar’: No such file or directory
/var/www/localhost/htdocs/openemr # mv emr_backup122019.tar
BusyBox v1.27.2 (2018-06-06 09:08:44 UTC) multi-call binary.

@robikny

The copied tar file will be in root path of the docker as per the below command,

sudo docker cp emr_backup122019.tar bda01b2da835: /emr_backup122019.tar

/var/www/localhost/htdocs/openemr # mv emr_backup122019.tar home
mv: can’t rename ‘emr_backup122019.tar’: No such file or directory

Navigate to root path as you are inside OpenEMR folder (/var/www/localhost/htdocs/openemr)

After entering docker, type the following command

cd ~/

After navigating to root you can move your tar file.
For additional clarifications please mail us to services@visolve.com

Thanks,
ViSolve-0123

This what I got after your advice -

robert@robert-Vostro1310:~$ sudo docker cp emr_backup122019.tar bda01b2da835:/emr_backup122019.tar`

[sudo] password for robert:

robert@robert-Vostro1310:~$ sudo docker exec -it bda01b2da835 sh

# /var/www/localhost/htdocs/openemr
# cd ~/
# mv emr_backup122019.tar home
# cd home
/home # cp /var/www/localhost/htdocs/openemr/contrib/util/restore

sh:
/home: Permission denied

some how can not complete this command because of unlock_admin.php - is there a solution?

looks like you’re missing the . (period) at the end which completes the cp command by placing it with the name or restore in your current directory
so should be

cp /var/www/localhost/htdocs/openemr/contrib/util/restore .