Restoring openemr

I am using to backup both www/mysql openemr ( backup.pgp/bckup.pgp), I created the encryption key and .gnupg is in both /root/ , /home/openemr directories

I was able to decrypt and untar backup.pgp and the directory is there .

was able to decrypt ( no need to untar mysql file) bckup.pgp , it overwrites outpufilename using the key phrase successfully.

When trying to restore database:
mysql -h localhost -p openemr < outputfilename
it asks for password.
in the new machine I am restoring to I tried in mysql the user password , root password, key password, always I get:
ERROR 1045 (28000): Access denied for user ‘mohammad’@‘localhost’ (using password: YES)
I’m using OpenEMR version
mohammad is user in mysql.

what I need to do to restore database?

I will rephrase my question to be more precise:
Using Brady’s script I understand I need manually to place the two files
is there any way someone links me to where to place them?
it is easy of the www file it will go under /var/www/html/openemr and the directories are restored…I did that.
where does the mysql ( from bckup.pgp) goes?
Any links
this method of backing up and restoring is very secure and free, also I do not have to rely on servers and clouds, I am old fashion paper oriented I like records to be under my watch and this is the closest setup to my nature.

Bumping the post……………………….!

OK ……

Something is not right with the script, the size of the mysql_openemr_bckup.pgp is only 256 K, no way it should be at least 10 MB, when manually I generated the dump file it was 18 MB. so here is one problem I need to solve.

I removed the web directory of the old OpenEMR on the target machine to restore it ( kept the database)
reinstalled openemr fresh install ( since database was kept I had to change sqlconf.php
$host = ‘localhost’;
$port = ‘3306’;
$login = ‘UserNameInMyDB’;
$pass = ‘PSWOfUserOfMyDB’;
$dbase = ‘openemr’;
$db_encoding = ‘utf8mb4’;
And I had to change 0 to 1 so I get to the login instead of setup.
ran the manual mysql dump file and successfully got all the records on the source machine to the target machine.

So troubleshooting the script why it was not getting the database?

Will work on it and update.

I am very happy to report the restore is successful with the script, it did output data , I was able to decrypt it and restore it, the glitch was with the path for the dump file.

credit to

And to

I was writing the wrong path for the .mylogin.cnf
I did keep it testbed1 in
mysql_config_editor set --login-path=testbed1 --host=localhost --user=root —password
while in the script it was
mysql_config_editor set --login-path=testbed --host=localhost --user=root —password
So I edited it back and it is running like a charm…. :slight_smile:

So now I have an automated backups to my DVD R at 1 AM every day and I can restore it with simple steps to the target machine if source goes bad …. cannot ask for better than that.

please help, after an update something broke and I cannot establish connection with mysql with the script for root@localhost.
For some reason I am still able to maintain the restoration of the www ( www_openemr_backup.pgp ) and it does restore the whole directory, however the mysql_openemr_bckup.pgp does not get any data from the openemr because the connection to mysql is broke, I get the screen shot:

I tried everything
I even dropped root@localhost and recreated it with privileges and flushed them to no avail

After the update I can link to my mysql using sudo mysql -u root -p after I put the mysql password when prompted but in no way shape or form I can connect with sudo mysql, even if I use sudo -I and I am in root I cannot connect using mysql it gives me error :

ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)

What to do ?
If I cannot restore data I have to repeat the whole process which is exhausting.
Any help is greatly appreciated.

To add to previous post

mysql_config_editor set --login-path=myopenemr --host=localhost --user=root —password

prompted me for the root password
entered it
over wrote the previous path

mysql --login-path=myopenemr

gets me into mysql

but why in the script it does not connect?

Credit to this link

the ticket was:

ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;

Now it is working

It is interesting how you fixed this problem and kept your post/forum updated.

I admire the resilience. Keep it up!

1 Like