From b180b852be63d7db487f22b19545dfdf578de056 Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Sat, 20 Apr 2019 10:01:30 -0400 Subject: [PATCH] Expanded orgbackup --- bin/orgbackup | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) mode change 100644 => 100755 bin/orgbackup diff --git a/bin/orgbackup b/bin/orgbackup old mode 100644 new mode 100755 index ea952d8..6680e92 --- a/bin/orgbackup +++ b/bin/orgbackup @@ -1,20 +1,22 @@ #!/bin/bash set -eo pipefail -BEORG="$HOME/Library/Mobile Documents/iCloud~com~appsonthemove~beorg/Documents/org/" -BACKUP="$HOME/Documents/org" -if ! test -d "$BEORG"; then +SRC="${1-$ORGHOME}" +DST="${2-$HOME/Documents/org}" +if test -z "$SRC" -o ! -d "$SRC"; then + echo "usage: $0 [src] [dst]" + echo "SRC ($SRC) is either unset or not a directory" exit 0 fi -rsync -a --exclude-from="$HOME/.gitignore" "$BEORG" "$BACKUP" -cd "$BACKUP" && ( +rsync -a --exclude-from="$HOME/.gitignore" "$SRC" "$DST" +cd "$DST" && ( if ! test -d .git; then git init fi if git status | grep 'not staged' &>/dev/null; then find -X . -name '*.org*' -and -not -name '.*' | xargs git add - git commit -m "Org archive from $(date)" + git commit -m "Org archive from $(date)" && git push fi )