Menu

Backup Error

M S
2013-12-07
2014-01-16
  • M S

    M S - 2013-12-07

    "/usr/bin/mysqldump -u 'openemr' -p'1wC3FofWpevv' --opt --quote-names -r /tmp/openemr_web_backup/emr_backup/openemr.sql 'openemr'" returned 3:

    This is the error I am now getting with my attempt at a backup through the admin tools - I am using openEMR version 4.1.0 on a Linuxmint13 machine.

    Any help would be appreciated. In advance, thanks

    Michael

     
  • MD Support

    MD Support - 2013-12-07

    OpenEMR just submits a OS command. This seems like inconsistent MySQL database. To troubleshoot run the same command from console with -v switch to see verbose output.

     
  • Lams

    Lams - 2013-12-09

    Michael,
    what are the permission settings for your /tmp directory
    If you could paste the output of:

    sudo ls -als /tmp

     
  • M S

    M S - 2013-12-09

    Here it is Lams

    total 2072
    28 drwxrwxrwt 16 root root 28672 Dec 9 12:26 .
    4 drwxr-xr-x 25 root root 4096 Oct 17 2012 ..
    84 -rw------- 1 alpinehealth alpinehealth 83119 Dec 9 11:06 0C_GJJpF.pdf.part
    80 -rw------- 1 alpinehealth alpinehealth 80317 Dec 6 13:58 2MELO+9v.pdf.part
    0 lrwxrwxrwx 1 alpinehealth alpinehealth 34 Nov 20 16:30 528d461c59e7a -> /etc/cups/ppd/HP_LaserJet_1022.ppd
    0 lrwxrwxrwx 1 alpinehealth alpinehealth 34 Nov 20 20:07 528d78d8a4229 -> /etc/cups/ppd/HP-LaserJet-1022.ppd
    0 lrwxrwxrwx 1 alpinehealth alpinehealth 34 Dec 6 09:58 52a2021c87ae2 -> /etc/cups/ppd/HP_LaserJet_1022.ppd
    0 lrwxrwxrwx 1 alpinehealth alpinehealth 34 Dec 6 09:58 52a2021c87c73 -> /etc/cups/ppd/HP_LaserJet_1022.ppd
    0 lrwxrwxrwx 1 alpinehealth alpinehealth 34 Dec 6 09:58 52a2021c87d25 -> /etc/cups/ppd/HP_LaserJet_1022.ppd
    0 lrwxrwxrwx 1 alpinehealth alpinehealth 34 Dec 6 10:23 52a207f8b83f3 -> /etc/cups/ppd/HP-LaserJet-1022.ppd
    8 -rw------- 1 alpinehealth alpinehealth 7670 Dec 9 10:54 5n3CwcDu.pdf.part
    80 -rw------- 1 alpinehealth alpinehealth 81292 Dec 6 16:39 72L_eJGz.pdf.part
    84 -rw------- 1 alpinehealth alpinehealth 82319 Dec 5 15:09 bpmUxY9g.pdf.part
    84 -rw------- 1 alpinehealth alpinehealth 83532 Dec 5 13:03 DUXqkCXZ.pdf.part
    72 -rw------- 1 alpinehealth alpinehealth 72924 Dec 5 18:32 E7ZQokV+.pdf.part
    72 -rw------- 1 alpinehealth alpinehealth 71963 Dec 5 13:23 euVjeB2k.pdf.part
    52 -rw------- 1 alpinehealth alpinehealth 53153 Dec 6 14:07 F+UQNXiA.pdf.part
    76 -rw------- 1 alpinehealth alpinehealth 75865 Dec 9 11:05 hD9xJv48.pdf.part
    4 drwxr-xr-x 2 root root 4096 Dec 6 17:57 hsperfdata_root
    72 -rw------- 1 alpinehealth alpinehealth 72513 Dec 9 11:05 IBr9XDL6.pdf.part
    4 drwxrwxrwt 2 root root 4096 Nov 20 16:25 .ICE-unix
    80 -rw------- 1 alpinehealth alpinehealth 81009 Dec 5 15:10 jZm5i1FR.pdf.part
    4 drwx------ 2 alpinehealth alpinehealth 4096 Nov 20 16:25 keyring-UxXcMe
    72 -rw------- 1 alpinehealth alpinehealth 70119 Dec 5 13:03 LDLHjF6G.pdf.part
    4 drwx------ 2 alpinehealth alpinehealth 4096 Dec 6 17:49 libgksu-7W6Mzw
    84 -rw------- 1 alpinehealth alpinehealth 82319 Dec 5 15:10 L+xa2qiJ.pdf.part
    4 drwx------ 2 alpinehealth alpinehealth 4096 Dec 9 12:33 matecorba-alpinehealth
    4 drwxrwxrwx 2 alpinehealth alpinehealth 4096 Dec 6 17:49 mintUpdate
    72 -rw------- 1 alpinehealth alpinehealth 72977 Dec 5 15:05 nddFw1qu.pdf.part
    4 drwxr-xr-x 3 www-data www-data 4096 Dec 6 17:18 openemr_web_backup
    4 drwx------ 2 alpinehealth alpinehealth 4096 Dec 31 1969 orbit-alpinehealth
    8 -r-------- 1 alpinehealth alpinehealth 7670 Dec 9 08:50 Parking Justification Form.pdf
    84 -rw------- 1 alpinehealth alpinehealth 83929 Dec 6 14:07 Pin7ylAQ.pdf.part
    4 drwx------ 2 alpinehealth alpinehealth 4096 Dec 6 15:02 plugtmp
    4 drwx------ 2 alpinehealth alpinehealth 4096 Nov 20 16:25 pulse-BynLAN5z4Ypu
    4 drwx------ 2 root root 4096 Nov 20 16:25 pulse-PKdhtXMmr18n
    68 -rw------- 1 alpinehealth alpinehealth 65814 Dec 6 16:39 q4bOzZ08.pdf.part
    84 -rw------- 1 alpinehealth alpinehealth 82287 Dec 5 18:30 QVDD1OZW.pdf.part
    84 -rw------- 1 alpinehealth alpinehealth 82676 Dec 5 18:32 Q_X3sZ2V.pdf.part
    84 -rw------- 1 alpinehealth alpinehealth 83959 Dec 5 15:17 sc1IcccS.pdf.part
    4 drwx------ 2 alpinehealth alpinehealth 4096 Nov 20 16:25 ssh-arMxjnSB2380
    84 -rw------- 1 alpinehealth alpinehealth 82183 Dec 5 13:22 UTzxe4EV.pdf.part
    4 drwx------ 2 alpinehealth alpinehealth 4096 Dec 9 08:33 .vbox-alpinehealth-ipc
    160 -r-------- 1 alpinehealth alpinehealth 162928 Dec 9 10:50 voice-message.wav
    4 -r--r--r-- 1 root root 11 Nov 20 16:25 .X0-lock
    4 drwxrwxrwt 2 root root 4096 Nov 20 16:25 .X11-unix
    84 -rw------- 1 alpinehealth alpinehealth 82607 Dec 6 13:59 y08e8p_q.pdf.part
    84 -rw------- 1 alpinehealth alpinehealth 82140 Dec 9 11:05 yjt+c+CQ.pdf.part
    84 -rw------- 1 alpinehealth alpinehealth 82180 Dec 5 15:05 ZUSfVcpR.pdf.part

     
  • M S

    M S - 2013-12-09

    I installed the patch above and there is no change to the error message

     
  • Stephen Waite

    Stephen Waite - 2013-12-09

    look at the sub-directory you're using:

    4 drwxr-xr-x 3 www-data www-data 4096 Dec 6 17:18 openemr_web_backup

    looks like only www-data can write to it, so maybe that's where mysqldump is having problem?

     
  • Lams

    Lams - 2013-12-09

    Michael,
    the problem you have is the permission settings for the /tmp directory and the sub-directory /tmp/openemr_web_backup

    I would recommend you enable the 'sticky bit' and a wide rw permission setting for /tmp

    Try the following:
    sudo chmod -R 1777 /tmp

    Furthermore, as proof, if you check your mysql error log, you will find that there is a permission denied log.

     

    Last edit: Lams 2013-12-10
  • M S

    M S - 2013-12-12

    Hello Lams

    I have changed the permissions but everytime I use the backup in Openemr the permissions get changed again by the script and I get the same error again.

    Michael

     
  • Lams

    Lams - 2013-12-13

    See if it works if you point it to your home directory rather than the /tmp; from a command prompt, enter

    /usr/bin/mysqldump -u 'openemr' -p'1wC3FofWpevv' --opt --quote-names -r ~/openemr.sql 'openemr'

    I assume you retrieved the database password from this file: /sites/yoursite/sqlconfig.php

     

    Last edit: Lams 2013-12-14
  • M S

    M S - 2013-12-14

    This suggestion worked for creating the openemr.sql file. What would be a script to create an entire backup as a tar file?

     
    • Lams

      Lams - 2013-12-15

      Michael,
      try this - save this script as whatever you like e.g. my_emr_backup.sh

      #!/bin/bash

      /usr/bin/mysqldump -u 'openemr' -p'1wC3FofWpevv' --opt --quote-names -r ~/openemr.sql 'openemr' | gzip > openemr.sql.gz
      tar -zcf openemr_web.tar.gz /var/www/openemr/sites
      tar -cvf emr_backup.tar openemr.sql.gz openemr_web.tar.gz
      rm openemr.sql.gz
      rm openemr_web.tar.gz
      echo “Your backup was successful and saved as emr_backup.tar”

      use the following command to execute shell script:
      sudo bash my_emr_backup.sh

      make sure you use the sudo command, otherwise you will get permission errors; I assume you have a default bash shell.
      could run this in a rotating cron job
      best of luck

       
      • David Speck MD

        David Speck MD - 2013-12-15

        Lams,

        Is there a way to modify the script above so that it puts a date and time stamp into the file name?. The way it is written now, the newest backup always overwrites the previous one. It is generally good programming practice to keep a number of backups, in case an adverse effect of some change is not discovered till some later date.

        If the backup file names could come out as something like:

        emr_backup_2013-12-14_22:16:43.tar

        it would be helpful. As hard drive space is essentially free these days (4 TB for $159 on sale, last I looked), there's no good reason to keep only one backup copy. I'm not sure if colons would be allowed as separators in the time part of the file name.

        Thanks,

        Dave

         
        • Lams

          Lams - 2013-12-15

          Hello Dave,
          you raised a good point - for rotating and keeping a few days and weeks of backups. I guess one could make the following changes:

          #!/bin/bash

          time_stamp=$(date +"%m_%d_%Y")
          #for a complete time-second stamp, uncomment below
          #time_stamp=$(date +"%m_%d_%Y_%T)

          /usr/bin/mysqldump -u 'openemr' -p'1wC3FofWpevv' --opt --quote-names -r ~/openemr.sql 'openemr' | gzip > openemr.sql.gz
          tar -zcf openemr_web.tar.gz /var/www/openemr/sites
          tar -cvf emr_backup_$time_stamp.tar openemr.sql.gz openemr_web.tar.gz
          rm openemr.sql.gz
          rm openemr_web.tar.gz
          echo “Your backup was successful”

          I have avoided : and - and such characters from the file name. I think sometimes they may cause trouble. However, if you want a full time stamp, just redefine the above time stamp variable with
          time_stamp=$(date +"%m_%d_%Y_%T)

           

          Last edit: Lams 2013-12-15
          • David Speck MD

            David Speck MD - 2013-12-15

            Excellent, Lams!

            Thanks very much.

            I might suggest that you order it as:

            time_stamp=$(date +"%Y_%d_%m")

            or

            time_stamp=$(date +"%Y_%d_%m_%T)

            so that the backups would sort properly by date and time created.

            It occurs to me that this looks like it would be appropriate for a Linux installation. Please pardon the noob question, but how would one do it for a system hosted on Windows 7?

            Is there a way we could make it an official, standard part of OpenEMR?

            Dave

             
            • MD Support

              MD Support - 2013-12-15

              There is a nice standard script that encrypts the backup files and handles burning Dvd as well as cleanup. You should seriously consider using that.

               
            • Lams

              Lams - 2013-12-15

              Dave, I'm afraid I am not very familiar with the windows implementation. I once tried it, but found the linux platform easier to meddle with.

              As MD support has pointed out, there are other scripts with more features available to create backups. The great feature of the mysqldump command is that it stops the mysql server and stops all db transactions. The script above is quite basic but I have used the output to restore and re-create a functioning original oemr installation. There is a script out there that uses duplicity to create encrypted backups and then uploads them to amazon s3. But I find the resulting file sets too complicated to restore. No restore = No backup

               

              Last edit: Lams 2013-12-15
              • Lams

                Lams - 2013-12-15

                Please remember that if you use couchdb to store patient documents (as I do), the above script or the one MD support is referring to will not back up these documents. One will need to carry out a separate backup for couchdb. Fortunately, couchdb backup and restore is quite straightforward.

                 
  • M S

    M S - 2014-01-16

    Lams

    Thanks for the script above, it is working well. It appears that there is an issue with the table which may have been the original issue. Here is the output during the execution of the script.

    mysqldump: Error 1194: Table 'openemr_session_info' is marked as crashed and should be repaired when dumping table openemr_session_info at row: 1220
    tar: Removing leading `/' from member names

     

Log in to post a comment.