Skip to content

Instantly share code, notes, and snippets.

@kylebradshaw
Last active May 14, 2021 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylebradshaw/b4b2deadfcdc9b8ffe69ae7d9136a379 to your computer and use it in GitHub Desktop.
Save kylebradshaw/b4b2deadfcdc9b8ffe69ae7d9136a379 to your computer and use it in GitHub Desktop.
automatic dendron backups - nightly

AUTOMATIC DENDRON NIGHTLY BACKUPS

create an alias to automatically backup from cli for zsh

add an alias to .zshrc

alias dendron-nightly="cd $HOME/dendron-repo; git add .; git commit -m '$(date +%Y.%m.%d) backup'; git push origin master"

create a script to backup your dendron repo nightly

dendron-nightly.sh

#!/usr/bin/env zsh
source $HOME/.zshrc
dendron-nightly

chmod +x dendron-nightly.sh

automate (OSX)

  1. go to https://www.gieson.com/Library/projects/utilities/launcha/
  2. set it up and create the .plist file and point to your script that runs any nightly tasks
  3. follow the instructions prob put it in your ~/Library/LaunchAgents folder
  4. load it: launchctl load /Library/LaunchDaemons/{YOUR FILE}.plist

example .plist file

this .plist will run your dendron-nightly script every day at 23:59:00

{ REPLACE CUSTOM VALUES }

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>GroupName</key>
    <string>{USERNAME}.nightly</string>
    <key>Label</key>
    <string>com.gieson.launcha.{USERNAME}.nightly</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>Program</key>
    <string>{FULL PATH TO YOUR SCRIPT}</string>
    <key>RunAtLoad</key>
    <true/>
    <key>EnvironmentVariables</key>
    <dict>
      <key>PATH</key>
      <string>/bin:/usr/bin:/usr/local/bin</string>
    </dict>
    <key>StartCalendarInterval</key>
    <array>
      <dict>
        <key>Weekday</key>
        <integer>0</integer>
        <key>Hour</key>
        <integer>23</integer>
        <key>Minute</key>
        <integer>59</integer>
      </dict>
      <dict>
        <key>Weekday</key>
        <integer>1</integer>
        <key>Hour</key>
        <integer>23</integer>
        <key>Minute</key>
        <integer>59</integer>
      </dict>
      <dict>
        <key>Weekday</key>
        <integer>2</integer>
        <key>Hour</key>
        <integer>23</integer>
        <key>Minute</key>
        <integer>59</integer>
      </dict>
      <dict>
        <key>Weekday</key>
        <integer>3</integer>
        <key>Hour</key>
        <integer>23</integer>
        <key>Minute</key>
        <integer>59</integer>
      </dict>
      <dict>
        <key>Weekday</key>
        <integer>4</integer>
        <key>Hour</key>
        <integer>23</integer>
        <key>Minute</key>
        <integer>59</integer>
      </dict>
      <dict>
        <key>Weekday</key>
        <integer>5</integer>
        <key>Hour</key>
        <integer>23</integer>
        <key>Minute</key>
        <integer>59</integer>
      </dict>
      <dict>
        <key>Weekday</key>
        <integer>6</integer>
        <key>Hour</key>
        <integer>23</integer>
        <key>Minute</key>
        <integer>59</integer>
      </dict>
    </array>
  </dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment