Jump to content

Evernote-Backup Windows Batch Files and Automation


Recommended Posts

Posted

I thought I'd do a little write-up to share how I automate Evernote-Backup. This is best used when combined with another backup utility that will backup your enex files each day or week or how ever often you export them, since they'll be overwritten, so you can go into your backup client of choice and retrieve an enex file from a specific point in time. For a very cheap, simple solution for Windows PCs I suggest Backblaze Computer Backup, it's from a really great company and it's $9 a month. For something a little more complex that allows you to bring your own storage or use your own cloud storage such as Google Drive or OneDrive, Arq Backup is a great tool.

First we need to download evernote-backup from Github. https://github.com/vzhd1701/evernote-backup/releases

Download the latest binary for Windows and unzip it. Please be aware that some antivirus software may consider this to be malware, this is a false positive. Evernote-Backup is safe. There is nothing to worry about, I would suggest creating a folder c:\evernote-backup and creating an antivirus exception for that folder, then placing the executable there.

With evernote-backup.exe placed in the folder we'll now need to open a Command Prompt and change directory to that folder, so we'll type: cd \evernote-backup then we are going to type evernote-backup init-db --oauth then simply follow the prompts to authenticate with Evernote in the browser window that will open.

Now open Notepad and paste in the following batch file, you may which to change some paths to match your system, the paths I used are just examples, you'll need to create these folders obviously. On that second export line the Notebooks folder is where your enex files will export to broken up by a folder for each stack then enex files within each stack/folder so you may want these in a different place on your system. You may also want en_backup.db which is the Evernote database to live somewhere else as well. This is all personal preference and can be customized.

evernote-backup sync -d C:\evernote-backup\en_backup.db
evernote-backup export C:\evernote-backup\Notebooks -d C:\evernote-backup\en_backup.db --overwrite
ping 127.0.0.1
taskkill /f /im evernote-backup.exe
exit

Save this batch file in c:\evernote-backup\evernote-backup-sync.bat

Now open Notepad again and paste in the following batch file:

evernote-backup reauth --oauth -d c:\evernote-backup\en_backup.db 
pause

Save this as c:\evernote-backup\evernote-backup-reauth.bat

This will be used annually to reauthenticate evernote-backup when the authentication expires.

I have one more batch file that replaces the first one. This allows for versioning of enex files. I don't personally use this myself so it isn't regularly tested but someone may find this useful:

setlocal

rem Get the current date in YYYY-MM-DD format using PowerShell
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format 'yyyy-MM-dd'"') do set date=%%i

evernote-backup sync -d C:\evernote-backup\en_backup.db
evernote-backup export C:\evernote-backup\%date%\Notebooks\ -d C:\evernote-backup\en_backup.db

ping 127.0.0.1
taskkill /f /im evernote-backup.exe
exit

This one can be used in place of evernote-backup-sync.bat and can be called for example evernote-backup-sync-with-date.bat and will create a dated folder for each export done allowing for versioning without any backup software needed.

Now for automation, for this we'll use task scheduler. Open Task Scheduler and click Create Task. Here are some screenshots to show what to do:

image.png.cc337cec79813c17c20e083816db326c.png

Use any interval you want, this is how I set mine:

image.png.23830672081606961b4f019eb82b3218.png

image.png.f8d785e8ec8e88ec07088af8dfbc34af.png

This is the hard part so I'm going to also show you what to type:

image.png.3b376dc4a9bcb67a192dd9629b9694c3.png

image.png.0fdf0b378f3c4112c73d916f739ee5f4.png

Program/script: c:\windows\system32\cmd.exe
Add arguments (optional): /c C:\evernote-backup\evernote-backup-sync.bat
Start in (optional): C:\Evernote-Backup

 

image.png.f020d4abea55130bf03c62fc9e6e1012.png

image.png.75e5fa0017c9e786c38ea06f4e6865f7.png

I hope this helps someone automate their backups!

 

For some tips on basic command line navigation see here: 

 

  • Like 1
  • Thanks 3
  • Level 5
Posted

Nice one, thanks (although as a Mac user, I can’t employ it).

