[英]How to backup bound Google Apps Script
I have looked fairly extensively on this site and on the web and cannot find any posts on how to backup bound Google Apps Scripts.我在此站点和网络上进行了相当广泛的查看,但找不到任何关于如何备份绑定的 Google Apps 脚本的帖子。 Is there a way to do this and how?有没有办法做到这一点以及如何做到这一点? I use a backup solution for anything in Google Drive, although when restoring any file the bound scripts/projects are not part thereof.我对 Google Drive 中的任何内容使用备份解决方案,尽管在恢复任何文件时绑定的脚本/项目不是其中的一部分。
Any help would be welcome, thanks beforehand欢迎任何帮助,在此先感谢
This is not a perfect solution, but it does provide a way to extract content from a bound project.这不是一个完美的解决方案,但它确实提供了一种从绑定项目中提取内容的方法。
In the the bound script project, that you want to get the .gs functions out of, click the "file" menu, and choose "Manage Versions".在绑定的脚本项目中,要从中获取 .gs 函数,单击“文件”菜单,然后选择“管理版本”。
Enter a description, and click "Save New Version"输入说明,然后单击“保存新版本”
In the the bound script project that you want to get the .gs functions out of, click the "file" menu, and choose "Project Properties".在要从中获取 .gs 函数的绑定脚本项目中,单击“文件”菜单,然后选择“项目属性”。
Copy the Project Key.复制项目密钥。
The "library" is just the bound project that you want to back up. “库”只是您要备份的绑定项目。
In a different Apps Script file, add the Project Key as the library.在不同的 Apps 脚本文件中,添加项目密钥作为库。
In the "Find a Library" box, paste in the Project Key of the project that you want to back up.在“查找库”框中,粘贴要备份的项目的项目密钥。
Choose the latest version, and make a note of the "Identifier".选择最新版本,并记下“标识符”。
Add this code to the Apps Script file that you just added the library to:将此代码添加到您刚刚将库添加到的 Apps 脚本文件:
function backUpAllFunctions() {
var fileName = "backUp",
allServerFunctions = "",
fncName;
for (fncName in TestStuff) {
//Logger.log(fncName)
allServerFunctions += TestStuff[fncName];
};
DriveApp.createFile(fileName, allServerFunctions, MimeType.PLAIN_TEXT);
};
Run the above code, and look in your Google Drive.运行上面的代码,然后查看您的 Google Drive。 There will be a new text file which whose contents will be all of the functions in the bound project.将会有一个新的文本文件,其内容将是绑定项目中的所有功能。
If you have HTML files that you want to back up, that can also be done, but that takes a different strategy.如果您有要备份的 HTML 文件,也可以这样做,但这需要不同的策略。 HTML Service needs to be used.需要使用 HTML 服务。
使用最新版本的 google 脚本,只需使用“脚本 ID”而不是项目密钥(已弃用)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.