Browse Source

Deploy skript a zaloha DB pred kazdym updatem

remotes/origin/feincms
Tomas Gavenciak 10 years ago
parent
commit
6ed4c61041
  1. 27
      Makefile
  2. 10
      backup_prod_db.sh

27
Makefile

@ -58,13 +58,18 @@ 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
TEST_USER=test-mam TEST_USER=test-mam
TEST_SERVER=atrey.karlin.mff.cuni.cz TEST_SERVER=atrey.karlin.mff.cuni.cz
TEST_DIR=/home/test-mam/mamweb-test/ TEST_DIR=/home/test-mam/mamweb-test/
# remote commands 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 //'` HEAD=`git log --color=never |head -1|sed 's/.*commit //'`
push_test: push_test:
@echo "Checking out commited HEAD (${HEAD}) state at ${TEST_SSH} ..." @echo "Checking out commited HEAD (${HEAD}) state at ${TEST_SSH} ..."
git push --all git push --all
@ -80,6 +85,24 @@ push_test:
(chown -Rf :mam . || true ) && \ (chown -Rf :mam . || true ) && \
(chmod -Rf g+w . || true ) && \ (chmod -Rf g+w . || true ) && \
echo Done." echo Done."
@echo "Test deployed at ${TEST_SERVER}:${TEST_DIR} successfully." @echo "Test pushed to ${TEST_SERVER}:${TEST_DIR} successfully."
push_prod:
@echo "Checking out commited HEAD (${HEAD}) state at ${PROD_SSH} ..."
git push --all
ssh ${PROD_USER}@${PROD_SERVER} -n -x "\
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 Done."
@echo "Deployed to ${PROD_SERVER}:${PROD_DIR} successfully."

10
backup_prod_db.sh

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