From 37129a2e37aaac3268b286e502db0fa3fadd9e66 Mon Sep 17 00:00:00 2001 From: LF Date: Mon, 24 Jul 2023 02:57:38 +0800 Subject: [PATCH 1/3] Update README.md --- README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/README.md b/README.md index 2b7820e..6872c2c 100644 --- a/README.md +++ b/README.md @@ -102,3 +102,81 @@ You won't be able to backup files exceeding a size of 100MB unless you enable [G *.jpeg filter=lfs diff=lfs merge=lfs -text *.psd filter=lfs diff=lfs merge=lfs -text ``` + +## AWS S3 Support + +Due to LFS storage constraints (batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.), we can't store the backup file on LFS. To solve this problem, you can store Notion export files on AWS S3. + +```yaml +name: "Notion backup" + +on: + push: + branches: + - master + schedule: + - cron: "0 */4 * * *" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + +jobs: + backup: + runs-on: ubuntu-latest + name: Backup + timeout-minutes: 120 + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Delete previous backup + run: rm -rf markdown html *.zip + + - name: Setup dependencies + run: npm install -g notion-backup + + - name: install awscli + id: install-aws-cli + uses: unfor19/install-aws-cli-action@master + with: + version: 2 + + - name: Run backup + run: notion-backup + env: + NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }} + NOTION_FILE_TOKEN: ${{ secrets.NOTION_FILE_TOKEN }} + NOTION_SPACE_ID: ${{ secrets.NOTION_SPACE_ID }} + NODE_OPTIONS: "--max-http-header-size 15000" + + + - name: Upload to S3 + if: "${{ env.AWS_ACCESS_KEY_ID != '' }}" + run: | + aws s3 cp . s3://$AWS_S3_BUCKET_NAME/ --recursive --exclude "*" --include "*.zip" + + - name: Delete zips + if: "${{ env.AWS_ACCESS_KEY_ID == '' }}" + run: | + rm -f *.zip + rm -f markdown/*-Part*.zip + rm -f html/*-Part*.zip + + - name: Commit changes + if: "${{ env.AWS_ACCESS_KEY_ID == '' }}" + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git add . + git commit -m "Automated snapshot" + git push +``` From a8d8b88188104de9a77278e2c18b74898e2924ed Mon Sep 17 00:00:00 2001 From: LF Date: Mon, 24 Jul 2023 03:06:56 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 6872c2c..6b8b4ca 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,6 @@ jobs: NOTION_FILE_TOKEN: ${{ secrets.NOTION_FILE_TOKEN }} NOTION_SPACE_ID: ${{ secrets.NOTION_SPACE_ID }} NODE_OPTIONS: "--max-http-header-size 15000" - - name: Upload to S3 if: "${{ env.AWS_ACCESS_KEY_ID != '' }}" From d1bad92bfc85b92239f5062ee17632e54a89bb57 Mon Sep 17 00:00:00 2001 From: LF Date: Mon, 24 Jul 2023 03:27:09 +0800 Subject: [PATCH 3/3] Add aws s3 doc --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 6b8b4ca..6e861e2 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,9 @@ You won't be able to backup files exceeding a size of 100MB unless you enable [G ## AWS S3 Support Due to LFS storage constraints (batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.), we can't store the backup file on LFS. To solve this problem, you can store Notion export files on AWS S3. +Before using this workflow, please create an S3 bucket, an IAM User with Allow S3 PutObject policy(Please ref "AWS S3 IAM Policy" Section), and an IAM User Access key. After creating the S3 bucket and IAM User, add `AWS_S3_BUCKET_NAME`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_DEFAULT_REGION` to github Actions secrets and variables. +### Workflow file ```yaml name: "Notion backup" @@ -179,3 +181,22 @@ jobs: git commit -m "Automated snapshot" git push ``` +### AWS S3 IAM Policy +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "VisualEditor0", + "Effect": "Allow", + "Action": [ + "s3:PutObject" + ], + "Resource": [ + "arn:aws:s3:::", + "arn:aws:s3:::/*" + ] + } + ] +} +```