notionblog / notion-backups

🪄 Automatic backups for your Notion workspaces.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Cover

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

Getting started

  1. Log in to your Cloudflare workers dashboard, select the workers tab, and then create a new service. Step 1

  2. Give your script a name and then click the 'create service' button. Step 2

  3. Click on the Quick edit button and Copy-paste the Script code into the editor. Step 3

  4. Follow this guide to find your Notion token v2.

  5. 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) Step 4
  6. Returning to your worker editor page, you should now see the following page. Step 5

  7. To manually test the script, add a new variable with the name MODE and the value test to your environment variables. Step 6

  8. 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. Step 7

  9. 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

    0 0 1 * * will cause the script to run on a monthly basis. Step 8

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

Support Me

Buy Me a Coffee at ko-fi.com

About

🪄 Automatic backups for your Notion workspaces.

License:MIT License


Languages

Language:JavaScript 63.4%Language:HTML 36.6%