我目前正在使用 Google 表单来允许人们提交存储在 Google 文档电子表格中的信息。我想知道是否可以定期自动备份电子表格。例如,每个星期五电子表格都会导出为 CSV 并通过电子邮件发送给我或存储在服务器上受密码保护的目录中。

感谢您的阅读,任何想法都会受到赞赏!

有帮助吗?

解决方案

Google文档是在线编辑和协作的理想工具。 虽然Google文档不提供自动备份的功能,但与Google文档相同使用Dropbox存储的人员具有解决方案。

解决方案是 cloudhq (10 $ + / pm)提供 google文档和dropbox之间的实时同步的服务。例如,虽然用户正在编辑一些Google文档Web文档,但在Dropbox中自动修改文档。这意味着, cloudhq 自动将文件从Google文档复制到Dropbox。

我想提出以下链接到 cloudhq快速游览 cloudhq 还提供Google Chrome扩展名。使用 cloudhq chrome浏览器扩展您可以使用Google文档接口直接与Google文档中的Dropbox或Basecamp帐户中的任何内容同步或复制或复制任何内容。 Google Chrome Web Store中提供了扩展名。

如果有人可以为我提供一些关于云服务之间的数据同步的提示或意见,我应该感激。

其他提示

这是一个解决方案:

  • 自动创建 Google 电子表格的备份(每日/每周等)
  • 作为 Google 云端硬盘中给定文件夹中的 Excel 文件 (XLSX)
  • 然后您可以将其配置为自动同步到您的计算机

步骤1

在 Google 云端硬盘中创建一个用于备份文件的文件夹(例如“我的硬盘 > 文档 > 备份”)。在浏览器中打开它,并记下其“文件夹ID”来自网址。例如,来自以下 URL 的文件夹 ID 将为 1234abcdefgh_98765ijklmnopqrs_0XY

https://drive.google.com/drive/u/0/folders/1234abcdefgh_98765ijklmnopqrs_0XY?ths=true

第2步

打开您想要自动备份的 Google 电子表格。从顶部菜单中选择“工具”>“脚本编辑器”。在打开的新窗口中,将默认代码替换为以下代码,并确保:

  • 启用 高级驾驶服务 如果您还没有:从顶部菜单中,选择“资源”>“高级 Google 服务...”>“Drive API”> 切换“打开”
  • 更新文件夹 ID, ,通过替换 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 与您的备份文件夹ID,在行 var backupFolder = ...
// function to backup the current Spreadsheet as an Excel file (XLSX) in a given folder
// -- requires "Advanced Drive Service" which must be enabled in "Resources" > "Advanced Google services..." > "Drive API" > toggle "ON"
function backupSheet() {
  // UPDATE THE FOLDER ID for e.g. "My Drive > Docs > Backups"
  var backupFolder = DriveApp.getFolderById("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var spreadsheetId = spreadsheet.getId();
  var file = Drive.Files.get(spreadsheetId);
  var url = file.exportLinks[MimeType.MICROSOFT_EXCEL];
  var token = ScriptApp.getOAuthToken();
  var options = { headers: { Authorization: "Bearer " + token } };
  var response = UrlFetchApp.fetch(url, options);
  var doc = response.getBlob();
  var backupDate = Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd' 'HH-mm-ss");
  var backupName = spreadsheet.getName() + ".backup " + backupDate + ".xlsx";
  var tempFile = DriveApp.createFile(doc).setName(backupName);
  tempFile.makeCopy(backupName, backupFolder);
  tempFile.setTrashed(true);
}

如果您想测试脚本,请单击“跑步” 代码上方的图标。这将在您配置的备份文件夹中(基于前面提到的文件夹 ID)创建电子表格的备份 Excel 文件。

步骤3

节省 您的脚本(从顶部菜单中选择“文件”>“保存”),然后单击“触发器代码上方的“图标(时钟形图标)。在打开的新窗口中,单击“+ 添加触发器“(在右下角)。您应该看到一个标题为“Add Trigger for backupSheet”的叠加层,您可以在其中计划自动备份的执行。例如,如果您希望它每周一运行,您应该配置以下设置:

  • 选择要运行的函数: 备份表
  • 选择应运行的部署:
  • 选择事件源: 时间驱动
  • 选择基于时间的触发器类型: 周计时器
  • 选择星期几: 每逢星期一

节省 完成配置后触发。现在,Excel 备份将自动在 Google 云端硬盘的所需文件夹中创建。

步骤4

最后,安装 来自 Google 的备份和同步 在您的计算机上(如果还没有),并将其配置为从您的 Google 云端硬盘帐户同步备份文件夹 - 在“首选项”>“Google 云端硬盘”> 启用“将我的云端硬盘同步到此计算机”,并确保备份文件夹是正在同步的文件夹之一。

该应用程序现在将自动下载您的 Google 电子表格的 Excel 备份,以供您离线使用!

Two solutions that don't involve a for-pay subscription: 1) write a script or short app (pick your language) that exports a Google Sheet using the Google Drive API as CSV. Why the Drive API? The Sheets API is for spreadsheet-oriented functionality, i.e., data formatting, column resize, creating charts, cell validation, etc., while the Drive API is for file-oriented functionality, i.e., import/export.

If you do Python, here's a complete example which you can run as a cron job on your server or if app-hosting on Google App Engine. If you don't, you can use it as pseudocode and pick any language supported by the Google APIs Client Libraries. Here's core piece of code from that example (assume the most current Sheet named 'inventory'):

FILENAME = 'inventory'
SRC_MIMETYPE = 'application/vnd.google-apps.spreadsheet'
DST_MIMETYPE = 'text/csv'

files = DRIVE.files().list(
    q='name="%s" and mimeType="%s"' % (FILENAME, SRC_MIMETYPE),
    orderBy='modifiedTime desc,name').execute().get('files', [])

if files:
    fn = '%s.csv' % os.path.splitext(files[0]['name'].replace(' ', '_'))[0]
    print('Exporting "%s" as "%s"... ' % (files[0]['name'], fn), end='')
    data = DRIVE.files().export(fileId=files[0]['id'], mimeType=DST_MIMETYPE).execute()
    if data:
        with open(fn, 'wb') as f:
            f.write(data)
        print('DONE')

If your Sheet is large, you may have to export it in chunks -- see this page on how to do that. You can also email the file contents to yourself with the Gmail API. If you're generally new to Google APIs, I have a (somewhat dated but) user-friendly intro video for you. (There are 2 videos after that maybe useful too.)

2) The other solution is for those who are "allergic" to using APIs, and that alternative is Google Apps Script, Javascript outside of the browser. Like Node, it runs server-side but on Google's servers. With Apps Script, you can use DriveApp or the advanced Drive service to access your Sheet, then use MailApp or GmailApp to email it to yourself, or use the UrlFetch service to send it to some server of your choosing. To run it at a normal interval, you'll need to create a script as a time-driven installable trigger. In either case, you don't need to host+execute your app yourself.

ps. The latest Drive API version is v3, but if you access Drive from Apps Script, it uses v2 (not deprecated yet).

Google docs is a free tool that allows users to automatically save and collaborate any data in real-time. It does not however have a built-in feature for secure google docs backup nor automatic real-time backup.

Google have stated officially in their terms of service that:

Google, and Google’s suppliers and distributors, will not be responsible for lost profits, revenues, or data, financial losses or indirect, special, consequential, exemplary, or punitive damages.

Their waving of liability is applicable not just for personal use but also business use:

If you are using our Services on behalf of a business, that business accepts these terms. It will hold harmless and indemnify Google and its affiliates… including any liability or expense arising from claims, losses, damages, suits, judgments, litigation costs and attorneys’ fees.

Today there are other options other than paying to sync to Dropbox for google docs backup automation. Your decision on how to automate your google docs backup depends on a few factors:

  1. How sensitive your data is, and whether it’s for personal or business use i.e- How liable you’ll need to be in case of data loss or a security breach.

  2. Whether you have the dev knowledge to code a script or app using any of the methods outlined by wescpy previously in full detail:

a) using the Google drive API that exports google sheets automatically b) using Python to run a cron job on your server to export a google sheet spreadsheet as CSV or c) write a non-API Javascript that runs outside your browser using the Google apps script

If you require full security and data protection, and opt for a no-pay subscription- automated google docs backup solution, suffice to say you need to be sure your code is reliable and provides the security/encryption your project requires.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top