Skip to content

Simple Python script to back-up all your Notion pages locally

License

Notifications You must be signed in to change notification settings

sakshamsoni97/NotionBackup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Script to Backup Notion Data Locally

This is a simple Python script that uses the Notion client SDK to download all the pages from your Notion account in markdown and save them as a zipped back-up file. There are some pre-requisites to run this -

Pre-requisites

  1. Create a Notion integration in your account. You need to be the owner/admin of the account. Check this link for more details.
  2. Add this integration to all the pages you want to back-up. Adding the parent page automatically adds all the children pages.

Set Up

The first recommended step is to create a Python virtual environment in the directory and install the required packages in it.

python -m venv notion_env
source notion_env/bin/activate
pip install notion-client notion2md python-dotenv

Next you want to create a .env file and paste your Notion Integration Secret in there.

NOTION_TOKEN=""

Run

You can now run this script

python backup_notion.py

It should create a backup file named notion_backup_YYYY-MM-DD.zip with today's date.

Schedule

If you'd like to back-up your Notion automatically every week or every night, you can use cron to schedule that job if you are using a Linux based computer. Here is how I did for my system.

0 3 * * 6 /home/user/NotionBackup/notion_env/bin/python /home/user/NotionBackup/backup_notion.py >> /home/user/NotionBackup/cron.log 2>&1

References

  1. https://notionbackups.com/guides/automated-notion-backup-api
  2. https://www.notion.com/help/create-integrations-with-the-notion-api

About

Simple Python script to back-up all your Notion pages locally

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages