From b20eec16df54e25816d3671f59a9ea98b8a26d8a Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Wed, 24 Jan 2018 17:03:14 +0000
Subject: [PATCH] Check that database backup exists

---
 src/freedombone-app-rss      |  8 +-------
 src/freedombone-utils-backup | 10 ++++++++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/freedombone-app-rss b/src/freedombone-app-rss
index 45c026cae..7cc02942a 100755
--- a/src/freedombone-app-rss
+++ b/src/freedombone-app-rss
@@ -169,9 +169,7 @@ function restore_local_rss {
     function_check get_mariadb_password
     get_mariadb_password
 
-    function_check rss_create_database
-    rss_create_database
-
+    function_check restore_database
     restore_database ttrss
 
     if [ -d /etc/share/tt-rss ]; then
@@ -252,10 +250,6 @@ function restore_remote_rss {
         get_mariadb_password
 
         function_check restore_database_from_friend
-
-        function_check rss_create_database
-        rss_create_database
-
         restore_database_from_friend ttrss
 
         if [ -d /etc/share/tt-rss ]; then
diff --git a/src/freedombone-utils-backup b/src/freedombone-utils-backup
index 80f57dadf..39e1de00c 100755
--- a/src/freedombone-utils-backup
+++ b/src/freedombone-utils-backup
@@ -583,7 +583,7 @@ function restore_database_from_friend {
     DATABASE_PASSWORD=
     RESTORE_SUBDIR="root"
 
-    if [ -d $SERVER_DIRECTORY/backup/${1} ]; then
+    if [ -d $SERVER_DIRECTORY/backup/${1}data ]; then
         database_file_extension='sql'
         if [ $USE_MONGODB ]; then
             database_file_extension='mdb'
@@ -666,6 +666,9 @@ function restore_database_from_friend {
                 fi
             fi
         fi
+    else
+        echo $"No database backup found for ${1}"
+        exit 6239353
     fi
 }
 
@@ -674,7 +677,7 @@ function restore_database {
     restore_app_name=$1
     restore_app_domain=$2
 
-    if [ -d $USB_MOUNT/backup/${restore_app_name} ]; then
+    if [ -d $USB_MOUNT/backup/${restore_app_name}data ]; then
         echo $"Restoring ${restore_app_name} database"
         local_database_dir=/root/temp${restore_app_name}data
         if [ -d ${local_database_dir} ]; then
@@ -776,6 +779,9 @@ function restore_database {
                 fi
             fi
         fi
+    else
+        echo $"No database backup found for ${restore_app_name}"
+        exit 7357224
     fi
 }
 
-- 
GitLab