added backup sql script

This commit is contained in:
jules 2020-11-01 12:29:40 +01:00
parent 2d33b4859e
commit c8d6386dd4

26
scripts/backup_sql.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/sh
#
# this backs up the database from the wikibase-docker_mysql_1 container
# gnd, 2020
#######################################################################
# set some parameters here
DATUM=`date +%D|sed 's/\//_/g'`
CONTAINER="wikibase-docker_mysql_1"
DB_USER="SECRET USER NAME"
DB_PASS="SECRET PASSWORD"
DB_NAME="SECRET DB NAME"
# dump database
echo "Dumping $DB_NAME"
docker exec $CONTAINER mysqldump -u $DB_USER -p$DB_PASS $DB_NAME -r /tmp/$DB_NAME-$DATUM.sql
# copy db dump to /root
echo "Copying $DB_NAME"
docker cp $CONTAINER:/tmp/$DB_NAME-$DATUM.sql /root/$DB_NAME-$DATUM.sql
# delete the dump from the container to save up space
docker exec $CONTAINER rm /tmp/$DB_NAME-$DATUM.sql
# done !
echo "Done"