Back up a Google Sheet to a git repository.
Prerequisites:
- LibreOffice
- Git
For the server component:
Set the following environment variables:
GIT_REMOTE
- Remote of the git repository to push to. If the repo requires authentication, include the username and password in the URL (ex.https://username:password@github.com/repo.git
) Note: this repo will be pulled from on first start.GIT_COMMITTER_NAME
- Full name to make commits under. Ex. "Zaphod Beeblebrox"GIT_COMMITTER_EMAIL
- Email to make commits under. Ex. "zaphod@beeblebrox.com"
Deploy! Everything's already set up for Heroku/Dokku (including the crazy LibreOffice dependency), if you'd like to use that.
For the Apps Script component:
This program works through having an Apps Script attached to a spreadsheet continually ping an endpoint on the Python server, passing it auth information and the ID of the spreadsheet to work on.
script.gs
contains that Apps Script we want to install on our spreadsheet of
choice. To do that, do the following:
- In your open spreadsheet, click
Tools > Script editor...
. - Past the contents of
script.gs
into the defaultCode.gs
file (or create a new file for this code). - Change
example.com
in the pasted code to match the hostname of your deployed app. - Let's install a trigger to get this script running periodically. While still
in the script editor, click
Resources > Current project's triggers
and add a new time-driven trigger forinitiateGitBackup
and choose an interval that works for you. We currently have it running every minute.
Once you've done that, you're good to go!
See LICENSE.