fix db backup script

This commit is contained in:
finn 2024-08-07 13:51:46 +00:00
parent d1d64b181a
commit 1ced0d8b24

View File

@ -1,16 +1,27 @@
#!/bin/bash #!/bin/bash
# copy do db mount, use as helper # dump sql db backups
#
if [[ -z $1 ]] ; then if [[ -z $1 ]] ; then
echo "dbbu.sh <gitea|flask> <rootpass>" echo "dbbu.sh <gitea|flask|all>"
exit 0 exit 0
fi fi
if [[ $1 == "gitea" ]] ; then source ../.env
mariadb-dump -uroot -p$2 gitea > gitea_bu_$(date +%s).sql source .env
TIMESTAMP=$(date +%s)
if [[ $1 == "gitea" || $1 == "all" ]] ; then
docker-compose exec db bash -c "mariadb-dump -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD gitea > /bu/gitea_bu_$TIMESTAMP.sql"
docker-compose exec db chmod a+rw /bu/gitea_bu_$TIMESTAMP.sql
docker-compose exec db chown ubuntu:ubuntu /bu/gitea_bu_$TIMESTAMP.sql
fi fi
if [[ $1 == "flask" ]] ; then if [[ $1 == "flask" || $1 == "all" ]] ; then
mariadb-dump -uroot -p$2 flask > flask_bu_$(date +%s).sql docker-compose exec db echo $DOTENV_MYSQL_ROOT_PASSWORD
docker-compose exec db bash -c "mariadb-dump -uroot -p$DOTENV_MYSQL_ROOT_PASSWORD flask > /bu/flask_bu_$TIMESTAMP.sql"
docker-compose exec db chmod a+rw /bu/flask_bu_$TIMESTAMP.sql
docker-compose exec db chown ubuntu:ubuntu /bu/flask_bu_$TIMESTAMP.sql
fi fi