aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2021-09-14 16:58:19 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2021-09-14 16:58:19 +0900
commit0c985e8fdcbfa827327971e6d4771f177615ae60 (patch)
tree94a779c152861e9f5f4e3148fc527018e04be097
parentc7a1cfeb5b7e28b26fa73ae1c27fa517040abe04 (diff)
Add check-backup-of-email job.
-rwxr-xr-xjobs/check-backup-of-email.run11
1 files changed, 11 insertions, 0 deletions
diff --git a/jobs/check-backup-of-email.run b/jobs/check-backup-of-email.run
new file mode 100755
index 0000000..97af470
--- /dev/null
+++ b/jobs/check-backup-of-email.run
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+todays_backup="s3://qkbackup/email/$(date "+%w")/"
+echo "Check $todays_backup."
+output="$(guix environment --ad-hoc python2-s3cmd -- s3cmd ls "$todays_backup")"
+
+# UTC の時刻で日付が前日の場合はバックアップに成功していると見做す
+echo "$output" |\
+ awk -v utc_today="$(TZ=UTC date "+%F" -d '1 day ago')" \
+ '$1 != utc_today { print "Failed!"; exit 1 } ; { print }'