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.
- A Free Cloudflare workers account
- Notion token
token_v2(See this guide)
-
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 editbutton 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_V2paste the value of your Notion token (required)SLACK_WEBHOOKpaste your Slack webhook URL (optional to receive notification via Slack)DISCORD_WEBHOOKpaste 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
MODEand the valuetestto 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
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.
Requirements
- Linux or WSL
- Node
Install wrangler
npm i -g wrangler
Login With Wrangler to Cloudflare
wrangler login
Install packages
npm install
Run
wrangler dev

