Tag Archives: Database

Los Angeles Headshots by Richard Sumilang Richard Sumilang Los Angeles Headshot Photography

Backing up and Restoring with MongoDB

Dump You can dump the database locally using the following mongodump: mongodump --host DATABASE_HOST --port PORT -d YOUR_DATABASE_NAME -u YOUR_DB_USERNAME -p YOUR_DB_PASSWORD This will create a dump folder containing a subfolder named after your database. The default port for MongoDB is 27017. Import You can import the same dump to a local MongoDB instance using something like the following mongorestore after changing into the dump directory: mongorestore --host DATABASE_HOST --port PORT -d DATABASE_NAME_TO_IMPORT_TO --drop DATABASE_NAME_TO_IMPORT_FROM Note: This will drop the collections in the DATABASE_NAME_TO_IMPORT_TO database before restoring the same collections from your database dump.
Read More
May 30, 2014 1 min read

How to create a MongoDB ObjectID from a timestamp using PHP

This is a useful tidbit of code to have until PHP adds this feature into their MongoDB extension. I stumbled on an example on Stack Overflow illustration showing how to do this and rewrote it in what I think is a slightly more modern way that does the same thing.

Read More
Mar 31, 2014 2 min read