How to back up a Google Apps Script's scriptdb -


If I have a mission critical DB, which needs to be backed up regularly, and I have script db As archive, is there a way to back up the actual database file? It seems that DB is embedded in a way that makes it invisible out of the script?

Well, you can always always include all your values ​​and JSON.stringify Ask. If you ever need to restore a database from this, then the only difference is that each item ID will change.

Here is an example:

  function backup (DB) {var db = ScriptDb.getMyDb (); Var res = db.query ({}); Var array = []; While (res.hasNext ()) array push (res.next (). ToJson ()); Var dbString = JSON.stringify (array); Logger.log (dbString); // You will obviously save this string elsewhere, for example, as a Docs file}   

You may also need to do this in disputes, because the script in your DB Can handle a lot of data at once, such as

I also think that this "backup" process should be kept in mind by the API. The above code is just an idea that I just did.

Comments