Skip to content

Instantly share code, notes, and snippets.

@AlexAtkinson
Last active April 4, 2024 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexAtkinson/5c828d0852c391527ebf3d8f7721cda9 to your computer and use it in GitHub Desktop.
Save AlexAtkinson/5c828d0852c391527ebf3d8f7721cda9 to your computer and use it in GitHub Desktop.
Free Evernote Alternative

Evernote Icon Evernote Alternative - Obsidian Evernote Icon

This is my free Evernote alternative.

Tech Stack

There are three components of this solution: the note taking app, cloud-sync utility, and the optional cloud storage.

NOTE: If you don't need more than 2GB of cloud storage, you can get away with simply putting the vault in Dropbox and accessing from all your devices. NO NEED FOR SYNCTHING. Otherwise, read on.

Diagram

Note that this diagram represents my use-case with pCloud as the cloud storage provider. If you're using Dropbox, then just use that on both your mobile and desktop, storing the vaults within.

+-------------------+      +-----------------------+
|                   |      |                       |
|   Mobile Device   |      |         Linux         |
|                   |      | +-------------------+ |
|                   |      | |   Cloud Storage   | |
|  +-------------+  |      | |  +-------------+  | |
|  |             |  |      | |  |             |  | |
|  |   Obsidian  |  |      | |  |   Obsidian  |  | |
|  |    Vault    |  |      | |  |    Vault    |  | |
|  |             |  |      | |  |             |  | |
|  +---^-----+---+  |      | |  +---^-----+---+  | |
|      |     |      |      | |      |     |      | |
|      |     |      |      | +------+-----+------+ |
|      |     |      |      |        |     |        |
|  +---+-----v---+  |      |    +---+-----v---+    |
|  |             +--+------+---->             |    |
|  |  Syncthing  |  |      |    |  Syncthing  |    |
|  |             <--+------+----+             |    |
|  +-------------+  |      |    +-------------+    |
|                   |      |                       |
+-------------------+      +-----------------------+

Note Taking Application

Obsidian - It's free and has a "vaults" concept that allows the notes to be stored on the file system.

Cloud-Sync

Syncthing - An awesome app that sync's things.

Cloud Storage (Optional)

This is entirely optional.

Any free cloud storage service that provides a mount point on your file system.

  • Dropbox Basic - free 2GB.
    • 💡 You don't need syncthing if this is the case. Just store your vault here on both your desktop and mobile.
  • pCloud - While not free, they offer a lifetime subscription at a reasonable price.
    • ⚠️ This is awesome only as long as the company stays in business.
  • s3fs - Use your own s3 bucket. Untested. Freeish.

Note that the pCloud mobile app does not provide a mount point on the fs, but the linux version does, which is how syncthing is able to sync the Obsidian Vault to/from the cloud storage.

Backups

If you would like a multi-cloud backup posture, the following cronjob will do it for you.

💡 This could be reduced to just a few lines, but this how I setup all my localhost shell scripts.

#!/usr/bin/env bash
# backup_obsidian.sh
# ----------------------------------------------------------------------------------------------------------------------
# Crontab Example:
#    0 */6 * * * /bin/bash -c '~/crons/backup_obsidian.sh'

# ----------------------------------------------------------------------------------------------------------------------
# Variables
# ----------------------------------------------------------------------------------------------------------------------

THIS_SCRIPT="${0##*/}"
RC_LOG="true"
[[ "$RC_LOG" == "true" ]] && LOG_FILE="${THIS_SCRIPT}.log"
IFS_BAK=$IFS
PARENT_DIR_PATH="${PWD%/*}"
PARENT_DIR_NAME="${PARENT_DIR_PATH##*/}"

TMP_DIR="$(mktemp -d)"

BACKUP_FILE="obsidian.$(date --utc +"%FT%H-%M-%SZ").tar.gz"
BACKUP_TARGET='~/pCloudDrive/apps/Obsidian'
BACKUP_DESTINATION='~/Dropbox/backups/obsidian'

# ----------------------------------------------------------------------------------------------------------------------
# Functions
# ----------------------------------------------------------------------------------------------------------------------

# This function enables syslog style error code handling with colors.
#   Named loggerx so as to avoid clobbering logger if present.
#   Note: There is no 9th severity level in RFC5424.
function loggerx() {
  [[ $1 -eq 0 ]] && echo -e "$(date --utc +"%FT%T.%3NZ") - \e[01;30;41mEMERGENCY\e[0m: ${*:2}"
  [[ $1 -eq 1 ]] && echo -e "$(date --utc +"%FT%T.%3NZ") - \e[01;31;43mALERT\e[0m: ${*:2}"
  [[ $1 -eq 2 ]] && echo -e "$(date --utc +"%FT%T.%3NZ") - \e[01;97;41mCRITICAL\e[0m: ${*:2}"
  [[ $1 -eq 3 ]] && echo -e "$(date --utc +"%FT%T.%3NZ") - \e[01;31mERROR\e[0m: ${*:2}"
  [[ $1 -eq 4 ]] && echo -e "$(date --utc +"%FT%T.%3NZ") - \e[01;33mWARNING\e[0m: ${*:2}"
  [[ $1 -eq 5 ]] && echo -e "$(date --utc +"%FT%T.%3NZ") - \e[01;30;107mNOTICE\e[0m: ${*:2}"
  [[ $1 -eq 6 ]] && echo -e "$(date --utc +"%FT%T.%3NZ") - \e[01;39mINFO\e[0m: ${*:2}"
  [[ $1 -eq 7 ]] && echo -e "$(date --utc +"%FT%T.%3NZ") - \e[01;97;46mDEBUG\e[0m: ${*:2}"
  [[ $1 -eq 9 ]] && echo -e "$(date --utc +"%FT%T.%3NZ") - \e[01;32mSUCCESS\e[0m: ${*:2}"
}

function et() { loggerx 5 "TASK START: $task..."; }

function rc_handler() {
  if [[ $1 -eq $2 ]] ; then
    loggerx 9 "$task."
  else
    loggerx 3 "$task - exit code $2"
    exit 1
  fi
}

function rc() {
  result=$?
  if [[ "$RC_LOG" == "true" ]]; then
    rc_handler "$1" "$result" | tee -a "$LOG_FILE"
  else
    rc_handler "$1" "$result"
  fi
}

# ----------------------------------------------------------------------------------------------------------------------
# Main Operations
# ----------------------------------------------------------------------------------------------------------------------

task="Compact Obsidian Directory"; et
tar -zcvf "$TMP_DIR/$BACKUP_FILE" "$BACKUP_TARGET"; rc 0

task="Copy Obsidian Backup to Dropbox"; et
cp "$TMP_DIR/$BACKUP_FILE" "$BACKUP_DESTINATION"; rc 0

# Double check.
task="Verify Obsidian Backup"; et
test -f "$BACKUP_DESTINATION/$BACKUP_FILE"; rc 0

task="Remove Backup File"; et
rm -f "$TMP_DIR/$BACKUP_FILE"; rc 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment