GithubHelp home page GithubHelp logo

hugo-clemente / notion-backup Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 7.0 3 KB

A simple GitHub repository template you can use to automate Notion backups using GitHub actions.

notion backup backup-script

notion-backup's Introduction

Notion Backup

A simple GitHub repository template you can use to automate Notion backups using GitHub actions. The backups are stored on the repo, so you can keep track of them.

Acknowledgements

Huge thanks to Artur Burtsev ! They're the author of the script used for the backup, and they wrote this article which is the main source of "inspiration" for this repo.


How to use

Simply click the use this template button on GitHub to create your own repo. Next, you need to configure the secrets to get the backup script working.

Configuring the secrets

Two things are needed : a notion access token, and a notion space ID.

Here's how to get them in Google Chrome:

  • Open http://notion.so/, go to “Settings & Members” → “Settings”
  • Open Chrome DevTools by pressing Command+Option+J (Mac) or Control+Shift+J (Windows, Linux, Chrome OS)
  • Go to the Network tab, as shown on a screenshot below
  • Enable “XHR” filter (1), clear console (2), start the export (3), select “enqueueTask” (4)

Drag Racing

In the opened “Headers” tab you would need to scroll down until you see “cookie:” and a lot of text, in this text you need to identify a part, which looks like (5): token_v2=xxx; where xxx is a very long sequence of letters and digits and can span multiple lines.
Copy everything between “token_v2=” and “;” and add it as a GitHub actions secret under the name NOTION_TOKEN_V2 (How to add a secret to GitHub actions).

Now scroll to the very bottom and under the “Request Payload” section you will see something like (6): spaceId: “4489c123-09d6-4069-ae3b-1665e25d6c03”
Copy the value inside quotes, and again add it as a GitHub actions secret under the name NOTION_SPACE_ID.

Enabling actions

⚠️ THIS STEP IS VERY IMPORTANT, THE BACKUP WON'T WORK IF YOU DON'T DO THIS ⚠️

To enable the backup action, you simply need to go to the actions tab, and click Enable actions on this repository


You should be good to go !

The script will run everyday at 8PM UTC (configurable), and add the notion export to a backup folder in your repo.

Configure the cron task

The script is run on a cron schedule. You can modify the schedule in the .github/workflows/backup.yml file. Look for - cron: '0 20 * * *', and change the cron schedule as desired (use this great tool)

https://artur-en.medium.com/automated-notion-backups-f6af4edc298d

notion-backup's People

Contributors

hugo-clemente avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

notion-backup's Issues

urllib.error.HTTPError: HTTP Error 403: Forbidden

I did get an error urllib.error.HTTPError: HTTP Error 403: Forbidden. What to do? I deleted the filename and replaced it with the text in-between the <>

Pages exported: 3601
Pages exported: 3601
Pages exported: 3603
Export created, downloading: https://file.notion.so/f/t/<filename-which-contained-my-data>.zip
    with contextlib.closing(urlopen(url, data)) as fp:
                            ^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/urllib/request.py", line 215, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/urllib/request.py", line 521, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/urllib/request.py", line 630, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/urllib/request.py", line 559, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/urllib/request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.1/x64/lib/python3.12/urllib/request.py", line 639, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.