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:[email protected]/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. "[email protected]"
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.gsinto the defaultCode.gsfile (or create a new file for this code). - Change
example.comin 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 triggersand add a new time-driven trigger forinitiateGitBackupand 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.