From f2c712f47a42eaad90db46d86f8727fbf7fd67c7 Mon Sep 17 00:00:00 2001
From: root <root@vps358919.ovh.net>
Date: Fri, 22 Mar 2019 16:03:27 +0100
Subject: [PATCH] Add Check Cloud Storage

---
 check_cloud_storage | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100755 check_cloud_storage

diff --git a/check_cloud_storage b/check_cloud_storage
new file mode 100755
index 0000000..99e77a7
--- /dev/null
+++ b/check_cloud_storage
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# Copyright © 2019 Le Filament (<http://www.le-filament.com>)
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+OUTPUT=""
+RETURN_CODE="0"
+for file in `ls /mnt/vdb/backup/cloud/*.latest`
+do
+    INIT_LINE=$(grep -A 2 "Container:" $file | grep -v ACL | grep -v Sync | grep -v X- | grep -v Accept-Ranges | tr -d '\t ' | tr '\n' ' ')
+    LAST_FILE=$(tail -2 $file | grep gpg)
+    if [ `date -d "${LAST_FILE:5:19}" +%s` -gt `date -d '7 days ago' +%s` ]
+    then
+        OUTPUT+="OK : $INIT_LINE Last-Modified:${LAST_FILE:5:19}\n"
+    else 
+        OUTPUT+="NOK : $INIT_LINE Last-Modified:${LAST_FILE:5:19}\n"
+        RETURN_CODE="2"
+    fi
+done
+echo $OUTPUT
+exit ${RETURN_CODE} 
-- 
GitLab