Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
4 total  XML / RSS feed 

Postgresql dump SS archive script

Dump, bzip, and upload a postgres database to strongspace. Via Ubernostrum


FILENAME=b_list-`/usr/xpg4/bin/date +%Y%m%d`.sql.bz2
cd /home/myuser/dumps
/opt/local/bin/pg_dump -U db_username db_name | /usr/bin/bzip2 > $FILENAME
/usr/bin/scp $FILENAME me@strongspace:/my/backup/dir/

Install RdbiPgSQL package for R on OS X

Connecting R to Postgres on OS X is a little bit of a hassle given where OS X looks for the libraries to link to.

Assuming you've installed Postgres via MacPorts, add shell variables for your Postgres lib and include directories to ~/.profile

export PG_LIB_DIR=/opt/local/lib/postgresql82
export PG_INCLUDE_DIR=/opt/local/include/postgresql82

Add a link from the OS X SDK directory to /opt

$ sudo ln -s /opt/ /Developer/SDKs/MacOSX10.4u.sdk/opt

Then install RdbiPgSQL as you would normally.

If the install fails because R isn't picking up the PG_LIB_DIR, _INCLUDE_DIR variables, keep a lookout for the lines in the install error output that look like

The downloaded packages are in

In Terminal, change to this directory, replacing the 'RtmpTakYpZ' string with whatever directory the error output gives. Then run the R install command on the package file:

$ cd /tmp/RtmpTakYpZ/downloaded_packages
$ sudo R CMD INSTALL RdbiPgSQL_1.10.0.tar.gz 

load/unload postgres (via ports) launch deamon

Enable or disable the automatic launch of the postgresql server installed via macports. Starts or stops the daemon and modifies the launchd manifest.

launchctl load -w /opt/local/etc/LaunchDaemons/org.darwinports.postgresql81-server/org.darwinports.postgresql81-server.plist

launchctl unload -w /opt/local/etc/LaunchDaemons/org.darwinports.postgresql81-server/org.darwinports.postgresql81-server.plist

start postgres

Postgres was installed through darwinports, so

/opt/local/lib/postgresql81/bin/pg_ctl -D /opt/local/var/db/postgresql81/defaultdb/ start
« Newer Snippets
Older Snippets »
4 total  XML / RSS feed