Forum OpenACS Q&A: Re: shut down postgreSQL server remotely

Collapse
Posted by Steve Manning on
Syed

This is the script which I use to do the same thing but with  the aolserver under the control of daemontools and the two systems synced using rsync.

I also dump the database schema and data separately as I find I can restore without errors by splitting them.

===================

#!/bin/sh
#
# OpenACS Daemontools Shutdown Script
#
#

{

echo -n "===== Started "
date

# Kill the current nsd
/usr/local/bin/svc -d /service/foobar

# RSync the systems
su -c '/usr/bin/rsync --recursive --links --perms --times --checksum --compress --verbose --delete \
    -e ssh "mailto:auser@www.foobar.com:/var/lib/aolserver/foobar" \
    --exclude="foobar/etc/*" /var/lib/aolserver ' nsadmin

echo -n "===== Restore DB "
date

# Update the database
su -c '/usr/bin/dropdb foobar' nsadmin
su -c '/usr/bin/createdb --template=template0 --encoding=UNICODE foobar' nsadmin
su -c '/usr/bin/psql foobar < /var/lib/aolserver/foobar/database-backup/foobar_schema.dmp' nsadmin
su -c '/usr/bin/psql foobar < /var/lib/aolserver/foobar/database-backup/foobar_data.dmp' nsadmin

# Restart NSD
/usr/local/bin/svc -u /service/foobar

echo -n "===== Completed "
date

} > /var/lib/aolserver/foobar/etc/sync_live.log 2>&1

=======================

  - Steve