Creating Ledgersmb Database Live & Test Environments

Written by James McDonald

December 17, 2009

Warning: This setup can be dangerous if you forget which environment you are in you can cause damage to your LIVE environment.

Login to postgres as a superuser and use \l to list your databases

[email protected]:~$ psql -U ledgersmb -h localhost
Password for user ledgersmb: 
Welcome to psql 8.3.8, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

ledgersmb=> \l
            List of databases
       Name       |   Owner   | Encoding 
 jmits-5zero-live | ledgersmb | UTF8
 ledgersmb        | ledgersmb | UTF8
 postgres         | postgres  | UTF8
 template0        | postgres  | UTF8
 template1        | postgres  | UTF8
(5 rows)

Identify your ledgersmb database. Mine is jmits-5zero-live

backup your live DB using pg_dump

[email protected]:~$ pg_dump -U ledgersmb -h localhost jmits-5zero-live  > jmits-5zero-live.sql

Create a new test database

createdb -T ledgersmb jmits-5zero-test

Restore you live backup into the test db

psql -U ledgersmb -h localhost jmits-5zero-test < jmits-5zero-live.sql 

Goto the ledgersmb admin page and login

Configure your user account to use the test db

Always check your environment when logging in to LedgerSMB and clicking the Version Link in the left hand side to display your DB environment:


Submit a Comment

Your email address will not be published.

You May Also Like…


Zebra Printer Language The above website has a page where you can enter ZPL and it...

PHP Iterators

Just came across a Youtube talk "Iterators in PHP" by Jake Smith published in 2014 that steps through the many...

PHP array_map Multiple Arrays

array_map can take multiple arrays. I like how it starts mapping through them starting at the first element of each...