Notion Backups
Set up automated backups for your Notion workspaces that run on a time-basis and notify you by Slack, Discord, or email, so you never worry about losing your Notion data again.
Warning
⚠️ This tool uses the Notion unofficial API, which means it could break at any time. I’ll try my best to keep it up to date, but you should be aware of this.
Pre-requisites
- A Free Cloudflare workers account
- Notion token
token_v2
(See this guide)
Getting started
-
Log in to your Cloudflare workers dashboard, select the workers tab, and then create a new service.
-
Give your script a name and then click the ‘create service’ button.
-
Click on the
Quick edit
button and Copy-paste the Script code into the editor. -
Follow this guide to find your Notion token v2.
-
Navigate to your Worker > Settings > Variables and add the following secrets:
TOKEN_V2
paste the value of your Notion token (required)SLACK_WEBHOOK
paste your Slack webhook URL (optional to receive notification via Slack)DISCORD_WEBHOOK
paste your Discord webhook URL (optional to receive notification via Discord)
-
Returning to your worker editor page, you should now see the following page.
-
To manually test the script, add a new variable with the name
MODE
and the valuetest
to your environment variables. -
If you click the trigger export button again, you should receive a success message, and it will begin exporting your workspace. If you configured your Discord or Slack webhook url, you should receive a message in a few minutes, and you will also receive an email from Notion.
-
in order for the script to execute on a time-based, you must create a cron job task for it,
Navigate to Worker > Triggers > Cron Triggers and create a new cron trigger
Examples:
0 0 * * *
will cause the script to execute once everyday.0 0 */10 * *
will cause the script to execute once every ten days
Change export format to Markdown
To change the backup’s export format from html to markdown or PDF (enterprise plan), create a new environment variable called EXPORT_TYPE
and set its value to html
or markdown
.
Guides
Running project locally
Requirements
- Linux or WSL
- Node
Steps to get server up and running
Install wrangler
npm i -g wrangler
Login With Wrangler to Cloudflare
wrangler login
Install packages
npm install
Run
wrangler dev