Backing up vimwiki with rsync

I use vimwiki to take notes and keep a todo list. Vimwiki stores every page as a separate markdown file in whatever directory you tell it to use. For a long time, my backup strategy for my vimwiki files was Dropbox. Dropbox always seemed like a heavy-handed solution for essentially a dozen text files and I’ve wanted to switch to something simpler for a while. Dropbox is not an approved piece of software at my new job, so that also accelerated my search for a new backup solution.

I ended up using rsync with a raspberry pi I keep running 24/7. Because rsync needs to be manually triggered, there’s a bunch of additional tools out there that essentially watch your files for changes and then trigger rsync. Instead of that, I added this to my vimrc:

    " after saving anything in ~/vimwiki, sync to rpi for backup
    au! BufWritePost ~/vimwiki/* silent
      \ execute "!rsync -avz ~/vimwiki/ des-pi:/home/des/vimwiki" |
      \ redraw!
    

In english, whenever a file in my vimwiki directory is written to, it’ll run rsync. This sends my changes to the rpi as soon as I hit save.

More posts