# New backup and restore scripts

**URL:** <https://community.open-emr.org/t/new-backup-and-restore-scripts/5549>\
**Category:** OpenEMR Development\
**Created:** [September 19, 2008, 5:23pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549 "2008-09-19T17:23:48Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [September 19, 2008, 5:23pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/1 "2008-09-19T17:23:48Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Friday, September 19, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42):

I have checked in a couple of new scripts to support backup and restore of an OpenEMR installation.&nbsp; These are currently experimental, so caution is in order, especially for the restore.&nbsp; New files are:

interface/main/backup.php  
contrib/util/restore

Changed files are:

interface/main/left\_nav.php  
interface/usergroup/usergroup\_navigation.php

The backup is a web script, assessible via the Administration menu of OpenEMR.&nbsp; It requires "superuser" permissions.&nbsp; It creates and sends a backup file for download by the web browser.&nbsp; The resulting file can be easily saved to a USB memory stick or other removable medium.

The restore is a bash shell script.&nbsp; It must be executed with root permissions, and takes the full path to the backup file as an argument.

These scripts will not work with WIndows (of course any efforts towards adding support for Windows would be greatly appreciated).&nbsp; I have been testing them with Ubuntu and Debian Linux.

Your testing feedback is welcomed!

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [September 20, 2008, 12:05am UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/2 "2008-09-20T00:05:53Z")

</div>

