]> git.parisson.com Git - docker-django-scripts.git/commitdiff
gzip mysql dump, cleanup
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 17 Oct 2017 14:17:32 +0000 (16:17 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 17 Oct 2017 14:17:32 +0000 (16:17 +0200)
db/backup.sh
db/restore.sh

index f06c870ba387a65d7365ea342a99160a7f2ce84d..3ea532726c1a6fe0210775bd098ef0224bfd7948 100755 (executable)
@@ -1,19 +1,15 @@
 #!/bin/bash
 
 # dump postgres or mysql functions of the database
-export POSTGRES="$(dpkg --get-selections  | grep postgres 2>&1)"
-export MYSQL="$(dpkg --get-selections  | grep mysql 2>&1)"
+export POSTGRES="$(dpkg --get-selections  | grep postgres 2>&1)"
+export MYSQL="$(dpkg --get-selections  | grep mysql 2>&1)"
 
-if [ ! -z "$MYSQL" ];
-    then
+if [ ! -z "$MYSQL_PASSWORD" ]; then
     export MYSQL_PWD=$MYSQL_PASSWORD
-    mysqldump $MYSQL_DATABASE -hdb -u$MYSQL_USER > /srv/backup/mariadb.dump
-elif [ ! -z "$POSTGRES" ];
-    then
-    export PGUSER="postgres"
+    mysqldump $MYSQL_DATABASE -hdb -u$MYSQL_USER | gzip > /srv/backup/mariadb.dump
+elif [ ! -z "$POSTGRES_PASSWORD" ]; then
     export PGPASSWORD=$POSTGRES_PASSWORD
-    export PGDATABASE="postgres"
-    pg_dump -Fc -hdb > /srv/backup/postgres.dump
+    pg_dump -Fc -hdb -Upostgres -dpostgres > /srv/backup/postgres.dump
 fi
 
 echo "Backup done!"
index 3531fe72e73e8edb8c76e0d2b2838608e14ec546..480b3f0ee99098ad266ce971f4a9ff72e5af3eba 100755 (executable)
@@ -4,15 +4,11 @@
 # export POSTGRES="$(dpkg --get-selections  | grep postgres 2>&1)"
 # export MYSQL="$(dpkg --get-selections  | grep mysql 2>&1)"
 
-if [ ! -z "$MYSQL_ROOT_PASSWORD" ];
-    then
+if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then
     export MYSQL_PWD=$MYSQL_ROOT_PASSWORD
-    mysql -h db $MYSQL_DATABASE -uroot < /srv/backup/mariadb.dump
-elif [ ! -z "$POSTGRES_PASSWORD" ];
-    then
-    # export PGUSER="postgres"
+    gunzip < /srv/backup/mariadb.dump | mysql -h db $MYSQL_DATABASE -uroot
+elif [ ! -z "$POSTGRES_PASSWORD" ]; then
     export PGPASSWORD=$POSTGRES_PASSWORD
-    # export PGDATABASE="postgres"
     pg_restore -c -hdb -Upostgres -dpostgres  /srv/backup/postgres.dump
 fi