Last active
May 26, 2022 14:16
-
-
Save cdukebwell/6511c19385bd0bf045f0f5276d1f2f5b to your computer and use it in GitHub Desktop.
Simple mongo dump/restore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
lookbackDate=`date -d "6 hours ago" +"%Y-%m-%dT%H:%M:%S%z"` | |
echo $lookbackDate | |
while IFS= read -r c | |
do | |
echo "Queuing...${c}" | |
mongodump \ | |
--config=/home/ubuntu/aws-prod-cs \ | |
--username=root \ | |
-d fhir_prod \ | |
-c $c \ | |
--gzip --archive \ | |
| mongorestore \ | |
--config=/home/ubuntu/atlas-prod-cs \ | |
--username=pa-prod-service \ | |
--stopOnError \ | |
--numInsertionWorkersPerCollection=10 \ | |
--nsFrom="fhir_prod.*" \ | |
--nsTo="fhir.*" \ | |
-- | |
--gzip --archive > "/tmp/mongosync-prod-${lookbackdate}.log" | |
done < "/home/ubuntu/collections.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment