Asheboy / mongo-wrangler

Two developers one dump πŸ’©

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mongo Wrangler

Lightweight copies of databases with personal data obfuscated.

Two developers one dump πŸ’©

To keep customer data safe and reduce the liability on developers, live database access is only granted to people who really need it for operational support. You really don't want to be in that group, you'll get called at all hours and be asked to help solve horrible problems for angry customers and bosses.

How does this work?

Developer: πŸ€” I need a copy of the production database to do my work

Developer: πŸ’¬ Hey privileged user can I have a copy of acme-cms-production database?

Privileged user: πŸ’¬ Sure, I'll send you a link.

Privileged user: πŸ™‚ 1. ssh to database server. 2. Run a oneliner. 3. Copy and paste oneliner for Developer to run.

Privileged user: πŸ’¬ Here you go! {ONELINER GOES HERE}

Developer: πŸ’¬ Thanks.

Developer: {ONELINER GOES HERE} Running... πŸ˜—πŸŽΆ

Developer: πŸ’¬ Got it thanks! πŸ˜„

Privileged user: πŸ’¬ You are most welcome. πŸ˜„ Have a great day! 🎈

Note: This is a clock.co.uk specific workflow!

Dumping πŸ’©

NB: With this tool it is possible to exhaust available disk space on the MongoDB server. For now, it is essential to manually check the size of the database you are going to dump, and the available disk space. Furthermore, if possible avoid running the tool close to the beginning of a new hour; Clock's servers are snapshotted every hour on the hour, and it is best to avoid storing the temporary dump files in those backups.

  1. First ssh into database server

  2. If this is your first dump πŸ’©

    git clone https://github.com/clocklimited/mongo-wrangler.git

  3. cd mongo-wrangler

  4. ./dump.js {database name}

4.1 If you want to exclude additional collections use -e ./dump.js -e member,subscriber,duck,log {database name}

  1. Check the output for instructions and copy and paste the onliner

  2. Send to the requester

Request / Restorer

  1. Paste oneliner sent to you.

  2. πŸŽ‰

Excluded Collections

These collections are excluded by default. If you need them please ask the privileged user to include them by editing the dump script.

If you find other big collections that are slowing up your dumps or taking a lot of space please send a PR or edit dump.js on a per project bases.

Obfuscation

Properties containing these properties are obfuscated by default. This can cause some data you don't want getting obfuscated. You'll have to ask the privileged to do a customer dump or submit a PR if this causes a problem.

Troubleshooting

You need to be on node 0.11+

You should be able to do to get a newer runtime:

nave use stable

No node no nave

wget http://github.com/isaacs/nave/raw/master/nave.sh
bash ./nave.sh use stable

Verbose Mode

Add -v on either command to see the commands run and get verbose output

Mongo 2 Failing because of invalid indexes

Use -n to ignore indexes on restore

./restore.js -n {DB} {URL}

Xfer

This solution relies on xfer.clock.co.uk

About

Two developers one dump πŸ’©


Languages

Language:JavaScript 100.0%