From 9a572457844d244562831192a2ba1047e15d01b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Mon, 25 Jul 2016 20:57:35 +0200 Subject: [PATCH] =?UTF-8?q?Makefile:=20synchronizace=20testu=20s=20produkc?= =?UTF-8?q?=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index a397f44b..e755aa55 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean_env init_env clean_virtualenv install_packages clean install run all schema_seminar.pdf schema_all.pdf +.PHONY: clean_env init_env clean_virtualenv install_packages clean install run all schema_seminar.pdf schema_all.pdf sync_test_media sync_test_db sync_test sync_local_media sync_local_db sync_local PYTHON=python2.7 VE_VER=13.1.2 LOCAL_PYTHON=bin/python @@ -93,16 +93,36 @@ deploy_prod: touch mamweb/wsgi.py @echo Done. + +# Sync test media directory with production +sync_test_media: + @if [ ${USER} != "www-mam" ]; then echo "Only possible by user www-mam"; exit 1; fi + @if [ `pwd` != "/akce/MaM/WWW/mamweb-test" ]; then echo "Only possible in /akce/MaM/WWW/mamweb-test"; exit 1; fi + rsync -av /akce/MaM/WWW/mamweb-prod/media/ ./media + +# Sync test database with production database +sync_test_db: + @if [ ${USER} != "www-mam" ]; then echo "Only possible by user www-mam"; exit 1; fi + pg_dump mam-test -U mam > dump-test-`date +"%Y%m%d_%H%M"`.sql + pg_dump -Fc mam-prod -U mam > dump-prod.sql + pg_restore -c -d mam-test -U mam dump-prod.sql + rm dump-prod.sql + @echo Done. + +# Sync test with production +sync_test: sync_test_media sync_test_db + + # Sync media directory with atrey. Useful for local development with production database # Does not sync Galerie and CACHE (too huge). -sync_media: +sync_local_media: rsync -ave ssh --exclude Galerie --exclude CACHE\ atrey.karlin.mff.cuni.cz:/akce/MaM/WWW/mamweb-prod/media/ ./media/ # Downloads and restores production database to local database. PostgreSQL only. -sync_db: +sync_local_db: scp atrey.karlin.mff.cuni.cz:`ssh atrey.karlin.mff.cuni.cz 'ls -v /akce/MaM/WWW/backups/mam-prod-*\.pgdump | tail -n 1'` \ ./last.pgdump pg_restore -c -d mam -U mam last.pgdump # Sync database and media. See above lines -sync: sync_media sync_db +sync_local: sync_media sync_db