Announcement

Collapse
No announcement yet.

Code Template: Automatic Mirth Backup

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by mdehoog View Post
    [2018-01-24 17:10:56,674]
    Seems
    Code:
    if (archivePassword !== undefined) {
    doesnt do the trick.
    Hmm... this is the standard way in JS to check if a parameter was provided to a function and usually works very well. So it does for us (v3.4.2, windows, Oracle JDK). Do you maybe use OpenJDK?
    I, however, did not add a check for an empty parameter - I hope this fixes your issue. If not, simply remove the encryption part from the function if you don't need it.

    Originally posted by mdehoog View Post
    Exporting configuration of mirth server "127.0.0.1"
    [2018-01-24 17:22:42,369] ERROR (transformer:?): unable to write file "C:/Users/...................Mirth/Backup Channels//2018-01-24/127.0.0.1_2018-01-24 17-22-39.zip": "ByteArrayOutputStream" is not defined.
    Yes, this is a bug. Funny, that it doesn't become active w/ v3.4.2. Fixed

    Please find the fixed version in the first post.

    Please let me know how it works for your environment. (Mirth version, OS, JDK)
    Last edited by odo; 01-25-2018, 01:09 PM.

    Comment


    • #17
      Originally posted by odo View Post
      Did it work? Writing the configuration map is different from writing the Mirth configuration as it is no xml but a property map (with comments).

      As promised, I extended the backup functionality:
      • Added configuration map export
      • Added zip compression of the backup (resulting size is now 5-10% of the size before)
      • Added optional 256 bit AES encryption of the export

      You were right it needed to be a property file and not an xml formatted file.

      Thank you for posting your update - it is working and is an excellent solution!
      I have learned a lot from your solution and your willingness to share is much appreciated!

      Mirth v3.4.2.8129
      Win 10/JDK 1.80_152
      Win Server 2012 R2/JDK 1.7.0_141
      Last edited by davidap; 02-01-2018, 01:21 PM. Reason: Added versions of Mirth, OS and JDK

      Comment


      • #18
        Works like a champ!!

        Perfect solution.

        One "small" add-on maybe.
        It would be nice if it would backup the channels in seperate files also.

        Windows 10, JRE 1.8, Mirth Connect 3.6.1, Postgres db
        Last edited by mdehoog; 11-21-2018, 01:56 AM.
        X Connections
        https://documentor.email
        https://www.x-connections.com

        Comment


        • #19
          Originally posted by mdehoog View Post
          It would be nice if it would backup the channels in seperate files also.
          Good idea but this is not in the scope of this use case. This was only meant to create a daily backup for recovery in the case of need.

          However, as soon as I find some time, I'd like to create a channel that automatically commits a channel or code template to a svn repository as soon as something changes.

          When done, I will publish it in the forum if it would be of help to someone.

          Comment


          • #20
            Thanks a lot for this great contribution. Works well with 3.7.1.

            I had one issue small with the backup function; the server parameter in particular. I'm using a custom https port (8553) instead of the default (8443) that is hard-coded in the backup function. I was getting 'connection refused' errors when deploying the backup channel.

            I tried removing the port number from code template and passing the server parameter as '127.0.0.1:8553' but that caused the backup file not to be created because Windows doesn't allow colons in file names.

            I ended up modifying the function to accept both server and port parameters, and replaced the hard-coded '8443' in the function with the passed port parameter.

            The modified function call looks like: backupMirthServer('admin', 'admin', '127.0.0.1' , '8558', 'C:\Backup');


            Another issue I noticed is that when Windows user lacks privilege to write to the backup directory, backup function still logs that the backup file was created successfully.

            Thanks again

            Comment


            • #21
              Thanks for your feedback!

              I fixed both issues, you encountered, and added the changed version to the first post.

              Comment


              • #22
                Hi,

                I have tried the code template and runs without problems, but on import cast the following error:

                Invalid channel file:
                com.mirth.connect.model.ServerConfiguration cannot be cast to com.mirth.connect.model.Channel
                java.lang.ClassCastException: com.mirth.connect.model.ServerConfiguration cannot be cast to com.mirth.connect.model.Channel
                at com.mirth.connect.client.ui.ChannelPanel.importCha nnel(ChannelPanel.java:1425)
                at com.mirth.connect.client.ui.ChannelPanel.doImportC hannel(ChannelPanel.java:1413)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                at sun.reflect.misc.Trampoline.invoke(Unknown Source)
                at sun.reflect.GeneratedMethodAccessor2.invoke(Unknow n Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
                at java.beans.EventHandler.invokeInternal(Unknown Source)
                at java.beans.EventHandler.access$000(Unknown Source)
                at java.beans.EventHandler$1.run(Unknown Source)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.beans.EventHandler.invoke(Unknown Source)
                at com.sun.proxy.$Proxy46.actionPerformed(Unknown Source)
                at org.jdesktop.swingx.action.BoundAction.actionPerfo rmed(BoundAction.java:231)
                at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
                at org.jdesktop.swingx.JXHyperlink.fireActionPerforme d(JXHyperlink.java:264)
                at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
                at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
                at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
                at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
                at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
                at java.awt.Component.processMouseEvent(Unknown Source)
                at javax.swing.JComponent.processMouseEvent(Unknown Source)
                at java.awt.Component.processEvent(Unknown Source)
                at java.awt.Container.processEvent(Unknown Source)
                at java.awt.Component.dispatchEventImpl(Unknown Source)
                at java.awt.Container.dispatchEventImpl(Unknown Source)
                at java.awt.Component.dispatchEvent(Unknown Source)
                at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
                at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
                at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
                at java.awt.Container.dispatchEventImpl(Unknown Source)
                at java.awt.Window.dispatchEventImpl(Unknown Source)
                at java.awt.Component.dispatchEvent(Unknown Source)
                at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
                at java.awt.EventQueue.access$500(Unknown Source)
                at java.awt.EventQueue$3.run(Unknown Source)
                at java.awt.EventQueue$3.run(Unknown Source)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.security.ProtectionDomain$JavaSecurityAccessI mpl.doIntersectionPrivilege(Unknown Source)
                at java.security.ProtectionDomain$JavaSecurityAccessI mpl.doIntersectionPrivilege(Unknown Source)
                at java.awt.EventQueue$4.run(Unknown Source)
                at java.awt.EventQueue$4.run(Unknown Source)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.security.ProtectionDomain$JavaSecurityAccessI mpl.doIntersectionPrivilege(Unknown Source)
                at java.awt.EventQueue.dispatchEvent(Unknown Source)
                at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
                at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
                at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
                at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
                at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
                at java.awt.EventDispatchThread.run(Unknown Source)



                I tried "import Channel" and "Import group" with the same error. I'm on Mirth Connect 3.5.1.


                Thanks in advance and sorry for my english

                Comment


                • #23
                  Originally posted by JuanMiguel View Post
                  I tried "import Channel" and "Import group" with the same error. I'm on Mirth Connect 3.5.1.
                  Exactly this is the reason. The backup backups the whole configuration of mirth meaning all Channels, code templates, libraries, etc.

                  For restoring the configuration you would have to use the Restore Config button in Mirth administrator.

                  If you would just like to restore single channels or channel groups, you have to extract the corresponding part of the configuration first.

                  Comment


                  • #24
                    Thanks odo!!

                    Works like a charm. I just have a question: the backup generated with your script takes less space than if I manually backup only the channels.

                    In my case with your script the xml occupies 2.5Mb (Uncompressed) and manually 7Mb...

                    Anyway when I restore from your backup, everything works ok.

                    Thank you for your work ;-)

                    Comment


                    • #25
                      Originally posted by JuanMiguel View Post
                      the backup generated with your script takes less space than if I manually backup only the channels.
                      The generated backup should be complete. We use it for 8 servers on a daily base and I never encountered any issues.

                      Even the configuration map is backed up in a different file. Finally, everything is zipped, which might explain the difference in size?

                      Comment


                      • #26
                        Originally posted by JuanMiguel View Post
                        Thanks odo!!

                        Works like a charm. I just have a question: the backup generated with your script takes less space than if I manually backup only the channels.

                        In my case with your script the xml occupies 2.5Mb (Uncompressed) and manually 7Mb...

                        Anyway when I restore from your backup, everything works ok.

                        Thank you for your work ;-)
                        Do you have some large code template libraries that you are including with each individual channel backup? If that's the case you might have a lot of redundant data in your manual channel backups that will only appear once in the full server config backup.

                        Comment


                        • #27
                          Originally posted by agermano View Post
                          Do you have some large code template libraries that you are including with each individual channel backup? If that's the case you might have a lot of redundant data in your manual channel backups that will only appear once in the full server config backup.

                          That´s right!! I have verified the manual backup and I found javascript libraries repeat on it.

                          Thanks everybody for your help!!

                          Comment

                          Working...
                          X