Tue Jun 9 14:38:29 PDT 2009
- Previous message: [Slony1-commit] slony1-engine/tests/testseqnames README generate_dml.sh init_add_tables.ik init_schema.sql
- Next message: [Slony1-commit] slony1-engine/doc/adminguide adminscripts.sgml
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /home/cvsd/slony1/slony1-engine/tools In directory main.slony.info:/tmp/cvs-serv4394/tools Added Files: Tag: REL_2_0_STABLE slonikconfdump.sh Log Message: Add in a slonik configuration dump tool, that will be helpful when doing upgrades from 1.2 to 2.0, along with documentation. --- NEW FILE: slonikconfdump.sh --- #!/bin/bash # $Id: slonikconfdump.sh,v 1.1.2.1 2009-06-09 21:38:27 cbbrowne Exp $ # This tool rummages through a Slony-I cluster, generating a slonik script # suitable to recreate the cluster # Start with: # SLONYCLUSTER indicating the cluster name echo "# building slonik config files for cluster ${SLONYCLUSTER}" echo "# generated by: slonikconfdump.sh" echo "# Generated on: " `date` SS="\"_${SLONYCLUSTER}\"" echo "cluster name=${SLONYCLUSTER};" echo "include <admin-conninfos.slonik>; # Draw in ADMIN CONNINFO lines" Q="select distinct pa_server from ${SS}.sl_path order by pa_server;" PATHS=`psql -qtA -F ":" -c "${Q}"` for svr in `echo ${PATHS}`; do SQ="select pa_conninfo from ${SS}.sl_path where pa_server=${svr} order by pa_client asc limit 1;" conninfo=`psql -qtA -F ":" -c "${SQ}"` echo "node ${svr} admin conninfo='${conninfo}';" done Q="select no_id, no_comment from ${SS}.sl_node order by no_id limit 1;" NODE1=`psql -qtA -F ":" -c "${Q}"` nn=`echo ${NODE1} | cut -d : -f 1` comment=`echo ${NODE1} | cut -d : -f 2-` echo "init cluster (id=${nn}, comment='${comment}');" Q="select no_id from ${SS}.sl_node order by no_id offset 1;" NODES=`psql -qtA -F ":" -c "${Q}"` for node in `echo ${NODES}`; do CQ="select no_comment from ${SS}.sl_node where no_id = ${node};" comment=`psql -qtA -c "${CQ}"` echo "store node (id=${node}, comment='${comment}');" done #slonyregress1=# select * from sl_path; # pa_server | pa_client | pa_conninfo | pa_connretry #-----------+-----------+----------------------------------------------------------+-------------- # 2 | 1 | dbname=slonyregress2 host=localhost user=chris port=7083 | 10 # 1 | 2 | dbname=slonyregress1 host=localhost user=chris port=7083 | 10 #(2 rows) Q="select pa_server, pa_client, pa_connretry from ${SS}.sl_path order by pa_server, pa_client;" PATHS=`psql -qtA -F ":" -R " " -c "${Q}"` for sc in `echo $PATHS`; do server=`echo $sc | cut -d : -f 1` client=`echo $sc | cut -d : -f 2` retry=`echo $sc | cut -d : -f 3` Q2="select pa_conninfo from ${SS}.sl_path where pa_server=${server} and pa_client=${client};" conninfo=`psql -qtA -c "${Q2}"` echo "store path (server=${server}, client=${client}, conninfo='${conninfo}', connretry=${retry});" done Q="select set_id, set_origin from ${SS}.sl_set order by set_id;" SETS=`psql -qtA -F ":" -R " " -c "${Q}"` for sc in `echo ${SETS}`; do set=`echo ${sc} | cut -d : -f 1` origin=`echo ${sc} | cut -d : -f 2` Q2="select set_comment from ${SS}.sl_set where set_id=${set};" comment=`psql -qtA -c "${Q2}"` echo "create set (id=${set}, origin=${origin}, comment='${comment}');" done Q="select tab_id,tab_set, set_origin from ${SS}.sl_table, ${SS}.sl_set where tab_set = set_id order by tab_id;" TABS=`psql -qtA -F ":" -R " " -c "${Q}"` for tb in `echo ${TABS}`; do tab=`echo ${tb} | cut -d : -f 1` set=`echo ${tb} | cut -d : -f 2` origin=`echo ${tb} | cut -d : -f 3` RQ="select tab_relname from ${SS}.sl_table where tab_id = ${tab};" relname=`psql -qtA -c "${RQ}"` NSQ="select tab_nspname from ${SS}.sl_table where tab_id = ${tab};" nsp=`psql -qtA -c "${NSQ}"` IDX="select tab_idxname from ${SS}.sl_table where tab_id = ${tab};" idx=`psql -qtA -c "${IDX}"` COM="select tab_comment from ${SS}.sl_table where tab_id = ${tab};" comment=`psql -qtA -c "${COM}"` echo "set add table (id=${tab}, set id=${set}, origin=${origin}, fully qualified name='\"${nsp}\".\"${relname}\"', comment='${comment}, key='${idx}');" done Q="select seq_id,seq_set,set_origin from ${SS}.sl_sequence, ${SS}.sl_set where seq_set = set_id order by seq_id;" SEQS=`psql -qtA -F ":" -R " " -c "${Q}"` for sq in `echo ${SEQS}`; do seq=`echo ${sq} | cut -d : -f 1` set=`echo ${sq} | cut -d : -f 2` origin=`echo ${sq} | cut -d : -f 3` RQ="select seq_relname from ${SS}.sl_sequence where seq_id = ${seq};" relname=`psql -qtA -c "${RQ}"` NSQ="select seq_nspname from ${SS}.sl_sequence where seq_id = ${seq};" nsp=`psql -qtA -c "${NSQ}"` COM="select seq_comment from ${SS}.sl_sequence where seq_id = ${seq};" comment=`psql -qtA -c "${COM}"` echo "set add sequence(id=${seq}, set id=${set}, origin=${origin}, fully qualified name='\"${nsp}\".\"${relname}\"', comment='${comment}');" done Q="select sub_set,sub_provider,sub_receiver,case when sub_forward then 'YES' else 'NO' end from ${SS}.sl_subscribe;" SUBS=`psql -qtA -F ":" -R " " -c "${Q}"` for sb in `echo ${SUBS}`; do set=`echo ${sb} | cut -d : -f 1` prov=`echo ${sb} | cut -d : -f 2` recv=`echo ${sb} | cut -d : -f 3` forw=`echo ${sb} | cut -d : -f 4` echo "subscribe set (id=${set}, provider=${prov}, receiver=${recv}, forward=${forw});" done
- Previous message: [Slony1-commit] slony1-engine/tests/testseqnames README generate_dml.sh init_add_tables.ik init_schema.sql
- Next message: [Slony1-commit] slony1-engine/doc/adminguide adminscripts.sgml
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list