- on [Cron]( https://osxdaily.com/2020/04/27/fix-cron-permissions-macos-full-disk-access/):
- *UPDATE*: crontab is deprecated for MacOS so the sync option given will not work.
- the best next alternative is then to use [launchd](obsidian://open?vault=enter&file=Coding%20Tips%20(Classical)%2FTerminal%20Tips%2FShells%2FComputers%20(operating%20system)%2FApple%20Macbook%2FLaunchd) or keyboard scheduler as described through this youtube video.
- Refer back to [plists](obsidian://open?vault=Coding%20Tips&file=Computers%2FMac%20OS%20X%2FBBEdit%2Fplist) for a better understanding of implementation and usage.
- apparently the extension [Obsidian-Git](https://github.com/denolehov/obsidian-git/wiki/Installation#existing-repo) already does this in an easier way now
- So this is how you [push it to your gitlab](https://about.gitlab.com/blog/2022/03/15/publishing-obsidian-notes-with-gitlab-pages/)
- Refer to the [Git page](obsidian://open?vault=Obsidian&file=Coding%20Tips%2FComputers%2FTerminal%20Tips%2FGit) on here for more shortcuts.
My Obsidian files are all stored within Google Drive. So in order to maintain sync while still preserving cloud storage space, I used a few different steps than the guides, and well really it was a culmination of it all.
8. I then created another branch for the upload sync to take place.
```
git branch AnotherBranch
git checkout AnotherBranch #switch into it
```
9.
10. Then follow the instructions [outlined on this article](https://techstreams.medium.com/git-google-drive-simple-git-host-3a84db4fc1fd). Basically you then create a git clone of it in your new directory by `git clone --bare . PATH_TO_GOOGLE_DRIVE_SYNC_FOLDER/ANY_SUBFOLDER_PATH/PROJECT_NAME.git`
11. Then do a git remote by `git remote add REMOTE_NAME PATH_TO_GOOGLE_DRIVE_SYNC_FOLDER/ANY_SUBFOLDER_PATH/PROJECT_NAME.git`
12. Add files to stage for commit and commit a message.
```
git add .
git commit -m "an update message here"
```
13. Lastly, push the changes onto your quantum programming repo.
```
git push -u origin main
```
Voila! You should see the changes now [over here](https://gitlab.com/shwetha729/quantum-programming). Or wherever you decided to set up host the git remote server on.
This can be done locally or via Google Drive. However, I will be using Linode to host Gitea to host my obsidian and all my repos locally. Go to the folder on your laptop that you'd like to start the git syncing your Obsidian Vault at and run:
##### 3. Syncing Your Vault to Push every few minutes
So this is all great and all, you can now push and pull to a remote server that you own! However, it is a bit annoying to have to do the same terminal commands of git pull, add, commit, push, blah blah dsjkhfalfhk. It can get repetitive. So what do we do? We make a script that can take care of this automatically for us.
###### *For Linux:* Sync the Obsidian vault very few minutes with this script via `cron`:
###### *For Mac:* Sync Obsidian vault via `launchd` by writing a plist script:
1. We will be using launnchd. Check your list of services by:
```
sudo launctl list
```
![[Pasted image 20230714193655.png]]
It sort of looks like that!^
So the goal here is to put a launchd .plist into that so that your Mac knows to trigger a LaunchDaemon upon a certain trigger.
2. First, however we need to make a bash script that does that syncing itself. This can be done by navigating to `~/.local/bin` and create a shell script by:
```
touch zk_sync
chmod +x zk_sync
```
*Separately:* Also make sure to copy the absolute path of your vault as that will be the environment variable that you will input into `ZK_PATH` to ensure that it still works. You can obtain the path by:
```
> pwd
#output
> /Users/shwethajayaraj/Google Drive/My Drive/RESOURCES (Research - my notebook)/collabtestdir/Notepad
```
If there are spaces in your working directory just make sure that you put in wrapped double quotation marks.
3. What are the actual contents of the shell script though that have to be done?? Well, go ahead and `vim` into the `zk_sync` file and paste the following in:
```sh
#!/usr/bin/env sh
ZK_PATH=”/Volumes/GoogleDrive-117209510583853875316/My Drive/RESOURCES (Research - my notebook)/collabtestdir/Notepad"
and your git should be updated with that one command with the updated time and the number of lines that were changed in the git commit.
Now that we have ensured that the script itself the hard part is over. The next step is to make sure that you are syncing at a consistent time!
4. Now it is time to submit this to the `launchd` scheduler. Navigate to `~/Library/LaunchAgents` as this is where you will be dropping your .plist file.