Makefile: synchronizace testu s produkcí
This commit is contained in:
		
							parent
							
								
									86d63f2fef
								
							
						
					
					
						commit
						9a57245784
					
				
					 1 changed files with 24 additions and 4 deletions
				
			
		
							
								
								
									
										28
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								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 | PYTHON=python2.7 | ||||||
| VE_VER=13.1.2 | VE_VER=13.1.2 | ||||||
| LOCAL_PYTHON=bin/python | LOCAL_PYTHON=bin/python | ||||||
|  | @ -93,16 +93,36 @@ deploy_prod: | ||||||
| 	touch mamweb/wsgi.py | 	touch mamweb/wsgi.py | ||||||
| 	@echo Done. | 	@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
 | # Sync media directory with atrey. Useful for local development with production database
 | ||||||
| # Does not sync Galerie and CACHE (too huge). 
 | # Does not sync Galerie and CACHE (too huge). 
 | ||||||
| sync_media: | sync_local_media: | ||||||
| 	rsync -ave ssh --exclude Galerie --exclude CACHE\
 | 	rsync -ave ssh --exclude Galerie --exclude CACHE\
 | ||||||
| 		atrey.karlin.mff.cuni.cz:/akce/MaM/WWW/mamweb-prod/media/ ./media/ | 		atrey.karlin.mff.cuni.cz:/akce/MaM/WWW/mamweb-prod/media/ ./media/ | ||||||
| # Downloads and restores production database to local database. PostgreSQL only. 
 | # 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'` \
 | 	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 | 		./last.pgdump | ||||||
| 	pg_restore -c -d mam -U mam last.pgdump | 	pg_restore -c -d mam -U mam last.pgdump | ||||||
| 
 | 
 | ||||||
| # Sync database and media. See above lines
 | # Sync database and media. See above lines
 | ||||||
| sync: sync_media sync_db | sync_local: sync_media sync_db | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Matěj Kocián
						Matěj Kocián