Skip to content

Instantly share code, notes, and snippets.

@timpulver
Created April 15, 2013 08:12
Show Gist options
  • Save timpulver/5386620 to your computer and use it in GitHub Desktop.
Save timpulver/5386620 to your computer and use it in GitHub Desktop.
[Dayone, Backup Script] Creates a zipped backup of your Day One journal including all your photos. Journal will be exported as markdown-file, which can be edited in a plain text editor, and html.
#! /bin/bash
# dayonebac
# v.1.1
# Tim Pulver 2013
#
# dayonebac calls dayone_export, which needs to be installed, too.
# Download it from here: https://github.com/nathan11g/dayone_export
# place this file in /usr/local/bin and make it executable using
# chmod +x dayonebac
# The script will export your journal as a markdown- and html file
# together with your images as a zip archive.
# Edit your journal- and export paths below.
# Note that "~" cannot be used for the home-directory, use "$HOME" or the full path instead.
JOURNAL_PATH="$HOME/Library/Group Containers/5U8NS4GX82.dayoneapp/Data/Documents/Journal.dayone"
EXPORT_PATH="$HOME/bac/dayone"
DATE=$(date '+%Y-%m-%d')
TMP_DIR_NAME=".dayone_backup_tmp"
TMP_DIR=~
# create new folder + subfolders
mkdir -p "$TMP_DIR/$TMP_DIR_NAME"
cd "$TMP_DIR/$TMP_DIR_NAME"
# export html file
dayone_export --output journal.html "$JOURNAL_PATH"
# export markdown file
dayone_export --output journal.md "$JOURNAL_PATH"
# copy journal file
cp -r "$JOURNAL_PATH" .
# copy photo directory
cp -r "$JOURNAL_PATH/photos" .
# create zip-file
ZIP_FILENAME=dayone_bac_$DATE.zip
zip -r $ZIP_FILENAME *
# create export path if it does not exist already
mkdir -p "$EXPORT_PATH"
# move zip to backup folder
mv "./$ZIP_FILENAME" "$EXPORT_PATH"
# remove temp dir
cd "$TMP_DIR"
rm -r $TMP_DIR_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment