├── LICENSE └── .github └── workflows └── run_backup.yml /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Vladyslav Sitalo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/run_backup.yml: -------------------------------------------------------------------------------- 1 | name: "Roam Research backup" 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: "*/10 * * * *" #doesn't actually consistently run every 10 min =\ 10 | 11 | jobs: 12 | backup: 13 | #runs-on: "Ubuntu-20.04" # trying to workaound random crashes on linux 14 | runs-on: ubuntu-latest 15 | name: Backup 16 | timeout-minutes: 15 17 | steps: 18 | - name: Checkout notes repo 19 | uses: actions/checkout@v3.5.2 20 | with: 21 | repository: ${{ secrets.targetRepo }} 22 | token: ${{ secrets.roamPat }} 23 | - name: Set up Python 3.8 24 | uses: actions/setup-python@v4.6.0 25 | with: 26 | python-version: 3.8 27 | 28 | - name: Setup dependencies 29 | run: | 30 | #wget -qO /tmp/jet.zip https://github.com/borkdude/jet/releases/download/v0.0.13/jet-0.0.13-linux-amd64.zip 31 | #unzip /tmp/jet.zip -d /tmp 32 | #sudo mv /tmp/jet /usr/local/bin/jet 33 | # https://github.com/MatthieuBizien/roam-to-git/pull/112 34 | pip install "git+https://github.com/Stvad/roam-to-git" 35 | # removing as it logs sensetive information 36 | # - name: Download markdown images for previous backup 37 | # not commiting the changes to md files with this =\, should be possible to recover things by deconding the base64 of file names 38 | # run: npx markdown-backup "markdown/**/*.md" 39 | - name: Run backup 40 | run: | 41 | roam-to-git . --skip-git --formats json #edn #markdown 42 | # no markdown for now bc I have page names that are too long and that crashes the backup 43 | # disabling edn to try to speed up git push 44 | env: 45 | ROAMRESEARCH_USER: ${{ secrets.roamEmail }} 46 | ROAMRESEARCH_PASSWORD: ${{ secrets.roamPassword }} 47 | ROAMRESEARCH_DATABASE: ${{ secrets.roamDatabase }} 48 | - name: Split in chunks 49 | run: input="json/stvad.json"; split_size=1000; seq 0 $split_size $(jq length $input) | xargs -I{} sh -c "jq '.[{}:({}+$split_size)]' $input > json/stvad_{}.json" && rm json/stvad.json 50 | - name: git things 51 | run: git add . && git -c user.name="Vlad (via github actions)" -c user.email="vlad@sitalo.org" commit -m "automated snapshot" && git push 52 | 53 | 54 | --------------------------------------------------------------------------------