crowdsec/tests/instance-sqlite
Manuel Sabban b792c45921
Mysql enabled tests (#1372)
* add msyql backend test

Co-authored-by: sabban <15465465+sabban@users.noreply.github.com>
2022-03-18 17:36:51 +01:00

58 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
set -eu
script_name=$0
die() {
echo >&2 "$@"
exit 1
}
about() {
die "usage: $script_name [backup | restore] <backup_file>"
}
#shellcheck disable=SC1007
THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cd "${THIS_DIR}"
#shellcheck disable=SC1090
. ./.environment.sh
# you have not removed set -u above, have you?
[ -z "${CONFIG_YAML-}" ] && die "\$CONFIG_YAML must be defined."
# ---------------------------
[ $# -lt 1 ] && about
./assert-crowdsec-not-running
DB_FILE="${DATA_DIR}/crowdsec.db"
case "$1" in
configure)
;;
setup)
;;
cleanup)
;;
backup)
[ $# -lt 2 ] && about
backup_file="$2"
# dirty fast cp. nothing should be accessing it right now, anyway.
[ -f "${DB_FILE}" ] || die "missing file ${DB_FILE}"
cp "${DB_FILE}" "$backup_file"
;;
restore)
[ $# -lt 2 ] && about
backup_file="$2"
[ -f "$backup_file" ] || die "missing file $backup_file"
cp "$backup_file" "${DB_FILE}"
;;
*)
about
;;
esac;