Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/vm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2022-06-30 19:48:42 +0300
committerGitHub <noreply@github.com>2022-06-30 19:48:42 +0300
commit961c3862dfffbf3dfc001b73bda90414e09123fb (patch)
tree310301b600ea1d80030086b80b4c1ddecc46f299
parentf45a3d29d90573dbdce4ebf8605d3696b6a9ebb9 (diff)
use the `.dump` name for postgres exports and imports (#2359)
Signed-off-by: szaimen <szaimen@e.mail.de>
-rw-r--r--not-supported/borgbackup.sh16
-rw-r--r--not-supported/restore-backup.sh26
2 files changed, 28 insertions, 14 deletions
diff --git a/not-supported/borgbackup.sh b/not-supported/borgbackup.sh
index ae1d6043..2330a031 100644
--- a/not-supported/borgbackup.sh
+++ b/not-supported/borgbackup.sh
@@ -280,19 +280,19 @@ Please don't restart or shutdown your server until then!"
# Database export
# Not really necessary since the root partition gets backed up but easier to restore on new systems
ncdb # get NCDB
- rm -f "$SCRIPTS"/nextclouddb.sql
- rm -f "$SCRIPTS"/alldatabases.sql
+ rm -f "$SCRIPTS"/nextclouddb.sql "$SCRIPTS"/nextclouddb.dump
+ rm -f "$SCRIPTS"/alldatabases.sql "$SCRIPTS"/alldatabases.dump
if sudo -Hiu postgres psql -c "SELECT 1 AS result FROM pg_database WHERE datname='$NCDB'" | grep -q "1 row"
then
inform_user "$ICyan" "Doing pgdump of $NCDB..."
- sudo -Hiu postgres pg_dump "$NCDB" > "$SCRIPTS"/nextclouddb.sql
- chown root:root "$SCRIPTS"/nextclouddb.sql
- chmod 600 "$SCRIPTS"/nextclouddb.sql
+ sudo -Hiu postgres pg_dump "$NCDB" > "$SCRIPTS"/nextclouddb.dump
+ chown root:root "$SCRIPTS"/nextclouddb.dump
+ chmod 600 "$SCRIPTS"/nextclouddb.dump
else
inform_user "$ICyan" "Doing pgdump of all databases..."
- sudo -Hiu postgres pg_dumpall > "$SCRIPTS"/alldatabases.sql
- chown root:root "$SCRIPTS"/alldatabases.sql
- chmod 600 "$SCRIPTS"/alldatabases.sql
+ sudo -Hiu postgres pg_dumpall > "$SCRIPTS"/alldatabases.dump
+ chown root:root "$SCRIPTS"/alldatabases.dump
+ chmod 600 "$SCRIPTS"/alldatabases.dump
fi
systemctl stop postgresql
diff --git a/not-supported/restore-backup.sh b/not-supported/restore-backup.sh
index 1d147879..af26f07b 100644
--- a/not-supported/restore-backup.sh
+++ b/not-supported/restore-backup.sh
@@ -416,7 +416,7 @@ then
exit 1
fi
-if ! [ -f "$SYSTEM_DIR/$SCRIPTS/nextclouddb.sql" ]
+if ! [ -f "$SYSTEM_DIR/$SCRIPTS/nextclouddb.sql" ] && ! [ -f "$SYSTEM_DIR/$SCRIPTS/nextclouddb.dump" ]
then
msg_box "Could not find database dump. this is not supported."
umount "$BORG_MOUNT"
@@ -502,12 +502,26 @@ DB_PASSWORD=$(grep "dbpassword" "$SYSTEM_DIR/$NCPATH/config/config.php" | awk '{
sudo -Hiu postgres psql nextcloud_db -c "ALTER USER ncadmin WITH PASSWORD '$DB_PASSWORD'"
sudo -Hiu postgres psql -c "DROP DATABASE nextcloud_db;"
sudo -Hiu postgres psql -c "CREATE DATABASE nextcloud_db WITH OWNER ncadmin TEMPLATE template0 ENCODING \"UTF8\";"
-if ! sudo -Hiu postgres psql nextcloud_db < "$SCRIPTS/nextclouddb.sql"
+if [ -f "$SCRIPTS/nextclouddb.sql" ]
then
- msg_box "An issue was reported while restoring the database."
- umount "$BORG_MOUNT"
- umount "$DRIVE_MOUNT"
- exit 1
+ if ! sudo -Hiu postgres psql nextcloud_db < "$SCRIPTS/nextclouddb.sql"
+ then
+ msg_box "An issue was reported while restoring the database."
+ umount "$BORG_MOUNT"
+ umount "$DRIVE_MOUNT"
+ exit 1
+ fi
+fi
+
+if [ -f "$SCRIPTS/nextclouddb.dump" ]
+then
+ if ! sudo -Hiu postgres psql nextcloud_db < "$SCRIPTS/nextclouddb.dump"
+ then
+ msg_box "An issue was reported while restoring the database."
+ umount "$BORG_MOUNT"
+ umount "$DRIVE_MOUNT"
+ exit 1
+ fi
fi
# NTFS