Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write a script to create a full local copy of production database on dev #246

Open
jluebeck opened this issue Mar 7, 2024 · 5 comments
Open
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@jluebeck
Copy link
Member

jluebeck commented Mar 7, 2024

Allows better testing of weirdness that can happen in production environment.

@jluebeck jluebeck added the enhancement New feature or request label Mar 7, 2024
@jluebeck jluebeck changed the title Write a script to create a full local copy of production database on dev or local Write a script to create a full local copy of production database on dev Mar 7, 2024
@liefeld
Copy link
Collaborator

liefeld commented Apr 11, 2024

Made a first pass at this this morning with limited results that I am recording here. This should be doable using the mongoexport/mongoimport commands but I cannot seem to get a connection to the db from the amplicon-dev ubuntu node ( error connecting to db server: no reachable servers). Not sure if this is a mongo/documentdb version incompatibility. From within the container I can connect using pymongo from within the container. Export script is

from bson.json_util import dumps
from pymongo import MongoClient

mstr = "DB_URI_SECRET from config file"
client = MongoClient(mstr)

collections = database.collection_names()
for i, collection_name in enumerate(collections):
col = getattr(db,collections[i])
print(f”saving {collection_name}”)
collection = col.find()
jsonpath = collection_name + ".json"
with open(jsonpath, 'wb') as jsonfile:
jsonfile.write(dumps(collection))

@liefeld
Copy link
Collaborator

liefeld commented Apr 11, 2024

The DBs are too big to export on dev or prod nodes (prod is 145GB, disk is 80GB so it won't fit). In the meantime I added a file /home/ubuntu/AmpliconRepository-dev/mongo_shell.sh that is setup so that you can use a docker container of appropriate version to get a mongo shell into the DocumentDB database. It should be easily modifiable to use mongodump and mongorestore to make a new copy

https://www.mongodb.com/docs/manual/release-notes/4.2-compatibility/#remove-support-for-the-copydb-and-clone-commands

@jluebeck
Copy link
Member Author

@liefeld - I'm not sure it needs to be the entire DB that we clone for testing purposes. How about something like all public non-deleted projects? Or all non-deleted projects for a specific user. Thoughts?

@liefeld
Copy link
Collaborator

liefeld commented Apr 11, 2024

use caper
db.projects.find({'private': false, 'delete': false}).forEach(function(x){
db.getSiblingDB('caper-dev')['projects'].insert(x);
});

@jluebeck
Copy link
Member Author

Shelving this issue for the moment because there are no issues currently where we need to have a copy of the production database. Copy is also very large (80gb?).

@jluebeck jluebeck added the wontfix This will not be worked on label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants