Zmena zpusobu deploy a backupu

This commit is contained in:
Tomas Gavenciak 2015-09-14 22:59:25 +02:00
parent bb975e0eb2
commit ecbf18e975
2 changed files with 28 additions and 64 deletions

View file

@ -58,59 +58,33 @@ schema_seminar.pdf:
schema_all.pdf: schema_all.pdf:
./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf ./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf
# remote commands # Deploy to current *mamweb-test* directory
deploy_test:
@if [[ `pwd` != "/akce/MaM/WWW/mamweb-test" ]]; then echo "Only possible in /akce/MaM/WWW/mamweb-test"; exit 1; fi
@echo "Installing version from origin/master ..."
git pull origin master
git clean -f
make install
./manage.py migrate
./manage.py collectstatic --noinput
(chown -Rf :mam . || true )
(chmod -Rf g+w . || true )
touch mamweb/wsgi.py
@echo Done.
TEST_USER=test-mam # Deploy to current *mamweb-prod* directory
TEST_SERVER=atrey.karlin.mff.cuni.cz deploy_prod:
TEST_DIR=/home/test-mam/mamweb-test/ @if [[ `pwd` != "/akce/MaM/WWW/mamweb-prod" ]]; then echo "Only possible in /akce/MaM/WWW/mamweb-prod"; exit 1; fi
@echo "Backing up production DB ..."
PROD_USER=test-mam cd .. && ./backup_prod_db.sh
PROD_SERVER=atrey.karlin.mff.cuni.cz @echo "Installing version from origin/stable ..."
PROD_DIR=/home/test-mam/mamweb-prod/ git pull origin stable
git clean -f
HEAD=`git log --color=never |head -1|sed 's/.*commit //'` make install
./manage.py migrate
push_test: ./manage.py collectstatic --noinput
@echo "Checking out commited HEAD (${HEAD}) state at ${TEST_SSH} ..." (chown -Rf :mam . || true )
git tag deploy-test-`date +%Y-%m-%d-%H-%M`-${USER} (chmod -Rf g+w . || true )
git push --all touch mamweb/wsgi.py
ssh ${TEST_USER}@${TEST_SERVER} -n -x "\ @echo Done.
cd ${TEST_DIR} && \
git fetch --all && \
git checkout ${HEAD} -f && \
git clean -f && \
cp mamweb/settings_test.py mamweb/settings.py && \
make install && \
./manage.py collectstatic --noinput && \
./manage.py migrate --noinput && \
(chown -Rf :mam . || true ) && \
(chmod -Rf g+w . || true ) && \
echo 'Reloading apache ... (You may have to start it manually on error!)' && \
~/etc/apache2/apache2ctl -k restart && \
echo Done."
@echo "Test pushed to ${TEST_SERVER}:${TEST_DIR} successfully."
push_prod:
@echo "Checking out commited HEAD (${HEAD}) state at ${PROD_SSH} ..."
git tag deploy-prod-`date +%Y-%m-%d-%H-%M`-${USER}
git push --all
ssh ${PROD_USER}@${PROD_SERVER} -n -x "\
echo 'Stopping apache ... (You may have to start it manually on error!)' && \
~/etc/apache2/apache2ctl -k stop && \
cd ${PROD_DIR} && \
./backup_prod_db.sh && \
git fetch --all && \
git checkout ${HEAD} -f && \
git clean -f && \
cp mamweb/settings_prod.py mamweb/settings.py && \
make install && \
./manage.py collectstatic --noinput && \
./manage.py migrate --noinput && \
(chown -Rf :mam . || true ) && \
(chmod -Rf g+w . || true ) && \
echo 'Starting apache ... (You may have to start it manually on error!)' && \
~/etc/apache2/apache2ctl -k start && \
echo Done."
@echo "Deployed to ${PROD_SERVER}:${PROD_DIR} successfully."

View file

@ -1,10 +0,0 @@
#!/bin/bash
DBNAME=mam-prod
FNAME=backup-db/$DBNAME-`date '+%F-%T'`.bz2
echo Backing up production DB $DBNAME to $FNAME ...
pg_dump $DBNAME -U mam | bzip2 -9 > $FNAME
echo Done.