mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-06-10 08:37:02 +00:00
make database dump logic even more failure proof (#8286)
This commit is contained in:
@@ -13,6 +13,8 @@ esac)"
|
|||||||
export POSTGRES_LOG_MIN_MESSAGES
|
export POSTGRES_LOG_MIN_MESSAGES
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
|
GREP_STRING='Name: oc_appconfig; Type: TABLE; Schema: public; Owner:'
|
||||||
|
export GREP_STRING
|
||||||
DATADIR="/var/lib/postgresql/data"
|
DATADIR="/var/lib/postgresql/data"
|
||||||
export DUMP_DIR="/mnt/data"
|
export DUMP_DIR="/mnt/data"
|
||||||
DUMP_FILE="$DUMP_DIR/database-dump.sql"
|
DUMP_FILE="$DUMP_DIR/database-dump.sql"
|
||||||
@@ -103,7 +105,6 @@ if ( [ -f "$DATADIR/PG_VERSION" ] && [ "$PG_MAJOR" != "$(cat "$DATADIR/PG_VERSIO
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Check if the line we grep for later on is there
|
# Check if the line we grep for later on is there
|
||||||
GREP_STRING='Name: oc_appconfig; Type: TABLE; Schema: public; Owner:'
|
|
||||||
if ! grep -qa "$GREP_STRING" "$DUMP_FILE"; then
|
if ! grep -qa "$GREP_STRING" "$DUMP_FILE"; then
|
||||||
echo "The needed oc_appconfig line is not there which is unexpected."
|
echo "The needed oc_appconfig line is not there which is unexpected."
|
||||||
echo "Please report this to https://github.com/nextcloud/all-in-one/issues. Thanks!"
|
echo "Please report this to https://github.com/nextcloud/all-in-one/issues. Thanks!"
|
||||||
@@ -239,6 +240,12 @@ do_database_dump() {
|
|||||||
rm -f "$DUMP_FILE"
|
rm -f "$DUMP_FILE"
|
||||||
mv "$DUMP_FILE.temp" "$DUMP_FILE"
|
mv "$DUMP_FILE.temp" "$DUMP_FILE"
|
||||||
pg_ctl stop -m fast
|
pg_ctl stop -m fast
|
||||||
|
if ! grep -qa "$GREP_STRING" "$DUMP_FILE"; then
|
||||||
|
echo "Database dump was successful but the expected grep string does not exist."
|
||||||
|
echo "This is not expected!"
|
||||||
|
echo "Please report this to https://github.com/nextcloud/all-in-one/issues."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
rm "$DUMP_DIR/export.failed"
|
rm "$DUMP_DIR/export.failed"
|
||||||
echo 'Database dump successful!'
|
echo 'Database dump successful!'
|
||||||
if [ "$AIO_LOG_LEVEL" != 'debug' ]; then
|
if [ "$AIO_LOG_LEVEL" != 'debug' ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user