in

infostreams / db, Hacker News

infostreams / db, Hacker News


                    

        

With DB you can very easily save, restore, and archive snapshots of your database from the command line. It Supports connecting to different database servers (for example a local development server and a staging or production server) and allows you to load a database dump from one environment into another environment.

(****************************************
snapshot before running migrations“hashf4f0c1d3fac  (c) ************************************************************************************************************************************************************************** (a) ********************************************************************************************************************************** (cdaa5d) ************************************************************************************************************************************************ (dcd4b) ****************************************************************************************************************************************** (c6e) ******************************************************************************************************************************** (ccb) **********************************************************************************************************************
This will save a copy of your database to the repository.

By default, this repository lives in the dbfolder in your project root. In this repository are gzipped database dumps. Whether or not you want to commit the contents of that folder to git

or another VCS is up to you. If you do, make sure to exclude your database credentials by adding something like .db / * / config / credentials.cnf

(untested!) to your

. gitignore (************************************.

Imagine the following scenario: After creating the local snapshot, you run a database migration. However, the migration breaks your database and deletes some stuff that you didn't want to delete. Usually, if you run a migration, there is also a way to undo that migration - but alas, that won't return your deleted data. No problem. To restore your database to the state it was in before you started the migration, simply run:

[new collation] $ db load localhost f4f0c1d3fac (c) *************************************************************************************************************************************************************************************** (a) ********************************************************************************************************************** (cdaa5d) ********************************************************************************************************************************************** (dcd4b) ***************************************************************************************************************************************** (c6e) ********************************************************************************************************************************** (ccb) ************************************************************************************************************************* ********************************

This will load the snapshot you made before you ran the migration. It's like the migration never happened.

There are many other things (db) can do, for example pulling down a database from the staging environment to your localhost:

[new collation] $ db save staging

Snapshot intended for development* hash******************************************************************************************************************************* (b) *********************************************************************************************************************************** (c) ************************************************************************************************************************************************ (eb) ******************************************************************************************************************************************** (d5b) ************************************************************************************************************************************************************************ (e) ***************************************************************************************************************************************** (f) ********************************************************************************************************************** (f2bfca) ************************************************************************************************************************************************************************** (b5b) **************************************************************************************************************************************** (e) ********************************************************************************************************************  $ db load localhost  (b) *********************************************************************************************************************************** (c) ************************************************************************************************************************************************ (eb) ********************************************************************************************************************************************* (d5b) **************************************************************************************************************************************************************** (e) *************************************************************************************************************************************** (f) ************************************************************************************************************************** (f2bfca) **************************************************************************************************************************************************************************** (b5b) ****************************************************************************************************************************** e 79214713088
Here you first make a snapshot of the database on the (staging) ************************************** server, which you then load into your (localhost) database. This works most reliably if your staging and your development server are on the same database version.
See the full list of available commandsget a complete overview of
db
's capabilities.******************************** [new collation] ************************ [serveralias|all] ****************************** Installation
For now, you can only install (db) by cloning this repository:
[new collation] $ git clone https://www.github.com/infostreams/db (********************************
and then creating a symlink to the main (db) script from a directory that is in your path, eg:
[new collation] $cd (db /) #change to the directory you cloned the github repository in
$ ln -s db / usr / local / bin / (#)  create the symlink*******************************
You can see if it works by running

If all is well you should see the following friendly error message:

[new collation] fatal: Not a db repository (or any of the parent directories). Please run'db init' (********************

db nuke

), or to show the table structure of a particular dump (

Full list

The full list of available commands is as follows