forked from systemseed/falcon-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal-sql-dump.sh
More file actions
executable file
·35 lines (29 loc) · 1.11 KB
/
local-sql-dump.sh
File metadata and controls
executable file
·35 lines (29 loc) · 1.11 KB
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
#!/usr/bin/env bash
# TODO: Replace with your platform.sh project ID.
PROJECT_ID="fsdfsdfsfdfaaa"
PSH_ENV=master
DB_CONTAINERS=("be_donations_mariadb" "be_gifts_mariadb")
# If number of args passed is greater than 0
if [ $# -gt 0 ]; then
PSH_ENV=$1
fi
# Dump database for DONATIONS backend.
echo "Dumping Donations database..."
platform db:dump -y --project=$PROJECT_ID --environment=${PSH_ENV} --app=backend-donations --file=./backend-donations/mysql/init/dump.sql
# Dump database for GIFTS backend.
echo "Dumping Gifts database..."
platform db:dump -y --project=$PROJECT_ID --environment=${PSH_ENV} --app=backend-gifts --file=./backend-gifts/mysql/init/dump.sql
# Loop over the containers and rebuild them.
for CONTAINER in "${DB_CONTAINERS[@]}"
do
# Kill container if it's already running.
if docker-compose ps ${CONTAINER} | grep -q Up; then
docker-compose kill ${CONTAINER}
fi
# If the container is dead then remove it.
if docker-compose ps ${CONTAINER} | grep -q Exit; then
docker-compose rm -f ${CONTAINER}
fi
# When starting it will use the new DB dump.
docker-compose up -d ${CONTAINER}
done