-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload-db.sh
executable file
·27 lines (22 loc) · 968 Bytes
/
load-db.sh
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
#!/bin/bash
set -e
# Load dump.gz database automatically
echo "Starting load container.."
sudo docker-compose -f docker-compose.load.yml up -d
# Wait for it
echo "Waiting container to be responsive"
./wait-for-it.sh --timeout=0 localhost:8069
echo "Waiting another 10 seconds.. just in case"
sleep 10s
# Try to drop database
curl -F name=migrate -F master_pwd=admin http://localhost:8069/web/database/drop
# Upload new database
if [[ -f backups/migrate.dump.gz ]]; then
echo "Loading backup from migrate.dump.gz.."
curl -F backup_file=@backups/migrate.dump.gz -F name=migrate -F master_pwd=admin -F copy=true http://localhost:8069/web/database/restore
elif [[ -f backups/migrate.zip ]]; then
echo "Loading backup from migrate.zip.."
curl -F backup_file=@backups/migrate.zip -F name=migrate -F master_pwd=admin -F copy=true http://localhost:8069/web/database/restore
fi
echo "Shutting down load container.."
sudo docker-compose -f docker-compose.load.yml down