# Obsidian iOS sync with a Dev's touch

While there are several free methods available, such as using Google Drive or iCloud, to synchronize notes across different devices, there was still a desire to achieve note synchronization via GitHub. This desire gave rise to the concept of employing the Obsidian-git plugin in conjunction with the iOS app Working Copy, which, at the time, offered a robust free solution. However, it's worth noting that Working Copy has since implemented a one-time lifetime payment of $24 for its iPhone push functionality.

This new development prompted me to explore alternative approaches to address this situation. That's when I came up with the idea of utilizing a spare Raspberry Pi (or any remote instance, I am going to user my Pi) in combination with an Apple innovation: the Shortcuts application. Apple Shortcuts, when configured with the appropriate user permissions, enables the execution of scripts over SSH. As a result, I created a shortcut, outlined below:

![DFD](https://raw.githubusercontent.com/v4run75/blog-images/master/obsidiansync/Obsidian.drawio.png)

#### Setup Instructions:

To implement the process of pulling changes from Working Copy and Obsidian-git plugin, along with setting up automation using the Shortcuts app, you can follow the detailed guide provided at this link: [https://meganesulli.com/blog/sync-obsidian-vault-iphone-ipad/](https://meganesulli.com/blog/sync-obsidian-vault-iphone-ipad/). The only variation in this setup is that we will replace the standard push shortcut with our customized version.

Now, I will elucidate the steps for crafting a Git-Push Shortcut and configuring Git over SSH on a Raspberry Pi:

#### Step 1: Setting up Apple shortcut

* Create a new shortcut as shown below:
* Note: Please substitute the folder named _Voidd_ with your specific folder name and ensure to include the hostname, IP address/domain of your remote server, and the necessary user credentials, such as a username and password if authentication is required for the connection.

![Shortcuts App](https://raw.githubusercontent.com/v4run75/blog-images/master/obsidiansync/shortcut.png)

Directory Structure of my Obsidian Vault/Folder is depicted below:

Voidd.\_ > CISSP > Domains.md

![voidd](https://raw.githubusercontent.com/v4run75/blog-images/master/obsidiansync/voidd.png)

![cissp](https://raw.githubusercontent.com/v4run75/blog-images/master/obsidiansync/cissp.png)

![md](https://raw.githubusercontent.com/v4run75/blog-images/master/obsidiansync/md.png)

SSH script used in the shortcut:

```
ssh -A
#you can replace /home/ with any path for your remote server
cat /dev/stdin > /home//obs.tar.gz 
cd /home/
tar -xvf obs.tar.gz
./git-bash.sh
        
    
```

#### Step 2: Setting up Raspberry Pi

Utilize the provided guide, "[Connecting to Git over SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh)," to configure SSH connectivity to GitHub on your Raspberry Pi. This setup eliminates the need for user interaction when supplying your Git username and password combination. Additionally, add Git remote for your repository where your notes are stored.

Next, generate a Bash script named "git-bash.sh" in the directory where you've extracted the necessary files. This script will streamline and automate various Git-related tasks:

```

# Define your commit message
commit_message="Your commit message here"
Add all changes to the staging area
git add .
Commit the changes with the provided commit message
git commit -m "$commit_message"
Push the changes to the remote repository
git push origin main

```

Now, we are fully prepared to synchronize our notes across iOS devices using Git.

Our Shortcuts Automation takes care of the synchronization process by invoking the Working Copy pull shortcut each time we access Obsidian notes and utilizing the Custom Git Push Raspberry Pi shortcut upon closing the application.

It's important to note that this approach is primarily intended for educational and learning purposes, as it may be more intricate to set up compared to simpler alternatives.

We appreciate your time and consideration.
