21 lines
405 B
Bash
21 lines
405 B
Bash
|
#!/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
|