about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-01-23 11:56:58 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2015-01-23 11:56:58 +0100
commit7f622b266f5a5d20d3a2c2309b6290a4d66ae382 (patch)
tree3c20ffbb63bcef490b69288790bfda39017120e4
parent224a61a72e7c6a97f12cae601bc665444b59e23c (diff)
downloadrdumpfs-7f622b266f5a5d20d3a2c2309b6290a4d66ae382.tar.gz
rdumpfs-7f622b266f5a5d20d3a2c2309b6290a4d66ae382.tar.xz
rdumpfs-7f622b266f5a5d20d3a2c2309b6290a4d66ae382.zip
add yday v0.1
-rwxr-xr-xyday41
1 files changed, 41 insertions, 0 deletions
diff --git a/yday b/yday
new file mode 100755
index 0000000..ac3b95e
--- /dev/null
+++ b/yday
@@ -0,0 +1,41 @@
+#!/bin/bash
+# yday [-D DUMPDIR] [-a] [-d] [-n DAYS] FILES... - retrieve paths from the dump
+#   -a  all versions
+#   -d  diff against current file
+#   -n  start DAYS back
+
+: ${RDUMPFS_DUMP:=/data/dump/$HOSTNAME}
+
+Xecho() {
+  echo "$1"
+}
+
+Xdiff() {
+  diff -u "$1" "$2"
+}
+
+all=false
+op=Xecho
+n=0
+
+while getopts adn:D: opt; do
+  case "$opt" in
+    a) all=true;;
+    d) op=Xdiff;;
+    n) n="$OPTARG";;
+    D) RDUMPFS_DUMP="$OPTARG";;
+    [?]) exit;;
+  esac
+done
+shift $((OPTIND-1))
+
+for file; do
+  ABSOLUTE=$(readlink -f "$file")
+  for d in $(seq $n 1000); do
+    DUMPED=$RDUMPFS_DUMP/$(date --date "$d day ago" +%Y%m%d)$ABSOLUTE
+    if [ -e "$DUMPED" ]; then
+      $op "$DUMPED" "$ABSOLUTE"
+      $all || break
+    fi
+  done
+done