Never Lose Your Joplin Notes Again: Automatic GitHub Backups

2:40 PM


If you’ve ever had Joplin’s sync fail or lost your local backup, you know the panic. This guide shows you how to safeguard your notes with a simple script that backs them up to GitHub automatically every day.

Recently, I got myself into a pickle: I lost my local Joplin backup at the exact same time the built-in sync started glitching. The mess started after I formatted my PC and realized my cloud backup had skipped over the Joplin directory entirely. Getting that data back without an official backup was a nightmare I never want to repeat.

That’s when I had the idea: why not create a simple script to back up Joplin to GitHub automatically every day? GitHub is far more reliable and less prone to failure than most backup methods. This way, I’d have version control, safe storage, and peace of mind—without relying solely on Joplin’s built-in sync.

This is how you do it:


Packages

  • github
  • systemd
  • joplin
  • 7zip


GitHub Setup

1. Initialize Git inside a NEW, empty Joplin backup folder

cd ~/path/to/new-joplin-backup

git init


2. Add a remote pointing to your GitHub repo

git remote add origin https://github.com/USERNAME/REPO-NAME.git


3. Stage all files for commit

git add .


4. Make your first commit

git commit -m "Initial Joplin backup"


5. Push to GitHub

git branch -M main

git push -u origin main

 


BASH Script for Joplin Backup to GitHub

1. Create the Script

Save the following in your local GitHub repo directory as joplin-backup.sh:


#!/bin/bash

# Compress the Joplin backup directory into a split archive

7z a -t7z /path/to/new-joplin-backup/output/folder/backup.7z /path/to/old-joplin-backup/folder -v25m


# Stage and commit the split archive files

git add /path/to/new-joplin-backup/output/folder/backup.7z.*

git commit -m "Joplin backup $(date +%F)"


# Push changes to the GitHub repo

git push origin main


# Clean up the local split archives (optional)

rm -rf /path/to/new-joplin-backup/output/folder/backup.7z.* 


2. Replace the Placeholders

/path/to/old-joplin-backup/folder → the folder where Joplin exports its backups


/path/to/new-joplin-backup/output/folder → a working folder inside your Git repo (example: /home/username/joplin-github-backup)


main → the branch name of your GitHub repo (default is main, but use master if that’s your setup)


3. Make the Script Executable

chmod +x joplin-backup.sh


4. Run It Manually

From the repo folder:


./joplin-backup.sh

or

bash ./joplin-backup.sh 

 

Make sure it runs successfully before  moving to the next step. 


5. Create a systemd Service

Create a unit file at:

~/.config/systemd/user/joplin-backup.service


[Unit]

Description=Joplin daily GitHub backup


[Service]

Type=oneshot

ExecStart=/path/to/joplin-backup.sh

WorkingDirectory=/path/to/repo


ExecStart → full path to your script


WorkingDirectory → the Git repo folder


6. Create a systemd Timer

Create a timer file at:

~/.config/systemd/user/joplin-backup.timer


[Unit]

Description=Run Joplin backup daily


[Timer]

OnCalendar=daily

Persistent=true


[Install]

WantedBy=timers.target


7. Enable and Start the Timer

Reload user services and enable the timer:


systemctl --user daemon-reload

systemctl --user enable joplin-backup.timer

systemctl --user start joplin-backup.timer


8. Verify It Works

Check timer status:


systemctl --user list-timers


Check logs:


journalctl --user -u joplin-backup.service

 


How It Works

  • 7z Compression: Archives your Joplin backups and splits them into 25 MB chunks for Git-friendly storage.
  • Git Commit & Push: Adds the split files, commits with today’s date, and pushes to GitHub.
  • Cleanup: Removes local chunks so they don’t clutter your disk (GitHub will keep them). 



Restoring Your Notes from GitHub

1. If you ever need to recover your Joplin backup from GitHub, clone your repo (or pull the latest changes if you already have it):

git clone https://github.com/USERNAME/REPO-NAME.git

cd REPO-NAME/output/folder


2. Recombine and extract the backup archive:

7z x backup.7z.001


3. Copy the restored Joplin export folder back into Joplin’s backup/import directory, then use Joplin’s import function to bring your notes back.


That’s it — your notes are restored.



Wrap Up

With this setup, you now have:

  • Daily automated Joplin backups stored safely in GitHub.

  • Version control to roll back if something goes wrong.

  • A simple restore path when you need your data back.

By testing the script manually first and then letting systemd handle automation, you’ve made your notes nearly disaster-proof. Now I can finally sleep easier knowing my notes won’t just vanish on me again. 🙂

You Might Also Like

0 comments