Export Notion pages and subpages to a GitHub repo on a schedule (eg. to be used as a scheduled backup)
- Click on the green "Use this template" button at the top to make your own copy of this repository - make sure to choose "Private" visibility, unless you want to make your Notion content visible to the public
- Under Settings -> Actions -> General -> Workflow, scroll down to the Workflow Permissions section and select
Read and write permissions
(this is to allow the Actions workflow to write your Notion content to your repo) - Under Settings -> Secrets and Variables -> Actions, create a new repository secret called
NOTION_TOKEN
with the instructions in this article (original Medium article) - Edit
index.ts
to add the Notion pages you want to export to theblocks
array at the top of the file - Optional: Edit
index.ts
to specify a different export format, time zone or locale - Optional: Edit
.github/workflows/export-notion-blocks-and-commit.yml
to specify a different schedule (default is once per day) - After the
Export Notion Blocks and Commit to Git
workflow has run, your backup will have been committed to your GitHub repo in theexports
folder! 🙌
The GitHub Actions workflow is scheduled to run once a day to:
- export each specified Notion block
- wait until each export is done
- download, unzip and commit the content from each export to the repository
- Notion Backup Enhancer - rename files and folders after backup to remove Notion id
This script is heavily based on notion-guardian
, thanks to @richartkeil!