Backup and Restore TinyDB to/from
Text Files on Google Drive
An alternative to the many, many methods that are available for backing up the contents of a tinyDB database on AI2. In this instance, we use a google apps script web app to create individual files of each tag, with the content of the file being the tag value. This is obviously more suitable for larger tag value contents! The benefits of this method is that it stores the data off the app, provides a backup facility for the tags in a tinyDB individually, and individual tags and their values can be shared with others, or downloaded elsewhere. Any previous versions of a tag and its value is stored in a separate file in the Google Drive Bin for 30 days. All tag values are stored as plain text.
Please follow the originating demo for this HERE, to get an understanding of how things work.
You can create a folder called TINYDB, and within it a subfolder called TagsAndValues on your Google Drive.
Here I used a standalone Google Apps Script project which was created in the TINYDB folder.
WEB APP SCRIPT
AIA and FILES
To use the above aia project file, you will need to setup folders on your google drive: TINYDB then TagsAndValues as a subfolder, then create a standalone apps script project in the TINYDB folder, Add the script code above to the script project, then publish as a web app, getting the script url. In the aia project you will need to add the script url and the folder names and IDs.