]> us-delaporte.pagekite.me Git - minion.git/commitdiff
Add backup of wiki page
authorEdward Delaporte <edward@delaporte.us>
Sun, 23 Aug 2026 22:40:30 +0000 (17:40 -0500)
committerEdward Delaporte <edward@delaporte.us>
Sun, 23 Aug 2026 22:40:30 +0000 (17:40 -0500)
bin/m2w [new file with mode: 0755]

diff --git a/bin/m2w b/bin/m2w
new file mode 100755 (executable)
index 0000000..51162b8
--- /dev/null
+++ b/bin/m2w
@@ -0,0 +1,37 @@
+#!/bin/bash
+# m2w - minion send to wiki
+# Will publish a maximum of four .md files to .md.txt files
+# Meant for use wit Dokuwiki
+#   to $M2W_DIR on $M2W_SCP_HOST
+year=`date +%Y`
+files=$(find $HOME/Journal/$year -type f -iname "*$1*\.md")
+
+if [ ! -n "$M2W_DIR" ]; then
+  echo "Set M2W_DIR"
+  exit 1
+fi
+
+if [ ! -n "$M2W_HOST" ]; then
+  echo "Set M2W_HOST"
+  exit 1
+fi
+
+
+yearmonthday=`date -I`
+
+counter=0
+for file in $files; do 
+  base=`basename $file .md`
+  # make a backup copy
+  scp $M2W_HOST:$M2W_DIR/$base.txt $HOME/Journal/archive-$year/wiki.backup.$base.$yearmonthday.txt
+
+  # deploy file as .txt
+  scp $file $M2W_HOST:$M2W_DIR/$base.txt
+       counter=$((counter + 1))
+if [ $counter -gt 4 ]; then
+               echo "Aborting after 4 files."
+               echo "The following files would have been processed..."
+               echo $files
+               exit 1
+fi
+done