Best method to backup notes

Best way, if you can, is to use the command line tool along with the export command and export at a regular intervals from a cron script. Even better if you can version this in a Git repository.

This is the cron script I use for backup:

#!/bin/bash

# 0 0 10,15/12 * * /home/laurent/scripts/joplin_bak.sh >> /var/log/joplin_bak.log 2>&1

BACKUP_DIR="/path/to/backup_dir"
JOPLIN_BIN="$HOME/.npm-global/bin/joplin"

$JOPLIN_BIN sync
$JOPLIN_BIN e2ee decrypt

cd "$BACKUP_DIR"
rm -f *.md
rm -f resources/*
$JOPLIN_BIN --log-level debug export --format raw "$BACKUP_DIR"
git add .
git commit -m "Update"

I have this running because I often run dev versions of Joplin so I need a robust backup in case I mess up, but for normal use a simple export to JEX format is sufficient. Unlike the ENEX format, JEX is a lossless format so you can export and re-import and get everything back including tags, resources, notebooks, and all metadata.

An alternative to all this is indeed to backup the sync directory. That might be easier to automate and Nextcloud should also keep a history so you get benefits similar to using Git.

8 Likes