Browse Source

Zmena zpusobu deploy a backupu

remotes/origin/noc
Tomas Gavenciak 9 years ago
parent
commit
ecbf18e975
  1. 84
      Makefile
  2. 10
      backup_prod_db.sh

84
Makefile

@ -58,59 +58,33 @@ schema_seminar.pdf:
schema_all.pdf:
./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf
# remote commands
TEST_USER=test-mam
TEST_SERVER=atrey.karlin.mff.cuni.cz
TEST_DIR=/home/test-mam/mamweb-test/
PROD_USER=test-mam
PROD_SERVER=atrey.karlin.mff.cuni.cz
PROD_DIR=/home/test-mam/mamweb-prod/
HEAD=`git log --color=never |head -1|sed 's/.*commit //'`
push_test:
@echo "Checking out commited HEAD (${HEAD}) state at ${TEST_SSH} ..."
git tag deploy-test-`date +%Y-%m-%d-%H-%M`-${USER}
git push --all
ssh ${TEST_USER}@${TEST_SERVER} -n -x "\
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."
# 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.
# Deploy to current *mamweb-prod* directory
deploy_prod:
@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 ..."
cd .. && ./backup_prod_db.sh
@echo "Installing version from origin/stable ..."
git pull origin stable
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.

10
backup_prod_db.sh

@ -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.
Loading…
Cancel
Save