Need to migrate OpenEMR data to new server

We have OpenEMR 4.1.0 on Ubuntu 14.04 LTS server and are trying to move the data to a new server with Ubuntu 16.04 LTS with OpenEMR 5.0.0 sucessfully installed. We have tried the backup and restore script method on the wiki without success. We created a backup using the tool on the 4.1.0 machine then transferred the emr_backup.tar and restore script to the 5.0.0 server and tried to run the restore script after moving the openemr folder without success.

I know the emr_backup.tar has the openemr folder site and sql database file. Is there a way to do it manually by replacing the openemr folder and updating the sql database with the files in the emr_backup.tar.

I can move the openemr folder but need help with the steps to replace the sql database file. Can someone explain the steps with phpmyadmin perhaps.

If this is not possible we are also okay with installing 4.1.0 on the Ubuntu 16.04 LTS server as well and running the restore script but the 4.1.0 deb package installer does not work on 16.04 LTS maybe because of php 7.0

hi @123dssj, try the upgrade process that will update the code and the database on the new machine

you should install the 4.1 database from a backup using mysqldump onto the new machine first

you’ll need the dependencies on the new machine before that :slight_smile:

and then copy over the files under documents to the new machine in step 3 (may want to use an external drive for this)

so to summarize

  • get new machine setup with dependencies
  • restore a mysqldump of 4.1 openemr db into the mysql on the new machine
  • put openemr 5.0.0 code under /var/www/html/ on the new machine
    • tar -pxvzf openemr-5.0.0.tar.gz
    • mv openemr-5.0.0 /var/www/html/openemr
  • copy over documents
  • run upgrade.php

Thank you stephenwaite, your procedure worked with the following modifications but essentially the concept is the same. I got it to work the following way if someone else needs to do the same:

  1. Install openemr 5.0.0 on the new server. Make sure you can login and ensure correct installation.

  2. Make a backup on the 4.1.0 machine with either the backup tool in OpenEMR or the procedure at
    The backup tool makes a compressed file emr_backup.tar that contains openemr.sql

  3. Transfer the openemr.sql to the 5.0.0 server and restore the database using the steps in 2

  4. Follow the upgrade process in
    to move all the correct folders from the 4.1.0 server to the 5.0.0 server.

  5. Run the sql.upgrade.php script and select the correct version you are upgrading from.

  6. You should now be able to login on the 5.0.0 server with all the data transferred

1 Like

I moved OpenEMR to a new host/server. I have trouble with ‘attached’ images in the Documents for the patient records → they are still linked to the old server directories. Hence, they cannot be displayed.

The suggested migration here did not update this part, any suggestions how to resolve this?


If you can access the server via ssh, you need to change file permissions.
For debian,ubuntu, etc… the command is: chown -R www-data:www-data ./openemr
For Centos, RHEL, etc… the command is: chown -R apache:apache ./openemr
If that doesn’t work, try executing the statement as mysql administrator ((change paths):
update documents set thumb_url = replace(url, ‘file://var/www/html/openemr/sites/default/documents/’, ‘file://new/path/openemr/sites/default/documents/’)

1 Like

Thanks, @luisuriarte, your suggestions work. The server used is Debian.

Not yet tested on large database.

  1. Before uploading the backed up database, I replace the url using Geany editor.
  2. I also change the ownership of the openemr directory as shown in the previous reply.