]> gitweb.hamatoma.de Git - ansknife.git/commitdiff
V0.1.1
authorHamatoma <author@hamatoma.de>
Wed, 11 Jun 2025 17:04:36 +0000 (19:04 +0200)
committerHamatoma <author@hamatoma.de>
Wed, 11 Jun 2025 17:05:05 +0000 (19:05 +0200)
- templates.fix/scripts: new: BtrSnapshot, SvWebapp
- templates.local/scripts: new: SvWebapp.conf
- webapps.yaml: Korrektur der Syntax

CHANGELOG.md
templates.fix/scripts/BtrSnapshot [new file with mode: 0644]
templates.fix/scripts/SvWebapp [new file with mode: 0644]
templates.local/scripts/SvWebapp.conf [new file with mode: 0644]
templates.vars/webapps.yaml

index 51ee0d2686996a2e19fa5e7a33679fca3fadea61..3f31eb69c07ebdeb10fd3577d8419cd28478cc37 100644 (file)
@@ -1 +1,6 @@
-# Change log of 
+# V0.1.1
+
+- templates.fix/scripts: new: BtrSnapshot, SvWebapp
+- templates.local/scripts: new: SvWebapp.conf
+- webapps.yaml: Korrektur der Syntax
+
diff --git a/templates.fix/scripts/BtrSnapshot b/templates.fix/scripts/BtrSnapshot
new file mode 100644 (file)
index 0000000..9c53daa
--- /dev/null
@@ -0,0 +1,69 @@
+#! /bin/bash
+# BtrSnapshot [-q] MODE FILESYSTEM SRC [LOG]
+# BtrSnapshot daily /media/fs.cave mirror.home /tmp/snap.log
+VERBOSE=-v
+LOG=/var/log/local/btrsnapshot.log
+if [ "$1" = -q ]; then
+  VERBOSE=
+  shift
+fi
+MODE=$1
+FILESYSTEM=$2
+SRC=$3
+test -n "$4" && LOG="$4"
+export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
+
+function Usage(){
+  echo "Usage: BtrSnapshot MODE FILESYSTEM SOURCE [LOGFILE]"
+  echo "Example: BtrSnapshot daily /media/fs.cave home"
+  echo "Example: BtrSnapshot daily /media/fs.cave opt /var/log/mylog.log"
+  echo "+++ $*"
+}
+function Log(){
+  test -n "$VERBOSE" && echo "$*"
+  date "+%Y.%m.%d-%H:%M:%S $*" >>$LOG
+}
+function MakeSnapshot () {
+  local mode=$1
+  local filesys=$2
+  local src=$3
+  local subdir
+  case $mode in
+  daily)
+    subdir=$(LANG=C date +%a)
+    ;;
+  weekly)
+    subdir=$(date +%W)
+    subdir=$(expr $subdir "%" 4)
+    ;;
+  monthly)
+    subdir=$(date +%m)
+    ;;
+  temp)
+    subdir=temp
+    ;;
+  esac
+  local trg=$filesys/snapshots/$src/$mode
+  if [ ! -d $trg ]; then
+    Log "creating $trg..."
+    mkdir -p $trg
+  fi
+  trg="$trg/$subdir"
+  if [ -d $trg ]; then
+    Log "$(btrfs subvol delete $trg)"
+  fi
+  Log "$(btrfs subvol snapshot -r $filesys/$src $trg)"
+} 
+if [ "$MODE" = "auto" ]; then
+  MODE=daily
+  test "$(date +%w) = 6 && MODE=weekly
+  test "$(date +%d) = 01 && MODE=monthly
+fi
+
+if [ -z "$SRC" ]; then
+  Usage "too few arguments"
+elif [ ! -d $FILESYSTEM/$SRC ]; then
+  Usage "missing $FILESYSTEM/$SRC"
+else
+  MakeSnapshot $MODE $FILESYSTEM $SRC
+fi
diff --git a/templates.fix/scripts/SvWebapp b/templates.fix/scripts/SvWebapp
new file mode 100644 (file)
index 0000000..fd48e8c
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/bash
+VERBOSE=-v
+if [ "$1" == '-q' ]; then
+  VERBOSE=
+  shift
+fi
+DOMAIN=$1
+DB=$2
+PATH=/usr/bin:/bin
+. /usr/local/bin/local/SvWebapp.conf
+DATE=$(date "+%Y.%m.%d_%H_%M")
+BASE=$DIR_WWW/$DOMAIN
+TAR=$DIR_ARCHIVE/$DOMAIN.$DATE.tgz
+if [ -z "$DB" ]; then
+  echo "Usage: SvWebapp DOMAIN DB"
+  echo "Example SvWebapp stage.infeos.net swstageinfeos"
+  echo "+++ missing DOMAIN"
+elif [ ! -d $BASE ]; then
+  echo "+++ missing $BASE"
+else
+  cd $BASE/db
+  mysqldump $DB | gzip >$DOMAIN.sql.gz
+  cd $BASE
+  tar czf $TAR .
+  test -n "$VERBOSE" && ls -l $TAR
+fi
diff --git a/templates.local/scripts/SvWebapp.conf b/templates.local/scripts/SvWebapp.conf
new file mode 100644 (file)
index 0000000..2ca8b6b
--- /dev/null
@@ -0,0 +1,3 @@
+DIR_WWW=/srv/www
+DIR_ARCHIVE=/media/backup/archive
+
index c8656c332f61ea0f9ff8285bf8fb52bffa9986cd..136368e6c0f15c66fbb3e8402ffd591caabc80e9 100644 (file)
@@ -1,8 +1,9 @@
 ---
 # Configuration data of the web applications
 webapps_list:
-  - dummy
+  - webapp_name: dummy.example.com
     db_name: dbdummy5
+    db_type: mysql
     db_user: dummy5
     db_password: NeverKnown5
     directory: /srv/www/myapp5.example.com