From GridFS to FileS ystem - mongodb

I have some files in Mongo GridFS (inserted with utilities offered by the Meteor cfs:gridfs package)and I want to copy them to the filesystem in order to be compliant to an internal company backup procedure.
Can someone point me in the right direction on how to do this ? Thanks.

You can use mongofiles with gridfs in meteor.
Mongodb provides extensive features with mongofiles. Refer to official manual.

Related

Where can I find MongoDB documents created inside Meteor?

New to Meteor and MongoDB here. I have mongoDB running as a service in my server, and from what I understand, Meteor installs it's own mongoDB in the .meteor directory by default, unless you specify otherwise. I know native MongoDB stores its data in data/db folder, but where are the documents located for MongoDB as part of Meteor?
I have found that the mongoDB binary is found (for me) at
~/.meteor/packages/meteor-tool/.1.0.35.ftql1v++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/mongodb/bin/mongod
But scooping around that area didn't lead me to any documents, nor could I find any mongodb.conf, collection.0, collection.ns files. And there's no directory like .meteor/local/db as some answers suggested.
My question is similar to this one, however, I'm looking for the location on disk of the database documents, rather than the location of the address to access the database.
Question
Where are the documents located for MongoDB as part of Meteor?
They are saved in your project directory at .meteor/local/db.

server side Mongodb GridFS file copying

Per business requirements I need provide possibility to copy content of some file on GridFS. Of course it can be done over domain-specific layer. But in this case I can see some overhead:
take stream from mongo-server
allocate memory on business-layer
read
place back to mongo-server
Obvious solution is write mongo-side JavaScript that will perform copying in bound of single server.
So my questions:
Where is the description of API to manage GridFS on JavaScript?
Is there any issues if my GridFS is sharded?
Is there any issues if my GridFS is replicated?
Thank you in advance
You never need to copy a GridFS file within a single server, because GridFS files are immutable: you can create, read, or delete them, but not modify them. So there's no reason to make a copy.
Copying from one server to another should be done via a driver; there's no built-in support for copying directly from a MongoDB server to another.
The 'normal' js driver does not support GridFS.
You could do it in Node.js. The documentation is here:
http://mongodb.github.com/node-mongodb-native/markdown-docs/gridfs.html
For replica-sets the documentation can be found here for Node.js:
http://mongodb.github.com/node-mongodb-native/markdown-docs/replicaset.html
For simple one-time copying of some files you can use mongofiles on command line (using a temporary file :( ) :
http://www.mongodb.org/display/DOCS/GridFS+Tools
mongofiles --host HOST get currentfilename
mongofiles --host HOST put -l currentfilename newfilename
rm currentfilename
I however don't know how well mongofiles works with sharding and replicas but I would expect it to work.
gridfs_session = gridfs.GridFS(mongo.session)
out_file = gridfs_session.get(file_id)
new_copy = gridfs_session.put(out_file, content_type=out_file.content_type)

Mongo DB REST Option

I know that one of the biggest differences between CouchDB and MongoDB is that Couch uses a REST interface. I've installed Mongo without any other libraries, and the mongod service provides a --rest command-line option.
Does the MongoDB REST interface do the same thing as CouchDB's? If not then what's it for?
MongoDB does not use a REST interface for communications.
You will need to install a specific driver for you language. Just as you would for MySQL or SQL Server or most other databases.
The list of drivers are here.
The --rest option allows for you to run some basic queries and monitoring against the mongod process. It is not a full REST API.
If you're interested in a REST API interface for MongoDB then check out the Sleepy.Mongoose project.
Reason for this is that you started the database without the --rest option. To do this you can start the database from your MongoDB bin directory like "./mongod --rest".

Where does MongoDB store its documents?

I have inserted and fetched data using MongoDB, in PHP. Is there an actual copy of this data in a document somewhere?
By default Mongo stores its data in the directory /data/db.
You can specify a different directory using the --dbpath option.
If you’re running Mongo on Windows then the directory will be C:\data\db, where C is the drive letter of the working directory in which Mongo was started. This is quite confusing, so on Windows I’d recommend that you always specify a data directory using --dbpath.
MongoDB stores it's data in the data directory specified by --dbpath. It uses a database format so it's not actual documents, but there are multiple documents in each file and you cannot easily extract the data from this format yourself.
To read and/or update a document you need to use a MongoDB client, in the same way that you send SQL queries to MySQL through a MySQL client. You probably want to do it programmatically by using one of the client libraries for your programming language, but there is also a command-line client if you need to do manual updates.

can I use MongoDb in server-less mode?

I'm considering using MongoDb for a backing store for a WPF app that I'm building. Mostly just to get some exposure to NoSQL. Ideally I'd like to make a mongodb database, put it in my application's root folder (or ./data) and connect to it with LINQ -- without having mongo.exe running. I did something similar recently with SQLite and found it to be a great change from XML for data storage.
Is this possible with MongoDb? All the samples that I've seen require mongod.exe to be running when you connect to the database. And the data is always stored in c:\data\db.
Answer, yes. Need to use the --dbpath switch and version 1.5.2 (for "upsert").