One comment: Creating and saving the ENEX files daily makes little sense.The database from the backup utility is adding changed content only.

Once it’s converted to ENEX, it’s not updating incrementally any more. It won’t be overwritten with newer data.

The storage is very inefficient and consumes much more space. I advise against exporting to ENEX before it is necescary.

Posted

Fair enough, it could be done weekly or monthly. The scripts could be easily adapted to bash if you wanted. Instead of task scheduler just use cron.

Posted
2 hours ago, gazumped said:

Very nice - thanks!  :)

This could be added to your Evernote Tips series lol.

  • Like 1
Posted
12 hours ago, PinkElephant said:

Nice one, thanks (although as a Mac user, I can’t employ it).

If I ever get really bored, I'll write a guide to do this on my Mac Mini. 😉

Posted

Help me understand

This creates an SQL database.  I assume it is not intended that I access that directly for recovering data, but instead, I have to export the data using this utility as .enex files (one per notebook).

But when would an .enex file as a backup be useful?  For example, let's say Evernote.com can not be reached for a long time, and I have logged out.  Since login requires I access Evernote.com first, would I be able to somehow still read my enex files using Evernote without login in, or is there a next step that requires I import the enex files into another app that can do so?

Are there other scenarios where a backup is useful?

Thanks

  • Level 5
Posted

Options are to import into EN, or a number of other note apps.

ENEX has been the export / import format of EN since long. Many competing services accept ENEX as import format. It’s as close to an industry standard as it gets.

Posted
6 hours ago, Grant837 said:

But when would an .enex file as a backup be useful?  For example, let's say Evernote.com can not be reached for a long time, and I have logged out.  Since login requires I access Evernote.com first, would I be able to somehow still read my enex files using Evernote without login in, or is there a next step that requires I import the enex files into another app that can do so?

You might look at Joplin for the ability to read your ENEX files if Evernote becomes unavailable.  It is pretty fast -- a couple of hours for 9000 notes -- it can do all enex's from a stack at once if you want to group as you go or you can do all and just have a flat list of notebooks.  You can do just a few of your ENEX files if that is all you need in a pinch.  It will restore most internal links.  It is open source and content is kept locally.

Posted

Yarle can convert enex into markdown. Enex is human readable xml that can be parsed by many applications. 

Posted
5 hours ago, mackid1993 said:

Yarle can convert enex into markdown. Enex is human readable xml that can be parsed by many applications. 

True and it is quite flexible but you still have to move it to another application.  There are also issues with linking when the note titles have characters that don't work with the file system.  I was proposing that Joplin would probably be good quick way to see one's content if a recovery mode.

Choosing a migration destination is involved (and for me, I still come back to Evernote).

Posted
48 minutes ago, Dave Green said:

True and it is quite flexible but you still have to move it to another application.  There are also issues with linking when the note titles have characters that don't work with the file system.  I was proposing that Joplin would probably be good quick way to see one's content if a recovery mode.

Choosing a migration destination is involved (and for me, I still come back to Evernote).

I use it because the cloud is someone else's computer, trust your own computer with your own data in the end. 3-2-1 backups are important. Always have a second copy at least of anything you keep in the cloud.

  • Like 1
Posted
3 hours ago, mackid1993 said:

cloud is someone else's computer

Agree.  Joplin stores locally as well.

  • Like 1
Posted

Thanks all. I am aware of the many apps that can import .enex. 

I was more curious if maybe somehow Evernote could be used to view the backup files without logging in... that would be idea, since no export to another format works 100%, especially if you clip a lot from the web, link to other notes, attach and embed files, etc.

  • Level 5*
Posted

ENEX is (allegedly) modified XML - you could look at the content with one of the many online and offline viewers. 

And,  though I haven't tried it,  I wonder what happens if you try importing an ENEX file while offline?  Presumably if you're still logged in Evernote might import the files to view,  and you could delete them again before going back online...  No clue whether that would work,  and I don't have time to experiment at the moment.  If you try that,  let me know how you get on!

