Skip to content
Snippets Groups Projects
Verified Commit 41241f8f authored by David Beniamine's avatar David Beniamine
Browse files

Command to dump / restore database

parent 1d52b133
Branches
No related tags found
No related merge requests found
......@@ -27,8 +27,12 @@ usage() {
echo -e "\t displays this messages and exit"
echo "mysql"
echo -e "\topen a mysql prompt in LNB database"
echo "mysql_dump"
echo -e "\tcreates a database dump"
echo "mysql_init"
echo -e "\tpopulate LabNbook database (Docker only)"
echo "mysql_restore"
echo -e "\trestores database from a dump"
echo "restart"
echo -e "\t restart the docker stack or apache2"
echo "shell"
......@@ -72,6 +76,26 @@ case $action in
$cmdmy $mysql
set +x
;;
"mysql_dump")
$cmdmy mariadb-dump --databases $db -u $user -p$pass | gzip > ${db}_$(date +%Y%m%d_%H%M%S).sql.gz
;;
"mysql_restore")
if [ -z "$1" ]; then
echo "Usage $0 mysql_restore <file>"
exit 1
fi
read -p "Do you want to restore your database from file '$1' ? This command will erase your current data. (y/n). " yn
case $yn in
[Yy]* )
zcat $1 | $cmdmyInput $mysql
;;
[Nn]* )
exit
;;
* )
echo "Please answer yes or no.";;
esac
;;
"mysql_init")
read -p "Do you want to init your database with default data? This command will erase your current data. (y/n). " yn
case $yn in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment