MastodonHelp/web/clitools/maintain/restore.bash

21 lines
405 B
Bash
Raw Normal View History

2024-07-26 22:17:46 +02:00
#!/bin/bash
set -e
DBNAME="mastostart"
basedir=$(dirname "$0")
cd "${basedir}/backups"
xzfp=`ls -1 --time=birth -r *.xz 2>/dev/null | tail -n 1 2>/dev/null`
sqlfp=$(basename -s .xz "${xzfp}")
if [ -z "${xzfp}" ]; then
echo "No backup found :-(" 1>&2
else
echo "Uncompressing most recent backup file: «${xzfp}» ..."
xz -dk $xzfp
mariadb -u root -p "${DBNAME}" < "$sqlfp"
rm "${sqlfp}"
fi
exit 0