Today I’ve created a small Apple Script to export all my Evernote notes into a folder and compress the notes to a tar.gz archive for storing on my NAS. Feel free to use this script and customize for your own environment.
[UPDATE] Fixed an issued causing the export to fail if empty notebooks are present. Thanks to Darryl for the solution in the comments.
(* ####################################################################### ## (C) 2015 Michael Miklis (michaelmiklis.de) ## ## ## Filename: Backup-Evernote.scpt ## ## Version: 1.0 ## ## Release: Final ## ## Requirements: -none- ## ## Description: Export all Evernote note into tar.gz file ## ## This script is provided 'AS-IS'. The author does not provide ## any guarantee or warranty, stated or implied. Use at your own ## risk. You are free to reproduce, copy & modify the code, but ## please give the author credit. ## ####################################################################*) set archivePath to "/Users/michael/Desktop" set userName to "myuser@domain.com" with timeout of (30 * 60) seconds tell application "Evernote" set exportPath to archivePath & "/" & userName set allNotebooks to every notebook repeat with currentNoteBook in allNotebooks set notebookName to (the name of currentNoteBook) set allNotes to every note in notebook notebookName set exportFolder to exportPath & "/" & notebookName do shell script "if [ ! -e '" & exportFolder & "' ]; then mkdir -p '" & exportFolder & "'; fi;" set exportFile to exportFolder & ".enex" if (length of allNotes > 0) then export allNotes to exportFolder format HTML export allNotes to exportFile format ENEX end if end repeat end tell end timeout set currentTimestamp to do shell script "date +%Y-%m-%d_%H-%M-%S" set archiveFile to archivePath & "/" & currentTimestamp & "_" & userName & ".tar.gz" log archiveFile do shell script "tar -cvzf '" & archiveFile & "' '" & exportPath & "'" tell application "Finder" do shell script "rm -rf '" & exportPath & "'" end tell tell application "Finder" mount volume "afp://mynas.domain.local/Backup/Evernote" do shell script "cp '" & archiveFile & "' '/Volumes/Evernote'" do shell script "umount '/Volumes/Evernote'" end tell display dialog "Backup completed" buttons {"Ok"} default button "Ok"
it exports only the same three notebooks every time, i wonder why. I have 24 notebooks.
Hello Ryan,
that’s a good question. I don’t have an answer to this – I also have several notebooks and all are exported without problems. Maybe your notebooks contain some special characters that will make problems as each notebook will be created as a dedicated folder. Are the exported three notebooks are the first in an alphabetical sequence?
with kind regards
Michael
Ryan,
You may have empty Notebooks. The script fails if it hits an empty Notebook. If that is the case, adding the following check around the export lines should do the trick. The script will create empty backup folders for empty Notebooks, which I like, as I know it didn’t miss that Notebooks for some reason.
if (length of allNotes > 0) then
export allNotes to exportFolder format HTML
export allNotes to exportFile format ENEX
end if
Michael: Thanks for the script.
That’s cleared my thoughts. Thanks for cotnuibrting.
Thank you for the script! I’ve been searching for Evernote backup solution on Mac for a long time (there are bunch of them on Windows, like Backupery, but no robust solution for Mac). The script works as expected on my El Capitan.