From: Guillaume Pellerin Date: Mon, 29 Feb 2016 16:54:19 +0000 (+0100) Subject: add scripts dir and full restore / backup scripts X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=36f2fbb44511ab7ccff13202ecfd38cf99b861f2;p=mezzo.git add scripts dir and full restore / backup scripts --- diff --git a/app/festival/templates/festival/artist_detail.html b/app/festival/templates/festival/artist_detail.html index 5e12a66b..18fbda58 100644 --- a/app/festival/templates/festival/artist_detail.html +++ b/app/festival/templates/festival/artist_detail.html @@ -10,7 +10,9 @@

- + {% if artist.photo %} + + {% endif %} {{ artist.bio|safe }}

diff --git a/docker-compose.yml b/docker-compose.yml index aeff9eca..cac1294c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,6 +33,7 @@ db: - data volumes: - ./data/var/lib/mysql/:/var/lib/mysql + - ./scripts/:/srv/scripts environment: - MYSQL_ROOT_PASSWORD=hyRob0otlaz4 - MYSQL_DATABASE=manifeste diff --git a/scripts/backup.sh b/scripts/backup.sh new file mode 100755 index 00000000..14175e77 --- /dev/null +++ b/scripts/backup.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +docker-compose run db /srv/scripts/backup_db.sh +git add data/media +git commit -a -m "update DB and media" +git push diff --git a/scripts/backup_db.sh b/scripts/backup_db.sh new file mode 100755 index 00000000..d3d4d26b --- /dev/null +++ b/scripts/backup_db.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +mysqldump -hdb -uroot -phyRob0otlaz4 manifeste | gzip > /srv/backup/manifeste.sql.gz diff --git a/scripts/backup_db_eve.sh b/scripts/backup_db_eve.sh new file mode 100755 index 00000000..888a3c26 --- /dev/null +++ b/scripts/backup_db_eve.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +pg_dump -hpgdb -Upostgres eve | gzip > /srv/backup/eve.sql.gz diff --git a/scripts/restore.sh b/scripts/restore.sh new file mode 100755 index 00000000..271fe776 --- /dev/null +++ b/scripts/restore.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +sudo chown -R $USER ../data/media +sudo chown -R $USER ../data/backup +git pull +docker-compose run db /srv/scripts/restore_db.sh diff --git a/scripts/restore_db.sh b/scripts/restore_db.sh new file mode 100755 index 00000000..04a3f725 --- /dev/null +++ b/scripts/restore_db.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +gunzip < /srv/backup/manifeste.sql.gz | mysql -hdb -uroot -phyRob0otlaz4 manifeste +echo "Restore done!" diff --git a/scripts/restore_db_eve.sh b/scripts/restore_db_eve.sh new file mode 100755 index 00000000..d29766d6 --- /dev/null +++ b/scripts/restore_db_eve.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +export PGPASSWORD="mysecretpassword" +db_exists=`psql -hpgdb -Upostgres -lqt | cut -d \| -f 1 | grep -w eve | wc -l` + +if [ $db_exists == 0 ]; then + psql -hpgdb -Upostgres -c 'create role eve' +else + psql -hpgdb -Upostgres -c 'drop database eve' +fi + +psql -hpgdb -Upostgres -c 'create database eve' +gunzip -c /srv/backup/eve.sql.gz | psql -hpgdb -Upostgres -q eve