Giter Site home page Giter Site logo

kaedea / notion-up Goto Github PK

View Code? Open in Web Editor NEW
118.0 1.0 24.0 588 KB

Use NotionUp (Notion Backup) + CircleCI to backup your notion data nightly.|自动备份 Notion 数据。|Notion データのバックアップを自動化する

Home Page: https://www.kaedea.com/2021/10/01/devops/notion-backup/

Python 100.00%
notion notion-backup devops

notion-up's Introduction

notion-up

中文说明

NotionUp (Notion Backup) is a python repo helping you to backup notion data automatically.

Getting Started

Prepare

To get started with NotionUp, you should:

  1. Prepare your Notion's username(email) and password, or just find your notion_token_v2.
  2. Run notion-up/main.py with your configs.

Check here to find out your notion_token_v2 if need.

Run CLI

Basically just run notion-down/main.py :

# Run with cli cmd
PYTHONPATH=./ python main.py
    --token_v2 <token_v2>
    --username <username>  # Only when token_v2 is not presented
    --password <password>  # Only when token_v2 is not presented

# or
PYTHONPATH=./ python main.py \
    --config_file '.config_file.json'

# Your can configure notion-down args by cli-args, config_file or SysEnv parameters
# Priority: cli args > config_file > SysEnv parameters > NotionDown default

Archive to GitHub Release

Check the following workflows and jobs in .circleci/config.yml to get how it works.

workflows:
  backup-notion:
    jobs:
      - export-workspace
      - publish-github-release:
          requires:
            - export-workspace

As examples, check the output at Release and notion-exported.

Backup nightly

Check the following crontab workflows.

workflows:
  backup-notion-nightly:
    triggers:
      - schedule:
          cron: "0 * * * *"  # every hour
          filters:
            branches:
              only:
                - master
    jobs:
      - export-workspace
      - publish-github-release:
          requires:
            - export-workspace

Showcase

Work with CircleCI, see .circleci/config.yml.

notion-up's People

Contributors

kaedea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

notion-up's Issues

how to use CircleCi

How to configure yml ? circleci

I cant upload it to my Github. Can u give me an example ?

NameError: name 'unicode' is not defined

python3 main.py --token_v2 xxxxx

https://s3.us-west-2.amazonaws.com/temporary.notion-static.com/Export-85d43a1a-a0aa-44b9-8783-9410135efd5e.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220629%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220629T031308Z&X-Amz-Expires=604800&X-Amz-Signature=c55e628909e28e53fc975408470b86bf4368648c74119a60c6a3ff7abb30da84&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%20%3D%22Export-85d43a1a-a0aa-44b9-8783-9410135efd5e.zip%22&x-id=GetObject
Traceback (most recent call last):
File "E:\workspace\note2-master\main.py", line 50, in
start()
File "E:\workspace\note2-master\main.py", line 25, in start
zips = NotionUp.backup()
File "E:\workspace\note2-master\notion_backup.py", line 95, in backup
filename = slugify(f'{spaceName}-{spaceId}') + '.zip'
File "C:\Users\admin\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\slugify.py", line 24, in slugify
unicode(
NameError: name 'unicode' is not defined

有关备份后恢复的问题

你好,请问:通过该脚本备份后,如何再原样导入?(目前我看到的是只能通过导出md文件逐层级的手动恢复)

导出任务失败,请问是notion数据类型不支持导出的问题吗?

waitForExportedUrl 获取的任务状态是失败,报错信息如下:

'status': {'type': 'progress', 'pagesExported': 11}, 'error': "Cannot read properties of undefined (reading 'value')"}

另外,这段函数有个bug,state是failure时还在循环,我改了一下:

    def waitForExportedUrl(taskId):
        print('Polling for export task: {}'.format(taskId))
        t_0 = arrow.now()
        while True:
            res = NotionUp.requestPost('getTasks', {'taskIds': [taskId]})
            tasks = res.get('results')
            task = next(t for t in tasks if t['id'] == taskId)
            if task['state'] == 'success':
                url = task['status']['exportURL']
                print('\n' + url)
                break
            elif task['state'] == 'in_progress':
                print(f'\rDuration: {arrow.now() - t_0}', end="", flush=False)
                time.sleep(10)
            else:
                raise Exception('\n' + 'Error! Here is the return message:\n' + str(res))
        print('export state success\n')
        return url

项目

请问项目现在还可以使用吗

Download zip failed, return status code 403

When notion accepts the get request, it should verify the identity through the cookie. The get of the direct request cannot be downloaded correctly. Is there any solution?

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.