summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xocr-scan20
-rwxr-xr-xzfs-backup.sh78
2 files changed, 98 insertions, 0 deletions
diff --git a/ocr-scan b/ocr-scan
new file mode 100755
index 0000000..5e7423f
--- /dev/null
+++ b/ocr-scan
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+jpeg_quality=70
+jpeg_size=1500x1500
+
+time=$(date +%Y-%m-%d_%H%M%S)
+scanimage --resolution 300 -b -x 215 -y 297
+i=1
+while [[ -e "out$i.pnm" ]]; do
+ img="out$i.pnm"
+ newname="$(printf "%s_%03d" "$time" "$i")"
+ unpaper "$img" "unpaper-$img"
+ tesseract "unpaper-$img" "$newname.txt"
+ convert "$img" -normalize -resize $jpeg_size -quality $jpeg_quality "$newname.jpg" && rm "$img" "unpaper-$img"
+ ((i++))
+done
+
+if [[ $1 = "--pdf" ]]; then
+ convert "${time}"_*.jpg -resize $jpeg_size -compress jpeg -quality $jpeg_quality -density 72x72 -repage 595x842 "${time}.pdf" && rm "${time}"_*.jpg
+fi
diff --git a/zfs-backup.sh b/zfs-backup.sh
new file mode 100755
index 0000000..40dc4f6
--- /dev/null
+++ b/zfs-backup.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+## example host config
+# set_vars root karif
+#
+# run_ssh $src /root/backup.pl start
+#
+# run_ssh backup@$host "cd /home/backup/mysql-dumps; /home/backup/create-mysql-dumps"
+# run_ssh backup@$host "cd /home/backup/psql-dumps; /home/backup/create-psql-dumps"
+# backup_rsync "$src:/home/backup/mysql-dumps/" "$dst/mysql-dumps/"
+# backup_rsync "$src:/home/backup/psql-dumps/" "$dst/psql-dumps/"
+# run_ssh backup@$host "rm -f /home/backup/mysql-dumps/*.sql.gz"
+# run_ssh backup@$host "rm -f /home/backup/psql-dumps/*.dump"
+#
+# backup_rsync --filter=". /mnt/backup/filters/karif_root_filter" "$src:/mnt/snapshots/vg0-root/" "$dst/root/"
+# backup_rsync --filter=". /mnt/backup/filters/karif_home_filter" "$src:/mnt/snapshots/vg0-home/" "$dst/home/"
+# backup_rsync "$src:/boot/" "$dst/boot/"
+#
+# run_ssh $src /root/backup.sh stop
+#
+# create_and_clean_snapshots "$dst_fs"
+
+
+
+set -e
+
+backup_rsync() {
+ local dir="${@: -1}"
+ mkdir -p "$dir"
+ rsync --rsh="/usr/bin/ssh -i /root/.ssh/id_rsa-backup" --delete --numeric-ids --delete-excluded --max-delete=100000 -axEAXHv "$@"
+}
+
+run_ssh() {
+ ssh -i /root/.ssh/id_rsa-backup "$@"
+}
+
+set_vars() {
+ user="$1"
+ host="$2"
+ src="$user@$host"
+ dst_fs="$backup_fs_base/$host"
+ dst="$(zfs get mountpoint -o value -H "$dst_fs")"
+}
+
+create_snapshots() {
+ local dst_fs=$1
+
+ if [[ "$(date +%d)" = "01" ]]; then
+ /root/zfs_create_dated_snapshot.sh "$dst_fs" monthly
+ fi
+ if [[ "$(date +%u)" = "7" ]]; then
+ /root/zfs_create_dated_snapshot.sh "$dst_fs" weekly
+ fi
+ /root/zfs_create_dated_snapshot.sh "$dst_fs" daily
+}
+
+clean_snapshots() {
+ local dst_fs=$1
+
+ /root/zfs_snapshot_cleanup.sh "$dst_fs" daily 10
+ /root/zfs_snapshot_cleanup.sh "$dst_fs" weekly 4
+ /root/zfs_snapshot_cleanup.sh "$dst_fs" monthly 2
+}
+
+create_and_clean_snapshots() {
+ local dst_fs=$1
+ create_snapshots "$dst_fs"
+ clean_snapshots "$dst_fs"
+}
+
+backup_fs_base="data/backup_zfs/backups"
+
+if (($#<1)); then
+ echo "usage: ${0##*/} <hostname>"
+ exit 1
+fi
+
+source "${0%/*}/host-configs/$1"