Automate your Logseq or Obsidian graph to Github (Simple Workflow)

I have been a fan of Logseq for quite some time and been using it almost daily as a part of my workflow.

But due to the nature of logseq and obsidian being local there is a some probability that I might delete it my mistake and that's something I would not want to have.

What I have been doing is taking a regular backup of my logseq graph using git and publish that to Github for having a version control incase If I want to go back sometime.

The problem with this workflow was that it was manual so I have to go and put the graph to Github.

There need a solution for that.

You need to setup a basic github repository before doing this.

Automatic pushing code to Git

Create a file called auto-git.sh

#!/bin/bash
cd "<PATH>"; #Where you graph is located
git add .;
git commit -m "commit through script";
git push origin master;
auto-git.sh
code for the auto-git.sh file
auto-git.sh

After the file is created, then make the file executable using

chmod 755 auto-git.sh

This would let the system execute the file.

Now, since the file is executable we now need to run this file whenever we want to backup.

Let's run this file every hour using crontab. Go to terminal and enter

crontab -e

Add

@hourly sh <PATH>/auto-git.sh >> ~/cronlog.log
crontab code for automating it every hour
crontab -e

Here the <PATH> should be the path that you have kept the auto-git.sh file at.

Here, if you want to have it script run every day then in-place of @hourly put @daily. You can check Crontab for more info.

Save and you are done. Now if everything is successful you can see the auto-git.sh file running every hour and that would publish your graph to github.

If you have any doubts feel free to add that in the comment section.

Rohit Lakhotia

Rohit Lakhotia

Building digital products. A full-stack developer who also loves design.