Question
· Jun 13, 2019

Automatically export all globals

Is there a way to automatically export all globals? I want to script out this process so that this happens on a specific frequency. This is for testing, as an additional backup safeguard.

Discussion (6)1
Log in or sign up to continue

Have a look at %System.OBJ.Export():
https://irisdocs.intersystems.com/irisforhealth20192/csp/documatic/%25CSP.Documatic.cls

TESTING>s itm="*.GBL"
TESTING>s file="C:\Projects\export_mm.xml"
TESTING>d $System.OBJ.Export(.itm,.file,,.errors)

Having said that, since this is just for backups you might also consider just using the standard Online Backup utility which will backup all globals in the selected database(s) into a file:

https://irisdocs.intersystems.com/irisforhealth20192/csp/docbook/DocBook.UI.Page.cls?KEY=GCDI_backup#GCDI_backup_methods_online

2 things:

1. Why are you doing that to XML versus the GOF format? I don't even see that as an option when doing that from the UI. Is that as easy to import as the GOF format? If I wanted to do the GOF using this method, how do I do that?

2. How do I automate this method?

As far as the Online Backup, I'm using that as well. But from the documentation, it appears I have to restore the entire database, and I want to be able to restore only specific globals (and also use these for Import into a test database). 

Finally, I'm a backup freak. I tend to have 2 or 3 different methods of backup for every system, plus we lost data last week (see my previous post), so I want to have several options to restore from.

The resulting XML files can be imported again using %System.OBJ.Load().

If you prefer GOF format you can use %Global.Export() instead, however it doesn't accept wildcards so you would need to first put together a list of which globals you want to export.

For automation you can execute these methods from your own custom class or routine. If you want to schedule it to run automatically, you can create your custom class as a %SYS.Task.Definition and schedule it to run using Task Manager.

You're correct -- you can't restore specific globals from an Online Backup (.cbk) file.