Home / GitHub Page

Best method to backup notes


#1

We use Evernote at work, and I’ve been using it personally as well. As part of researching Joplin as a replacement for work i’m going to use it personally for the next month or so. I have it syncing to Nextcloud running on a personal server.
Currently trying without encryption.
I exported my notebook from Evernote, and imported it, and that all looks good. I see my directory is filled with .md files now, and the pictures are in .resource on the sync target as well.
I was experimenting with how best to automate backups and what I tried doing was using Nextcloud to sync the target directory to a computer. This gives me all of the .md files somewhere else. I then tried importing the “md directory” which works in importing, but all of the notes are the filenames of the .md files. Not really sure what the original note name.
So, I thought, “What’s the best way to back up Joplin?”
Anyone else?


#2

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.


#3

Thank you for your reply Laurent.

I tried something: Nextcloud has my ‘joplin’ target directory in it, and is synced to computer A. I created a new directory in Nextcloud called ‘testjoplin’. I copied the contents of the ‘joplin’ directory to the ‘testjoplin’ directory, hidden directories included. Then on Computer B I clean installed Joplin, and pointed it at Nextcloud…/testjoplin

It then synced and everything looked just like it should. I have a computer that’s always on, and is syncing Nextcloud, and that directory is getting backed up with versioning. I think this will suffice for me.
The other thing I played with was using Nextcloud’s versioning to restore an individual .md to a previous version. This did not work as expected. Joplin on Windows desktop will keep showing the note as it last was, but using the text viewer on Nextcloud shows that .md file as being a previous version. I’m probably just missing something.


#4

Yes that doesn’t work because when you restore an earlier version it will have a timestamp that’s earlier than the one that’s on your computer. So Joplin compares the versions, see that the one on your computer is more recent and therefore keeps this one.

There’s no simple way to restore just one note from sync at the moment unfortunately. You would need to do it manually - i.e. restore the note, copy the body, and paste it in the note on your computer.


#5

fair enough. Figure if it’s bad enough I need an older version it’s either a one time thing where copy/paste would suffice, or i’m redoing the entire directory in which case my previous test works too.