Browse Source

added backup sql script

master
jules 4 years ago
parent
commit
c8d6386dd4
  1. 26
      scripts/backup_sql.sh

26
scripts/backup_sql.sh

@ -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"
Loading…
Cancel
Save