From 433e366b173a6a4154b859e85cd08bf0e28918cd Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Tue, 23 Jan 2018 14:58:43 +0000
Subject: [PATCH] Move to postgresql directory when doing backups

---
 src/freedombone-utils-backup | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/freedombone-utils-backup b/src/freedombone-utils-backup
index 3dc51a0de..befefd8e8 100755
--- a/src/freedombone-utils-backup
+++ b/src/freedombone-utils-backup
@@ -13,7 +13,7 @@
 # License
 # =======
 #
-# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
+# Copyright (C) 2014-2018 Bob Mottram <bob@freedombone.net>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
@@ -255,6 +255,7 @@ function backup_database_local_usb {
     else
         USE_MONGODB=
         USE_POSTGRESQL=
+        cd /etc/postgresql
         sudo -u postgres pg_dump ${1} > ${local_database_dir}/${1}.${database_file_extension}
     fi
     if [ -f ${local_database_dir}/${1}.${database_file_extension} ]; then
@@ -585,6 +586,7 @@ function backup_database_remote {
     else
         USE_MONGODB=
         USE_POSTGRESQL=
+        cd /etc/postgresql
         sudo -u postgres pg_dump ${1} > ${local_database_dir}/${1}.${database_file_extension}
     fi
 
@@ -701,6 +703,7 @@ function restore_database_from_friend {
         else
             USE_MONGODB=
             USE_POSTGRESQL=
+            cd /etc/postgresql
             mysqlsuccess=$(sudo -u postgres pg_restore ${database_file})
         fi
         if [ ! "$?" = "0" ]; then
@@ -799,6 +802,7 @@ function restore_database {
         else
             USE_MONGODB=
             USE_POSTGRESQL=
+            cd /etc/postgresql
             mysqlsuccess=$(sudo -u postgres pg_restore $database_file)
         fi
         if [ ! "$?" = "0" ]; then
-- 
GitLab