[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make copy of database - and change the background colour


Just thought I'd post up in case it is useful to others.  This script will make a copy of the live database (fpl2) to the copy (fpl2copy) and then changes the background colour to make it easier to distinguish.


echo `date`
echo "Copying fpl2 to fpl2copy..."

# Make safety copy.
pg_dump --clean -h localhost -U phppgadmin fpl2 > /var/backups/fpl2_to_copy.pgd

# Simplest way is to drop the copy database and then recreate from the original.
psql -c "DROP DATABASE fpl2copy;" -U phppgadmin -h localhost template1
psql -c "CREATE DATABASE fpl2copy WITH TEMPLATE fpl2 OWNER lsadmin" -U phppgadmin -h localhost template1
psql -h localhost -U phppgadmin -c "UPDATE user_preference SET stylesheet = 'ledgersmb-yellow.css';"  fpl2copy

echo `date`
echo "Finished."

This needs the phppgadmin user to be able to login - maybe by setting the .pgpass file.  The PG user account I use for setup.pl etc and to own all the LS databases is lsadmin.


Kevin Bailey