简体   繁体   English

如何备份绑定的 Google Apps 脚本

[英]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.复制项目密钥。

How to Use the Project Key to link to a library如何使用项目密钥链接到库

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 脚本文件中,添加项目密钥作为库。

  • Resources资源
  • Libraries图书馆

添加库

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.

相关问题 备份Google Apps脚本未运行 - Backup Google apps script not running 如何从独立的Google Apps脚本项目备份代码? - How to backup the code from a standalone Google Apps Script project? 如何将onChange()Google Apps脚本函数绑定到特定事件? - How to bound the onChange() google apps script function to specific events? 容器绑定Google Apps脚本中的jQuery? - jQuery in Container Bound Google Apps Script? 如何使用Google Apps脚本定期备份Google云端硬盘(Google电子表格)文件? - How do I backup Google Drive (Google Spreadsheets) file on regular basis using Google Apps Script? 如何在Google Apps脚本中以编程方式复制文件绑定脚本的脚本权限? - How to programatically copy script permissions for a file bound script in Google Apps Script? 如何获取链接/绑定到 Google 电子表格的 Google Apps 脚本项目 ID - How to get Google Apps Script project ID linked/bound to a Google Spreadsheet Google Apps Script:获取绑定到电子表格的脚本 ID - Google Apps Script: Get the ID of script bound to a spreadsheet Google Apps脚本绑定脚本获取容器ID - Google Apps Script bound script get container id 在 Google Apps 脚本中创建电子表格备份时,如何复制格式和值,而不是公式? - How to copy format and values, not formulas, when creating a spreadsheet backup in Google Apps Script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM