ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

commit a4700375109d182b88ddcc250d80357535dff42f
parent b127c5f96cbeaf4f59a5ff34f296da5e982613ef
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 25 Jan 2021 22:46:34 +0100

backup: fixes
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/roles/backup/tasks/wanderduene.yml b/roles/backup/tasks/wanderduene.yml
@@ -2,7 +2,7 @@
 
 - name: create password file for rest-server
   copy:
-    content: "{{ lookup('community.general.passwordstore', 'server/taurus/rest-server.plain returnall=true')}}"
+    content: "{{ lookup('community.general.passwordstore', 'Server/taurus/rest-server.plain returnall=true')}}"
     dest:    /var/lib/restic-password
     mode:    0755
     owner:   root

@@ -10,7 +10,7 @@
 
 - name: create password files for services
   copy:
-    content: "{{ lookup('community.general.passwordstore', 'server/{{system.hostname}}/restic/{{item}} returnall=true')}}"
+    content: "{{ lookup('community.general.passwordstore', 'Server/{{system.hostname}}/restic/{{item}} returnall=true')}}"
     dest:    "/var/lib/{{item}}/restic-password"
     owner:   "{{item}}"
     group:   "{{item}}"

@@ -25,7 +25,7 @@
 
 - name: create password file for postgresql
   copy:
-    content: "{{ lookup('community.general.passwordstore', 'server/{{system.hostname}}/restic/postgresql returnall=true')}}"
+    content: "{{ lookup('community.general.passwordstore', 'Server/{{system.hostname}}/restic/postgresql returnall=true')}}"
     dest:    /var/lib/postgresql/restic-password
     owner:   postgres
     group:   postgres

@@ -33,7 +33,7 @@
 
 - name: create password file for htmldir
   copy:
-    content: "{{ lookup('community.general.passwordstore', 'server/{{system.hostname}}/restic/websites returnall=true')}}"
+    content: "{{ lookup('community.general.passwordstore', 'Server/{{system.hostname}}/restic/websites returnall=true')}}"
     dest:    /var/lib/websites/restic-password
     owner:   leah
     group:   leah
diff --git a/scripts/restic-backup-wanderduene.sh b/scripts/restic-backup-wanderduene.sh
@@ -1,15 +1,27 @@
 #!/usr/bin/env sh
 
+echo "$(date -R)" > /root/backup.last-run 
+
 #backup services
 for service in pleroma radicale synapse git maddy oeffisearch
 do
   sudo -u $service restic init --password-file /var/lib/$service/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password)@restic.ctu.cx/$(hostname)-$service
   sudo -u $service restic backup --password-file /var/lib/$service/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password)@restic.ctu.cx/$(hostname)-$service /var/lib/$service
+  if [ $? -eq 0 ]; then
+  	echo "$service: OK" >> /root/backup.last-run
+  else 
+  	echo "$service: FAIL" >> /root/backup.last-run
+  fi
 done
 
 #backup websites
 sudo -u leah restic init --password-file /var/lib/websites/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password)@restic.ctu.cx/$(hostname)-websites
 sudo -u leah restic backup --password-file /var/lib/websites/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password)@restic.ctu.cx/$(hostname)-websites /var/lib/websites
+if [ $? -eq 0 ]; then
+  echo "websites: OK" >> /root/backup.last-run
+else 
+  echo "websites: FAIL" >> /root/backup.last-run
+fi
 
 #backup postgres
 SQLFILE=/var/lib/postgresql/backup/postgres_$(date "+%Y-%m-%d_%H:%M").sql

@@ -17,4 +29,9 @@ sudo -u postgres mkdir /var/lib/postgresql/backup
 sudo -u postgres bash -c "pg_dumpall > $SQLFILE"
 sudo -u postgres restic init --password-file /var/lib/postgresql/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password)@restic.ctu.cx/$(hostname)-postgres
 sudo -u postgres restic backup --password-file /var/lib/postgresql/restic-password --repo rest:https://restic:$(cat /var/lib/restic-password)@restic.ctu.cx/$(hostname)-postgres /var/lib/postgresql/backup
+if [ $? -eq 0 ]; then
+  echo "postgres: OK" >> /root/backup.last-run
+else 
+  echo "postgres: FAIL" >> /root/backup.last-run
+fi
 sudo -u postgres rm -rf /var/lib/postgresql/backup