@@ -82,4 +82,111 @@ docker-compose -f local.yml up
82
82
docker-compose -f local.yml run --rm django python manage.py createsuperuser
83
83
```
84
84
85
- 8 . Log in to the SDE Indexing Helper frontend to ensure that all data has been correctly populated in the UI.
85
+ 8 . Log in to the COSMOS frontend to ensure that all data has been correctly populated in the UI.
86
+
87
+
88
+
89
+ # making the backup
90
+
91
+ ``` bash
92
+ ssh sde
93
+ cat .envs/.production/.postgres
94
+ ```
95
+
96
+ find the values for the variables:
97
+ POSTGRES_HOST=sde-indexing-helper-db.c3cr2yyh5zt0.us-east-1.rds.amazonaws.com
98
+ POSTGRES_PORT=5432
99
+ POSTGRES_DB=postgres
100
+ POSTGRES_USER=postgres
101
+ POSTGRES_PASSWORD=this_is_A_web_application_built_in_2023
102
+
103
+ ``` bash
104
+ docker ps
105
+ ```
106
+
107
+ b3fefa2c19fb
108
+
109
+ note here that you need to put the
110
+ ``` bash
111
+ docker exec -t your_postgres_container_id pg_dump -U your_postgres_user -d your_database_name > backup.sql
112
+ ```
113
+ ``` bash
114
+ docker exec -t container_id pg_dump -h host -U user -d database -W > prod_backup.sql
115
+ ```
116
+
117
+ docker exec -t b3fefa2c19fb env PGPASSWORD="this_is_A_web_application_built_in_2023" pg_dump -h sde-indexing-helper-db.c3cr2yyh5zt0.us-east-1.rds.amazonaws.com -U postgres -d postgres > prod_backup.sql
118
+
119
+ # move the backup to local
120
+ go back to local computer and scp the file
121
+
122
+ ``` bash
123
+ scp sde:/home/ec2-user/sde_indexing_helper/prod_backup.sql .
124
+ ```
125
+ scp prod_backup.sql sde_staging:/home/ec2-user/sde-indexing-helper
126
+ if you have trouble transferring the file, you can use rsync:
127
+ rsync -avzP prod_backup.sql sde_staging:/home/ec2-user/sde-indexing-helper/
128
+
129
+ # restoring the backup
130
+ bring down the local containers
131
+ ``` bash
132
+ docker-compose -f local.yml down
133
+ docker-compose -f local.yml up postgres
134
+ docker ps
135
+ ```
136
+
137
+ find the container id
138
+
139
+ c11d7bae2e56
140
+
141
+ find the local variables from
142
+ cat .envs/.production/.postgres
143
+ POSTGRES_HOST=sde-indexing-helper-staging-db.c3cr2yyh5zt0.us-east-1.rds.amazonaws.com
144
+ POSTGRES_PORT=5432
145
+ POSTGRES_DB=sde_staging
146
+ POSTGRES_USER=postgres
147
+ POSTGRES_PASSWORD=postgres
148
+
149
+
150
+ ``` bash
151
+ docker exec -it < container id> bash
152
+ ```
153
+ docker exec -it c11d7bae2e56 bash
154
+
155
+ ## do all the database shit you need to
156
+
157
+
158
+ psql -U <POSTGRES_USER> -d <POSTGRES_DB>
159
+ psql -U postgres -d sde_staging
160
+ or, if you are on one of the servers:
161
+ psql -h sde-indexing-helper-staging-db.c3cr2yyh5zt0.us-east-1.rds.amazonaws.com -U postgres -d postgres
162
+
163
+ \c postgres
164
+ DROP DATABASE sde_staging;
165
+ CREATE DATABASE sde_staging;
166
+
167
+ # do the backup
168
+
169
+ ``` bash
170
+ docker cp prod_backup.sql c11d7bae2e56:/
171
+ docker exec -it c11d7bae2e56 bash
172
+ ```
173
+
174
+ ``` bash
175
+ psql -U < POSTGRES_USER> -d < POSTGRES_DB> -f backup.sql
176
+ ```
177
+ psql -U VnUvMKBSdkoFIETgLongnxYHrYVJKufn -d sde_indexing_helper -f prod_backup.sql
178
+
179
+ psql -h sde-indexing-helper-staging-db.c3cr2yyh5zt0.us-east-1.rds.amazonaws.com -U postgres -d postgres -f prod_backup.sql
180
+ pg_restore -h sde-indexing-helper-staging-db.c3cr2yyh5zt0.us-east-1.rds.amazonaws.com -U postgres -d postgres prod_backup.sql
181
+
182
+
183
+
184
+ docker down
185
+
186
+ docker up build
187
+
188
+ migrate
189
+
190
+ down
191
+
192
+ up
0 commit comments