Skip to content

Instantly share code, notes, and snippets.

@gravcat
Last active February 21, 2018 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravcat/86cbe33ffc1a22d7ea55f732ef807f84 to your computer and use it in GitHub Desktop.
Save gravcat/86cbe33ffc1a22d7ea55f732ef807f84 to your computer and use it in GitHub Desktop.
#!/bin/bash
# export deployment info from mcp
timestamp=$(date +"%Y%m%d-%H%M")
# create directory in home based on timestamp like 20180221-1058, cd into
mkdir ~/$timestamp
cd ~/$timestamp
# export data from mongo
mongoexport --db=mcp --collection=DeploymentHistory --out DeploymentHistory.json
mongoexport --db=mcp --collection=Deployments --out Deployments.json
# hop back out and archive
cd ~
tar cvzf ~/$timestamp.tgz ~/$timestamp/
rm -rf ~/$timestamp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment