Automatically Back Up Your Notes To GitHub

github mark - Automatically Back Up Your Notes To GitHub

If you often taking note like me, you wanna backup your notes. I thought this subject and I wrote Bash Script about this subject. This blog include “Automatically Back Up Your Boostnote Notes To GitHub” subject.(I am using Ubuntu 19.04 OS, that’s mean maybe script is not work your system so don’t forget configure script according to yourself 🙂 ).

I was uploaded a video on YouTube, You can follow steps on video.

Prerequisites

  • Git

  • ssh client
  • autonote.sh script from Eredot_PK&FR (https://github.com/eredotpkfr/autonote.sh)

If you have completed the prerequisites, read the following lines 🙂

Configuration

Firstly we should create SSH Public and Private Key, because GitHub ask password and username when pushing files so we create SSH Public and Private Key this step is very easy 🙂 just enter following command.

NOTE: Choose encryption algorithm with -t option.

Screenshot from 2019 05 13 15 16 44 300x183 - Automatically Back Up Your Notes To GitHub

id_rsa is your Private Key and id_rsa.pub is your Public Key, We created Public and Private Key,  now copy id_rsa.pub’s content and go to your GitHub account and open Settings > SSH and GPG Keys > New SSH Key and paste it then save it.

NOTE: SSH ask you passphrase during creating keys. If you want to ask passphrase for reading your private key you can enter passphrase.

Screenshot from 2019 05 13 15 22 20 300x140 - Automatically Back Up Your Notes To GitHub

Screenshot from 2019 05 13 15 23 08 300x141 - Automatically Back Up Your Notes To GitHub

We completed everything about Keys. Now go to your notes path and execute following commands. You should convert HTTP to SSH in your links for GitHub no to ask for a password.

NOTE: You should change these commands for yourself, following commands is configured for me.

Screenshot from 2019 05 13 15 34 58 300x183 - Automatically Back Up Your Notes To GitHub

Now we can push all notes 🙂 .

Screenshot from 2019 05 13 15 36 48 300x184 - Automatically Back Up Your Notes To GitHub

The followings code is belongs autonote.sh (https://github.com/eredotpkfr/autonote.sh). autonote.sh script is belongs me hahaha… 🙂

If you want to backup your notes, you should change directory in push_files function. “cd /home/eredot_pkfr/n0t3s/notes/ && git add *” you should write your note’s path because script is backup all files in this path 🙂 .

Now we can change PATH variable in environment variables for calling script easily 🙂 . The following command works.

NOTE: You should change path for yourself, above command is configured for me.

Nice we made it but we have some problem, if we reboot system, this command is not work 🙂 so we should configure .bashrc file in ~/ directory 🙂 . Also we add some alias its get better.

Screenshot from 2019 05 14 13 58 35 300x183 - Automatically Back Up Your Notes To GitHub

alias command make it autonote command works execute autonote.sh in subshell 🙂 .

Now we can add some statup applications for this follow other steps 🙂

If you hit alt + f2 combination, opening command panel and type “gnome-session-properties”. Then fill the blanks according to yourself. Following command is configured for me.

Screenshot from 2019 05 14 14 21 27 300x258 - Automatically Back Up Your Notes To GitHub

Now we can add some key combination. If we add key combination and we hit this combination shell script is work and notes are backup to GitHub. For this (According Ubuntu 19.04) go to Settings > Devices > Keyboard and fill the blanks according to yourself.

Screenshot from 2019 05 14 14 22 36 300x224 - Automatically Back Up Your Notes To GitHub

All configurations are done 🙂 now if we hit ctrl + alt + a combination, notes are backup to GitHub .

Screenshot from 2019 05 15 01 22 21 300x184 - Automatically Back Up Your Notes To GitHub

Screenshot from 2019 05 15 01 23 09 300x38 - Automatically Back Up Your Notes To GitHub

Conclusion

Maybe could have been nicer with crontab 🙂 anyways script is working beautifully, if you want to use this script you can get on my GitHub account (https://github.com/eredotpkfr/autonote.sh). Don’t forget to star my GitHub (autonote.sh) account 🙂 .