voxel51 / fiftyone

Refine high-quality datasets and visual AI models
https://fiftyone.ai
Apache License 2.0
8.89k stars 564 forks source link

[Q] How to Backup Database? #1272

Closed tszumowski closed 1 year ago

tszumowski commented 3 years ago

Question

I understand I can export a dataset to JSON form using the fiftyone datasets export command. However, what if I would like a full backup of the database? Is there a way to do that?

brimoor commented 3 years ago

Hi @tszumowski 👋

There aren't currently any builtin command/methods for DB backups, but you can easily do it yourself by interacting directly with MongoDB.

FiftyOne installs include a MongoDB install, and you can run the following command to locate its mongod executable and the DB directory:

import fiftyone.core.service as fos

service = fos.DatabaseService()
print(service.command)

Here's the output on my setup:

['/Users/Brian/dev/env/fifty3/lib/python3.6/site-packages/fiftyone/db/bin/mongod',
'--dbpath',
'/Users/Brian/.fiftyone/var/lib/mongo',
'--logpath',
'/Users/Brian/.fiftyone/var/lib/mongo/log/mongo.log',
'--port',
'0',
'--nounixsocket']

I know you asked explicitly about full database backups, but I'll also mention that using dataset.clone() is a convenient way to create a temporary, independent copy of a dataset in cases where you want to test something before performing it on the source dataset.

twmht commented 1 year ago

@brimoor

Can i migrate mongodb to a remote server? or it's okay to just backup the whole files under /Users/Brian/.fiftyone/var/lib/mongo?

swheaton commented 1 year ago

you would use a tool like mongodump and not just grab the files directly. closing