Deploy skript a zaloha DB pred kazdym updatem
This commit is contained in:
parent
76a574c484
commit
6ed4c61041
2 changed files with 35 additions and 2 deletions
27
Makefile
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
Executable file
10
backup_prod_db.sh
Executable file
|
@ -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…
Reference in a new issue