Code Monkey home page Code Monkey logo

notion-s3-archiver's Introduction

notion-s3-archiver

A utility to back up any Notion page, and all its subpages, to AWS S3 Glacier Deep Archive.

Basic Usage

Assumes you several environment variables set; NOTION_API_KEY, NOTION_TOP_LEVEL_PAGE_ID, NOTION_OUTPUT_DIR, NOTION_BUCKET_NAME, NOTION_SNS_TOPIC_ARN and NOTION_AWS_REGION. You get an API key when you create an integration, and the page ID is the hexadecimal suffix in the URL of whichever page you are interested in having the crawler start at, eg for https://spill.notion.site/Careers-at-Spill-93c02882604b4b3ebfb7be0222692847 the id is 93c02882604b4b3ebfb7be0222692847. The output directory is where the downloaded json data will be stored - NB this directory will be created by the script, so you only need to provide the path. The bucket and SNS names are the bucket to be uploaded to, and the topic which log messages will get published to - both of these must be in the specified AWS rwegion.

There are many ways to set environment variables - for testing, the easiest is to use export:

export NOTION_API_KEY="123apiKEY"
export NOTION_TOP_LEVEL_PAGE_ID="93c02882604b4b3ebfb7be0222692847"
export NOTION_OUTPUT_DIR="/users/linus/repositories/notion-s3-archiver/out"
export NOTION_BUCKET_NAME="notion-s3-archive-bucket"
export NOTION_SNS_TOPIC_ARN="arn:aws:sns:eu-north-1:000000000000:my-sns-topic"
export NOTION_AWS_REGION="us-east-1"

Then download the repo, build the module and run the code.

git clone https://github.com/jonnyspicer/notion-s3-archiver.git
cd notion-s3-archiver
go build
./notion-s3-archiver

Don't be alarmed if this seems to take a while - the Notion API is rate-limited and so all operations in the script are executed synchronously. As an example, my workspace contains roughly 4500 pages and takes around 3 hours for the crawl alone.

Future Improvements

  1. Make the tool more customisable (eg SNS topic no longer required)
  2. Add alternate places to store archived data, including on disk
  3. Add options for eg bucket versioning, other S3 storage classes
  4. Extract the crawler and the archiver out, document them etc

notion-s3-archiver's People

Contributors

jonnyspicer avatar

Watchers

 avatar

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.