{"_id":"@eml-henn/notion-backup","_rev":"2-90b356095227f2a1eeb00bf9ea601ee9","name":"@eml-henn/notion-backup","dist-tags":{"latest":"1.4.3"},"versions":{"1.4.1":{"name":"@eml-henn/notion-backup","version":"1.4.1","author":{"name":"Robin Berjon","email":"robin@berjon.com"},"license":"MIT","_id":"@eml-henn/notion-backup@1.4.1","maintainers":[{"name":"eml-henn","email":"emiliano.lupo@henn.com"}],"homepage":"https://github.com/darobin/notion-backup","bugs":{"url":"https://github.com/darobin/notion-backup/issues"},"bin":{"notion-backup":"notion-backup.js","notion-backup-item":"notion-backup-item.js"},"dist":{"shasum":"ae46e87ec23a17ff7a02c9577d0b93fe47b66bd6","tarball":"https://registry.npmjs.org/@eml-henn/notion-backup/-/notion-backup-1.4.1.tgz","fileCount":6,"integrity":"sha512-cqCeCe5stpl6nsrNMMoczF1Lq57aQRFhtA5FjASSxTFcIT9JRqHm0AvZdlgZ0nCo6W2DmTIsfAU89r/RWZ6uEQ==","signatures":[{"sig":"MEYCIQC3lUISdImC9M09upzwiyIMn6I1LYqe9vXpW52INeijLQIhAMkQFt3HDpdHBoXFMxbvm6nMTMqVR5Mx9xkPBsLXcbtP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18195},"main":"./notion-backup.js","gitHead":"38d536ed29facdb5349030e5b16c445ba0d3b334","_npmUser":{"name":"eml-henn","email":"emiliano.lupo@henn.com"},"repository":{"url":"git+https://github.com/eml-henn/notion-backup.git","type":"git"},"_npmVersion":"9.3.1","description":"Notion exporter meant to be used as part of a GitHub workflow, forked from original from github darobin","directories":{},"_nodeVersion":"18.13.0","dependencies":{"async":"^3.2.4","axios":"^0.21.1","commander":"^7.2.0","extract-zip":"^2.0.1","notion-utils":"^4.5.2","notion-client":"^4.5.2"},"eslintConfig":{"extends":"robin"},"_hasShrinkwrap":false,"devDependencies":{"eslint-config-robin":"^6.1.3"},"_npmOperationalInternal":{"tmp":"tmp/notion-backup_1.4.1_1734352555662_0.1824218818382526","host":"s3://npm-registry-packages-npm-production"}},"1.4.2":{"name":"@eml-henn/notion-backup","version":"1.4.2","author":{"name":"Robin Berjon","email":"robin@berjon.com"},"license":"MIT","_id":"@eml-henn/notion-backup@1.4.2","maintainers":[{"name":"eml-henn","email":"emiliano.lupo@henn.com"}],"homepage":"https://github.com/darobin/notion-backup","bugs":{"url":"https://github.com/darobin/notion-backup/issues"},"bin":{"notion-backup":"notion-backup.js","notion-backup-item":"notion-backup-item.js"},"dist":{"shasum":"adbf505f3769451c74f88cf203180468a7c6dbd5","tarball":"https://registry.npmjs.org/@eml-henn/notion-backup/-/notion-backup-1.4.2.tgz","fileCount":7,"integrity":"sha512-e/qss5KFX6oc6dlQSjPTj2LoIP6TY0GQSS/0G9X5UHH8Tm9EDdtHFXu5FZppUzgyO7/wQNd8+3wb/g1WwpXr+w==","signatures":[{"sig":"MEUCIQCGTUpaZzUZLuZY/g4dkRkpXNMKrLMm9rDQuGEM7uVjdgIgNCkB4vxIH6ld/X/W9H6x4bWBya5VIzlLeQZQAKBXgPg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20898},"main":"./notion-backup.js","gitHead":"9c2b325e27ec6eef5b399e1bd449786df66558eb","_npmUser":{"name":"eml-henn","email":"emiliano.lupo@henn.com"},"repository":{"url":"git+https://github.com/eml-henn/notion-backup.git","type":"git"},"_npmVersion":"9.3.1","description":"Notion exporter meant to be used as part of a GitHub workflow, forked from original from github darobin","directories":{},"_nodeVersion":"18.13.0","dependencies":{"async":"^3.2.4","axios":"^0.21.1","commander":"^7.2.0","extract-zip":"^2.0.1","notion-utils":"^4.5.2","notion-client":"^4.5.2"},"eslintConfig":{"extends":"robin"},"_hasShrinkwrap":false,"devDependencies":{"eslint-config-robin":"^6.1.3"},"_npmOperationalInternal":{"tmp":"tmp/notion-backup_1.4.2_1740055349927_0.3119129394314857","host":"s3://npm-registry-packages-npm-production"}},"1.4.3":{"name":"@eml-henn/notion-backup","version":"1.4.3","description":"Notion exporter meant to be used as part of a GitHub workflow, forked from original from github darobin","main":"./notion-backup.js","bin":{"notion-backup":"notion-backup.js","notion-backup-item":"notion-backup-item.js"},"repository":{"type":"git","url":"git+https://github.com/eml-henn/notion-backup.git"},"eslintConfig":{"extends":"robin"},"author":{"name":"Robin Berjon","email":"robin@berjon.com"},"license":"MIT","bugs":{"url":"https://github.com/darobin/notion-backup/issues"},"homepage":"https://github.com/darobin/notion-backup","devDependencies":{"eslint-config-robin":"^6.1.3"},"dependencies":{"async":"^3.2.4","axios":"^0.21.1","commander":"^7.2.0","extract-zip":"^2.0.1","notion-client":"^4.5.2","notion-utils":"^4.5.2"},"gitHead":"a79938c1633c9e36b1ebdaa67b897cdda501cb2a","_id":"@eml-henn/notion-backup@1.4.3","_nodeVersion":"18.13.0","_npmVersion":"9.3.1","dist":{"integrity":"sha512-A1MWFM+GoXkfO7S2SHUVzKrOANfq9LC0UyQtShtbHXADOxXk4h2FgE/YguZeSpbdX3aph/D5QhdCKbUr3E2AVg==","shasum":"a75b4bd6eb944d47f86e023c15a2f215c46a07b9","tarball":"https://registry.npmjs.org/@eml-henn/notion-backup/-/notion-backup-1.4.3.tgz","fileCount":7,"unpackedSize":21152,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCxGGZ+8CLrntBrDbr7U0COoudxYD00LHVj0KwSqoTeXgIgUV6+EHHcfGHnAOok3UpjeIFJP3iCujym6xWMvz46mk8="}]},"_npmUser":{"name":"eml-henn","email":"emiliano.lupo@henn.com"},"directories":{},"maintainers":[{"name":"eml-henn","email":"emiliano.lupo@henn.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/notion-backup_1.4.3_1740056563918_0.6690154682869094"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-16T12:35:55.545Z","modified":"2025-02-20T13:02:44.324Z","1.4.1":"2024-12-16T12:35:55.801Z","1.4.2":"2025-02-20T12:42:30.111Z","1.4.3":"2025-02-20T13:02:44.145Z"},"bugs":{"url":"https://github.com/darobin/notion-backup/issues"},"author":{"name":"Robin Berjon","email":"robin@berjon.com"},"license":"MIT","homepage":"https://github.com/darobin/notion-backup","repository":{"type":"git","url":"git+https://github.com/eml-henn/notion-backup.git"},"description":"Notion exporter meant to be used as part of a GitHub workflow, forked from original from github darobin","maintainers":[{"name":"eml-henn","email":"emiliano.lupo@henn.com"}],"readme":"## fork of the original package from darobin, see below ##\r\n\r\nthis only exports html.\r\n\r\n\r\n**⚠️⚠️⚠️ I am no longer maintaining this. ⚠️⚠️⚠️** I stopped using Notion, I don't like the direction that the product is headed in\r\nand I got tired of having to constantly fight the API just to get my own data back. I have switched to Obsidian and don't plan on\r\nlooking back. You may, of course, still use this tool but I am not actively maintaining it. I will review PRs, slowly.\r\n\r\nIf someone with credible experience wants to take it over, please let me know.\r\n\r\n# notion-backup\r\n\r\nThis is a very simple tool to export a workspace from [Notion](https://www.notion.so/), designed\r\nto work as part of a GitHub workflow.\r\n\r\nIt reads `NOTION_TOKEN` and `NOTION_SPACE_ID` from the environment, and outputs the export to both\r\n`html` and `markdown` directories in the current working directory, as well as to `html.zip` and\r\n`markdown.zip`.\r\n\r\n## Obtaining tokens\r\n\r\nAutomatically downloading backups from Notion requires two unique authentication tokens and your individual space ID which must be obtained for the script to work.\r\n\r\n1. Log into your Notion account in your browser of choice if you haven't done so already.\r\n2. Open a new tab in your browser and open the development tools. This is usually easiest done by right-click and selecting `Inspect Element` (Chrome, Edge, Safari) or `Inspect` (Firefox). Switch to the Network tab.\r\n3. Open https://notion.so/f/. You must use this specific subdirectory to obtain the right cookies.\r\n4. Insert `getSpaces` into the search filter of the Network tab. This should give you one result. Click on it.\r\n5. In the Preview tab, look for the key `space`. There you should find a list of all the workspaces you have access to. Unless you're part of shared workspaces there should only be one.\r\n6. Copy the UUID of the workspace you want to backup (e.g. `6e560115-7a65-4f65-bb04-1825b43748f1`). This is your `NOTION_SPACE_ID`.\r\n6. Switch to the Application (Chrome, Edge) or Storage (Firefox, Safari) tab on the top.\r\n7. In the left sidebar, select `Cookies` -> `https://www.notion.so` (Chrome, Edge, Firefox) or `Cookies – https://www.notion.so` (Safari).\r\n8. Copy the value of `token_v2` as your `NOTION_TOKEN` and the value of `file_token` as your `NOTION_FILE_TOKEN`.\r\n9. Set the three environment variables as secrets for actions in your GitHub repository.\r\n\r\n**NOTE**: if you log out of your account or your session expires naturally, the `NOTION_TOKEN` and `NOTION_FILE_TOKEN` will get invalidated and the backup will fail. In this case you need to obtain new tokens by repeating this process. There is currently no practical way to automize this until Notion decide to add a backup endpoint to their official API, at which point this script will be able to use a proper authentication token.\r\n\r\n## Setup\r\n\r\nThis assumes you are looking to set this up to back up Notion to GitHub.\r\n\r\n1. Obtain the required values for the environment variables as explained above.\r\n2. Create a repo for your backup. You probably want it private.\r\n3. Set the `NOTION_TOKEN`, `NOTION_FILE_TOKEN` and `NOTION_SPACE_ID` environment variables as secrets in your GitHub repo.\r\n4. Give Actions write access to your repository: `Settings` > `Actions` > `General` > `Workflow permissions` > choose `Read and write permissions`\r\n5. Install the following under `.github/workflows/whatever.yml` in your repo.\r\n6. Configure the frequency by changing the `cron` value. You can use [Crontab.guru](https://crontab.guru/#0_*/4_*_*_*).\r\n7. Push and control your backup workflow from the `Actions` tab of your repository Github page.\r\n\r\n```yaml\r\nname: \"Notion backup\"\r\n\r\non:\r\n  push:\r\n    branches:\r\n      - master\r\n  schedule:\r\n    -   cron: \"0 */4 * * *\"\r\n\r\n  # Allows you to run this workflow manually from the Actions tab\r\n  workflow_dispatch:\r\n\r\njobs:\r\n  backup:\r\n    runs-on: ubuntu-latest\r\n    name: Backup\r\n    timeout-minutes: 15\r\n    steps:\r\n      - uses: actions/checkout@v3\r\n\r\n      - uses: actions/setup-node@v2\r\n        with:\r\n          node-version: '18'\r\n\r\n      - name: Delete previous backup\r\n        run: rm -rf markdown html *.zip\r\n\r\n      - name: Setup dependencies\r\n        run: npm install -g notion-backup\r\n\r\n      - name: Run backup\r\n        run: notion-backup\r\n        env:\r\n          NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}\r\n          NOTION_FILE_TOKEN: ${{ secrets.NOTION_FILE_TOKEN }}\r\n          NOTION_SPACE_ID: ${{ secrets.NOTION_SPACE_ID }}\r\n          NODE_OPTIONS: \"--max-http-header-size 15000\"\r\n\r\n      - name: Delete zips\r\n        run: |\r\n          rm -f *.zip\r\n          rm -f markdown/*-Part*.zip\r\n          rm -f html/*-Part*.zip\r\n\r\n      - name: Commit changes\r\n        run: |\r\n          git config user.name github-actions\r\n          git config user.email github-actions@github.com\r\n          git add .\r\n          git commit -m \"Automated snapshot\"\r\n          git push\r\n```\r\n\r\n## LFS Support\r\n\r\nYou won't be able to backup files exceeding a size of 100MB unless you enable [Git LFS](https://git-lfs.github.com/). Add a file named `.gitattributes` at the root of your repository and add the following. If you want to support other file types, just add a new line for that file type.\r\n\r\n```\r\n*.zip filter=lfs diff=lfs merge=lfs -text\r\n*.png filter=lfs diff=lfs merge=lfs -text\r\n*.jpg filter=lfs diff=lfs merge=lfs -text\r\n*.jpeg filter=lfs diff=lfs merge=lfs -text\r\n*.psd filter=lfs diff=lfs merge=lfs -text\r\n```\r\n","readmeFilename":"README.md"}