**[bradymiller](https://sourceforge.net/u/bradymiller/)** wrote on [Saturday, September 20, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/481d):

hey,  
This is huge. Haven’t tried it yet; plan to try it tomorrow after the CVS demo gets updated. From initial look at code, probably be useful to give the user option of manually entering the sql-ledger directory. I’ve been toying with the idea of moving a future openemr appliance version to ubuntu(it’s so much better supported than mandriva), but couldn’t figure out a way for old appliance users to upgrade; I think this script willl be part of the answer.  
-Brady

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [September 20, 2008, 12:20am UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/3 "2008-09-20T00:20:57Z")

</div>

**[bradymiller](https://sourceforge.net/u/bradymiller/)** wrote on [Saturday, September 20, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/7018):

hey,  
Your restore script is even huger. If we released a backup of a complete new installation, couldn’t this be another mechanism to quickly install openEMR/sql-ledger/phpgacl on ubuntu/debian (you’ve even got flexibility on installation directories, database names/pass, and will crush the annoying database persistance bug)  
very cool,  
brady

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [September 20, 2008, 12:43am UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/4 "2008-09-20T00:43:18Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Saturday, September 20, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/0f85):

Yep, it sure could.&nbsp; 🙂

Of course you have to make sure the dependent packages are all installed.

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [December 19, 2008, 1:46pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/5 "2008-12-19T13:46:57Z")

</div>

**[rayaz](https://sourceforge.net/u/rayaz/)** wrote on [Friday, December 19, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/b2b7):

Hi there,

Downloaded the script and used it to backup my openmr. Have not restored yet. Now I have a problem, I cannot work on a patient anymore. I can create new patients but cannot go to history, encounter or anything else. All the choices are grayed out. When I hover over the history button it points to left\_nav.php.

I replaced the new left\_nav.php file with the old one and I can get it to work. But the backup button goes missing!

Is it broken?

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [December 19, 2008, 2:50pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/6 "2008-12-19T14:50:26Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Friday, December 19, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/b2b7/80ea):

left\_nav.php is release-dependent.&nbsp; In general it doesn’t work to replace individual modules from other releases.

You could try modifying your current left\_nav.php to include the link to the backup script.

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [December 19, 2008, 4:36pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/7 "2008-12-19T16:36:24Z")

</div>

**[rayaz](https://sourceforge.net/u/rayaz/)** wrote on [Friday, December 19, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/185f):

Hi

Sorry didn’t specify, I am using openemr 2.9.0. I really am not very familiar with programming so could you please tell what modifications I need to do? I did a diff&nbsp; of the two files but the result was greek to me!

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [December 19, 2008, 4:48pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/8 "2008-12-19T16:48:02Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Friday, December 19, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/055a):

Well you did post in the Developers forum.&nbsp; 🙂

What you might do is look in the new left\_nav.php for lines referencing backup.php.&nbsp; There’s only a couple of them.&nbsp; Insert those same lines into the same places in your current left\_nav.php.

I can’t tell you for sure that will work, because I’ve not tested it with 2.9.0.&nbsp; But I think it will.

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [December 19, 2008, 5:00pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/9 "2008-12-19T17:00:27Z")

</div>

**[rayaz](https://sourceforge.net/u/rayaz/)** wrote on [Friday, December 19, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/185f/ed09):

Hi

Got it to work! Did what you suggested and it worked! Thank you very much! Maybe I could really learn this programming stuff after all!

Regards and thanks again.

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [December 19, 2008, 5:28pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/10 "2008-12-19T17:28:44Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Friday, December 19, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/185f/ed09/0892):

Alright, a new developer!&nbsp; 😃

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [December 20, 2008, 4:15pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/11 "2008-12-20T16:15:57Z")

</div>

**[rayaz](https://sourceforge.net/u/rayaz/)** wrote on [Saturday, December 20, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/d7b2):

Feedback time! Did a restore on&nbsp; a system that only had apache installed on it, Ubuntu 8.04. The restore went fine with phpgacl restoration as well. But sql-ledger didn’t install. I had to apt-get it from the repositories. Comments?

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [December 20, 2008, 6:30pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/12 "2008-12-20T18:30:57Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Saturday, December 20, 2008](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/d7b2/bed9):

I should have mentioned, the sql-ledger directory backup only works when SL is installed in a directory named “sql-ledger” that is a sibling of the OpenEMR directory.&nbsp; This is because the backup script doesn’t have any good way of knowing where it is in the filesystem.

I’m not going to worry about it because we’re getting rid of SL anyway.

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [February 22, 2009, 1:48am UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/13 "2009-02-22T01:48:22Z")

</div>

**[anojgoel](https://sourceforge.net/u/anojgoel/)** wrote on [Sunday, February 22, 2009](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/7a71):

i was trying to find this about backup and restoring in XP. any progress?

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [February 27, 2009, 6:42am UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/14 "2009-02-27T06:42:16Z")

</div>

**[bradymiller](https://sourceforge.net/u/bradymiller/)** wrote on [Friday, February 27, 2009](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/0803):

anoj,

&nbsp; Jason just discussed this here:  
[https://sourceforge.net/forum/forum.php?thread\_id=3043177&forum\_id=202505](https://sourceforge.net/forum/forum.php?thread_id=3043177&forum_id=202505)

-brady

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [March 20, 2009, 3:08pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/15 "2009-03-20T15:08:04Z")

</div>

**[rabbai](https://sourceforge.net/u/rabbai/)** wrote on [Friday, March 20, 2009](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/97bf):

I tested the backup script and it worked like a charm but I was thinking of making the job alot easier for users. Maybe addition of a cron script that when backup is run manually, it also runs another cron script which simply takes that file saved somewhere on the server and burns it into a DVD-RW which is placed in the server just for safety sake. Any thoughts??? A basic script would cater for this, I could do it if thats ok

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [March 20, 2009, 3:30pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/16 "2009-03-20T15:30:16Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Friday, March 20, 2009](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/97bf/3890):

Automated backup is a whole 'nother topic.&nbsp; Don’t underestimate the complexity of doing it right.&nbsp; One problem is that the documents directory can become huge, and eventually it may not be practical to back up to DVD or to copy the whole thing over a slow network (like the Internet) on every backup run.&nbsp; Backups via the Internet are desirable because some types of disasters such as fire or burglary can wipe out an entire location.

One solution I am using is rdiff-backup, which can copy just the things that have changed, and in addition can preserve previous versions so that it is possible to restore as of some specified prior date.

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [March 20, 2009, 4:24pm UTC](https://community.open-emr.org/t/new-backup-and-restore-scripts/5549/17 "2009-03-20T16:24:03Z")

</div>

**[rabbai](https://sourceforge.net/u/rabbai/)** wrote on [Friday, March 20, 2009](https://sourceforge.net/p/openemr/discussion/202506/thread/4845cc5c/#1d42/1067):

Yeah I understand but it could be setup for redundancy sake that u have a DVD rewritable back up and also an internet backup, the disc is reused each day and the backup is updated and it is replaced every month or week. I have considered things like time vault or flyback that simply focuses on specific locations on the system and saves changes to the file to a given location. I hope this can be implemented and even ingraphical form where it simply asks u for ur desired save location and runs it for you. Flyback is good for this u can check it out