NB - DO NOT double click the ENEX file or the notes will be created in their original notebook - even if they also already exist there...  best option (I believe) is to create a test notebook and drag/ drop the ENEX file into it.

  • Like 1
Posted

FYI a Mac guide is going to be super advanced, it'll involve Homebrew, some bash scripting, terminal commands like chmod +x to make the scripts executable and then setting up a cronjob to automate. For me it's easy, for @PinkElephant easy, for most people it's probably not worth writing a guide.

  • Level 5
Posted

Actually I simply did what was described in the GitHub documentation for the Mac. Careful reading, implemented step by step. It wasn’t rocket science to establish, even while it was my first Homebrew install.

Posted
2 minutes ago, PinkElephant said:

Actually I simply did what was described in the GitHub documentation for the Mac. Careful reading, implemented step by step. It wasn’t rocket science to establish, even while it was my first Homebrew install.

No it isn't I was referring to automation with a bash script and setting it to run on a nightly or weekly cron job. That might be a lot for some people.

  • Level 5*
Posted

It has been a while, but I think I just used Automator to set that up.

i doubt it was intended, but you essentially insulted the Mac community here implying their competence level was unworthy of your time 🫤. I would suggest that the competence level of most of the regular users on this forum is quite high, though some may not be as vocal as others.

Posted
1 hour ago, s2sailor said:

It has been a while, but I think I just used Automator to set that up.

i doubt it was intended, but you essentially insulted the Mac community here implying their competence level was unworthy of your time 🫤. I would suggest that the competence level of most of the regular users on this forum is quite high, though some may not be as vocal as others.

No I was simply stating that terminal heavy work (essentially the way it would be done on Linux) which is the way I would do it on macOS isn't worthy of my time. If there are other ways, great. I'm primarily a Windows and Linux user, so that's my domain. When it comes to macOS it's just a walled garden shiny Linux distro to me with a zsh shell instead of bash. I think you misunderstood me.

Posted
3 hours ago, s2sailor said:

It has been a while, but I think I just used Automator to set that up.

i doubt it was intended, but you essentially insulted the Mac community here implying their competence level was unworthy of your time 🫤. I would suggest that the competence level of most of the regular users on this forum is quite high, though some may not be as vocal as others.

FYI I'm not a Mac user. I have a spare Mac lying around the house. I genuinely didn't need this remark today especially after taking the time to make a detailed guide to help people which at this point I'm done with because I've learned it ultimately backfires. Peace out. ✌️Taking a break from this place for a good while.

Posted

Trying to poke my head back in here a little. @bmcl26 reached out to me with a question. Just some basic command line guidance. First off don't do this stuff in Powershell, open a command prompt. Easiest thing is to type cmd into Windows search. Powershell has a more unix like syntax and isn't going to work with these simple batch files. Powershell has its own scripting language which is way more than we need for such a simple task.

To change drive letters for example he wanted to do everything on his F: drive you'd type F: into the prompt and hit enter and now you're on your F: drive.

To navigate to a directory you'd type cd /path/to/dir. So if your need to run evernote-backup.exe located in F:\evernote-backup you'd want to switch to the F: drive so type F: which will put you on the root of F: and then type  cd evernote-backup or an absolute path cd F:\evernote-backup to navigate to your F:\evernote-backup folder. You can also change directory and drive letter in one command cd /d F:\evernote-backup. The  /d switch tells the cd command to also switch drives. This can be done from any drive you want, I used C as an example.

Then type evernote-backup init-db --oauth which will run evernote-backup.exe and pass it the init-db command with the --oauth argument.

I also want to add that when typing a path or file into the command line, pressing the tab key will auto complete. Press it a few times to cycle between different paths or files close to what you've typed. 

  • Like 3
Posted

For any Mac users, someone has written a launchd plist that can be used for automation on a schedule, see here: https://github.com/vzhd1701/evernote-backup/discussions/64

If someone who is more of a regular Mac user than I am wants to mess with this, launchd would be the easiest way to automate on Mac since once you write the plist and load it, it's set and forget. They usually get dropped into ~/Library/Application Support/Launch Agents

@PinkElephant maybe you'd want to look into this.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...