From ec4d210ea2f2b0aa6bcc823e3b58f6a1db72d3af Mon Sep 17 00:00:00 2001
From: David Beniamine <david.beniamine@tetras-libre.fr>
Date: Mon, 4 Nov 2024 11:36:38 +0100
Subject: [PATCH] Upgrade backup system

---
 upgrade/All.sh     |  4 ++--
 upgrade/Backups.sh | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)
 create mode 100644 upgrade/Backups.sh

diff --git a/upgrade/All.sh b/upgrade/All.sh
index 83d1278..01761f6 100644
--- a/upgrade/All.sh
+++ b/upgrade/All.sh
@@ -65,6 +65,8 @@ bash $DIR/install/ncdu.sh
 
 bash $DIR/upgrade/Monit.sh
 
+bash $DIR/upgrade/Backups.sh
+
 bash $DIR/checks/rkhunter.sh
 
 # Check docker is running
@@ -80,8 +82,6 @@ services="$services $(systemctl  | awk '/php.*fpm/{print $1}')"
 [ ! -z "$services" ] && systemctl restart $services
 checkrestart
 
-bash $DIR/checks/backups.sh
-
 echo -e "\tPlease check that the following services are up and running"
 bash $DIR/checks/list_domains.sh
 
diff --git a/upgrade/Backups.sh b/upgrade/Backups.sh
new file mode 100644
index 0000000..04780e8
--- /dev/null
+++ b/upgrade/Backups.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+echo "RUN $(basename "$0") ==="
+
+if [ ! -e $(dirname "$0")/../main.env ]
+then
+    echo "Please copy in racine of NoCloud Auto Installer main.env.sample to main.env and edit it"
+    exit 1
+else
+    echo "Environment file loaded"
+fi
+. $(dirname "$0")/../main.env
+
+
+duplicity_dir="/opt/duplicity-ftp-backup/"
+duplicity_alt_dir="/root/duplicity-ftp-backup/"
+if [ -d "$duplicity_dir" ]; then
+    backup_dir="$duplicity_dir"
+elif [ -d "$duplicity_alt_dir"]; then
+    backup_dir="$duplicity_alt_dir"
+fi
+if [ -z "$backup_dir" ]; then
+    echo "WARNING duplicity backup system not found"
+    exit 1
+fi
+cd $backup_dir
+git pull
+bash $DIR/checks/backups.sh
-- 
GitLab