Skip to content

Commit

Permalink
Refactored how local db is started, now uses the db files on s3 so lo…
Browse files Browse the repository at this point in the history
…cal DB is the same as what we're restoring to environments. Uses AWS s3 sync command to download the files so if they're there already it's quicker.
  • Loading branch information
Peter Nemere committed Oct 28, 2024
1 parent eb159aa commit 41db8fd
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ auth0dummy-LOCAL-ONLY.go-
/local-mongo/dbseed/json/
/local-mongo/3repl/

db-restore/

local-api-config.json
local-api-config-unittest.json

Expand Down
1 change: 1 addition & 0 deletions internal/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func initServices(cfg config.APIConfig, apiInstanceId string) *services.APIServi

// Get handle to the DB
dbName := mongoDBConnection.GetDatabaseName("pixlise", cfg.EnvironmentName)
iLog.Infof("DB name: %v", dbName)

db := mongoClient.Database(dbName)
/*
Expand Down
6 changes: 0 additions & 6 deletions local-mongo/dbseed/Making a DB seed.txt

This file was deleted.

4 changes: 0 additions & 4 deletions local-mongo/dbseed/import.sh

This file was deleted.

28 changes: 0 additions & 28 deletions local-mongo/export-prod-migrated.sh

This file was deleted.

6 changes: 0 additions & 6 deletions local-mongo/startdb.sh

This file was deleted.

8 changes: 8 additions & 0 deletions startdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

aws s3 sync s3://pixlise-backup/DB/pixlise-prodv4/ ./db-restore/

# Start Mongo
# Initiate a replica set (rs.initiate())
# Call import.sh to reload last saved mongo dump
docker run --rm -d -v /$PWD/db-restore:/db-restore -p 27017:27017 -h $(hostname) --name mongo-test mongo:4.0.28 --replSet=test && sleep 4 && docker exec mongo-test mongo --eval "rs.initiate();" && sleep 2 && docker exec mongo-test mongorestore --gzip --db "pixlise-localdev" db-restore/

0 comments on commit 41db8fd

Please sign in to comment.