-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
157 lines (130 loc) · 5.77 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# ------------------------------------------------------------------------
# Set this to the name of your project / website
# ------------------------------------------------------------------------
PROJECT_ID := inasafeorg
CONF_FILE := -f docker-compose.yml
CONF_HELP := Uses docker-compose.yml
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CONF_HELP := Detecting Linux Environment. Use docker-compose-linux.yml
CONF_FILE += -f docker-compose-linux.yml
endif
ifeq ($(UNAME_S),Darwin)
CONF_HELP := Detecting OSX Environment. Use docker-compose-osx.yml
CONF_FILE += -f docker-compose-osx.yml
endif
# ------------------------------------------------------------------------
# Should not normally need to change anything below this point....
# ------------------------------------------------------------------------
SHELL := /bin/bash
default: web
run: build web
build:
@echo
@echo "------------------------------------------------------------------"
@echo "Building "
@echo "------------------------------------------------------------------"
@echo $(CONF_HELP)
@docker-compose $(CONF_FILE) -p $(PROJECT_ID) build
web:
@echo
@echo "------------------------------------------------------------------"
@echo "Running "
@echo "------------------------------------------------------------------"
@echo $(CONF_HELP)
@docker-compose $(CONF_FILE) -p $(PROJECT_ID) up -d wordpress
@docker-compose $(CONF_FILE) -p $(PROJECT_ID) up -d btsync
dps
webwithrestore: kill rm web
@echo
@echo "------------------------------------------------------------------"
@echo "Running the restoring dump from backups/wordpress.sql "
@echo "------------------------------------------------------------------"
@sleep 10
@docker exec -t -i $(PROJECT_ID)_db_1 /backups/db-restore.sh
kill:
@echo
@echo "------------------------------------------------------------------"
@echo "Killing all containers!"
@echo "------------------------------------------------------------------"
@echo $(CONF_HELP)
@docker-compose $(CONF_FILE) -p $(PROJECT_ID) kill
rm: kill
@echo
@echo "------------------------------------------------------------------"
@echo "Removing all containers!!! "
@echo "------------------------------------------------------------------"
@echo $(CONF_HELP)
@docker-compose $(CONF_FILE) -p $(PROJECT_ID) rm
wplogs:
@echo
@echo "------------------------------------------------------------------"
@echo "Showing wordpress logs "
@echo "------------------------------------------------------------------"
@echo $(CONF_HELP)
@docker-compose $(CONF_FILE) -p $(PROJECT_ID) logs wordpress
dblogs:
@echo
@echo "------------------------------------------------------------------"
@echo "Showing mysql logs "
@echo "------------------------------------------------------------------"
@echo $(CONF_HELP)
@docker-compose $(CONF_FILE) -p $(PROJECT_ID) logs db
wpshell:
@echo
@echo "------------------------------------------------------------------"
@echo "Shelling in to wordpress (press enter to activate shell)"
@echo "------------------------------------------------------------------"
@echo $(CONF_HELP)
@docker-compose $(CONF_FILE) -p $(PROJECT_ID) run wordpress /bin/bash
dbshell:
@echo
@echo "------------------------------------------------------------------"
@echo "Shelling in to mysql (press enter to activate shell)"
@echo "------------------------------------------------------------------"
@docker exec -t -i $(PROJECT_ID)_db_1 /bin/bash
dbbackup:
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up mysql database"
@echo "------------------------------------------------------------------"
@docker exec -t -i $(PROJECT_ID)_db_1 /backups/db-backup.sh
@ls -lahtr `find ./backups -name *.sql` | tail -1
@docker exec -t -i $(PROJECT_ID)_sftpdbbackup_1 /backups.sh
dbrestore:
@echo
@echo "------------------------------------------------------------------"
@echo "Restoring wordpress.sql over current wordpress database"
@echo "You must ensure that the ./backups/wordpress.sql exists and is valid"
@echo "the existing wordpress database will be lost!"
@echo "------------------------------------------------------------------"
@docker exec -t -i $(PROJECT_ID)_db_1 /backups/db-restore.sh
wpbackup:
@echo
@echo "------------------------------------------------------------------"
@echo "Backing up wordpress files"
@echo "------------------------------------------------------------------"
@backups/wp-backup.sh
@docker exec -t -i $(PROJECT_ID)_sftpmediabackup_1 /backups.sh
pushbackup:
@echo
@echo "------------------------------------------------------------------"
@echo "Push local backup in sftpbackup to sftp remote server"
@echo "------------------------------------------------------------------"
@docker exec -t -i $(PROJECT_ID)_sftpdbbackup_1 /start.sh push-to-remote-sftp
@docker exec -t -i $(PROJECT_ID)_sftpmediabackup_1 /start.sh push-to-remote-sftp
pullbackup:
@echo
@echo "------------------------------------------------------------------"
@echo "Pull remote sftp backup to local backup"
@echo "------------------------------------------------------------------"
@docker exec -t -i $(PROJECT_ID)_sftpdbbackup_1 /start.sh pull-from-remote-sftp
@docker exec -t -i $(PROJECT_ID)_sftpmediabackup_1 /start.sh pull-from-remote-sftp
rsync:
@echo
@echo "------------------------------------------------------------------"
@echo "Rsyncing live wp site files"
@echo "------------------------------------------------------------------"
@rsync -av inasafe-docker:/home/data/inasafe.org/wp-content .
@rsync -av inasafe-docker:/home/data/inasafe.org/backups/wordpress.sql backups/wordpress.sql
@rsync -av --include '*/' --include='*.sql' --include="*.tar.gz" --exclude="*.zip" inasafe-docker:/home/data/inasafe.org/sftp_backup/backups/db backups/