mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
wekan.database-restore and wekan.database-backup talked to whatever was on the database port and nothing else. After `snap stop wekan`, which the restore steps tell people to run, nothing is there; on a FerretDB snap the database is its own service that starting WeKan alone does not bring back. The tools then failed after a 30-second server-selection timeout with a driver topology dump naming neither the service nor its log. The new bin/database-ready asks bin/database-role which database holds the data, starts that service when nothing answers, waits for it, and when it still does not answer stops with the driver's own error and the `snap logs` / `snap services` commands that show the reason. A "permission denied" is explained as a security-policy denial on this system, not the database, with the journal command that names the rule. WeKan's own wait for FerretDB discarded the ping error, so its log said only "FerretDB not ready yet" for every cause. db-eval now prints why a command failed on stderr, and the wait's one-time hint shows it. The same hint suggested `snap set wekan database=mongodb`, a setting the configure hook removes, so that advice did nothing; it is gone. The backup script also sources its settings and passes the archive path quoted now, so a path with a space works. tests/snapDatabaseRestore.test.cjs runs both scripts in a stand-in snap: FerretDB or MongoDB started by role, a running database left alone, and, negatively, a database that never answers stopping the tool before it runs, with the error shown. A source guard requires both tools to wait for the database first. tests/ferretdbWaitTimeout.test.cjs now requires the ping error in the hint and rejects the removed setting. Not run inside an installed snap here. Thanks to fabiosalles and xet7 !
39 lines
1.4 KiB
Bash
Executable File
39 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [[ "$PATH" != *"$SNAP_INSTANCE_NAME"* ]]; then
|
|
export PATH="${PATH/\/snap\/wekan\//\/snap\/$SNAP_INSTANCE_NAME\/}"
|
|
fi
|
|
|
|
# get wekan/mongo settings
|
|
source "$SNAP/bin/wekan-read-settings"
|
|
|
|
# make sure we have set minimum env variables for locale
|
|
if [ -z "$LANG" ]; then
|
|
export LANG=en_US.UTF-8
|
|
fi
|
|
|
|
export LC_ALL=C
|
|
|
|
# If CPU does not support AVX, use Qemu that supports AVX.
|
|
# Migratemongo is at https://github.com/wekan/migratemongo
|
|
# and at directory /snap/${SNAP_NAME}/current/migratemongo/avx
|
|
# is bash scripts like mongod, mongosh check avx support and use Qemu if needed.
|
|
export PATH=$SNAP/migratemongo/avx:$SNAP/usr/bin:$SNAP/bin:$PATH
|
|
export LD_LIBRARY_PATH=$SNAP/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/lib/aarch64-linux-gnu:$LD_LIBRARY_PATH
|
|
|
|
if [ -z "$1" ]; then
|
|
DATE=`/bin/date +%Y%m%dT%H%M%S`
|
|
mkdir -p "$SNAP_COMMON/db-backups/"
|
|
ARCHIVE="$SNAP_COMMON/db-backups/wekan-$DATE.backup"
|
|
else
|
|
ARCHIVE="$1"
|
|
fi
|
|
# start mongodb backup
|
|
[ "x" == "x${MONGODB_BIND_IP}" ] && MONGODB_BIND_IP="127.0.0.1"
|
|
echo "using bind ip: $MONGODB_BIND_IP port: $MONGODB_PORT"
|
|
# #6746: same as database-restore - back up the database that holds the data,
|
|
# starting it first when it is stopped.
|
|
source "$SNAP/bin/database-ready"
|
|
database_ready "$MONGODB_BIND_IP" "$MONGODB_PORT" || exit 1
|
|
mongodump --host "$MONGODB_BIND_IP" --port "$MONGODB_PORT" -d wekan --gzip "--archive=${ARCHIVE}"
|