Инструменты пользователя

Инструменты сайта


prog:arch-all-bases-pg
pgarch.sh
#!/bin/sh
 
#
# Author: Alexey Leonchik <aleonchik@gmail.com>, 2008
#                         <alexleon.narod.ru>
# Special for Artel Co. LTD <www.artelcompany.ru>
#
# Make DB archive from Postgres
#
 
# To do...
# Send archive to admin DB EMail
 
#
# su pgsql -c 'initdb -D /usr/local/var/pgsql/db/ --locale=ru_RU.CP1251'
# For view all locale on server type locale -a
#
# pg_dump -U pgsql -b db_name | gzip -c - > db_name.sql.gz
# gunzip -c db_name.sql.gz | psql -U pgsql db_name
#
# pg_dump -U pgsql -b -Fc db_name > db_name.dump
# pg_restore -U pgsql -d db_name -Fc db_name.dump
#
 
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH
 
DB='accounts artel budget client kis revise client_td china crm crmax advert crmax2 crmax2_trade'
PG_USER=pgsql
ARCH_COUNT=7
ROOT_DIR=/usr/home/alexey/pgarch
 
# to work dir
cd $ROOT_DIR
 
# if not exists dir - create it
for i in $DB ; do
    if [ ! -d $i ] ; then
	mkdir $i >/dev/null 2>&1
    fi
done
 
for i in $DB ; do
    Counter=`expr $ARCH_COUNT - 1`
    while [ $Counter -gt 0 ] ; do
	k=`expr $Counter - 1`
	mv -f ${i}/${i}_${k}.dump ${i}/${i}_${Counter}.dump >/dev/null 2>&1
	mv -f ${i}/${i}_${k}.sql.gz ${i}/${i}_${Counter}.sql.gz >/dev/null 2>&1
	Counter=`expr $Counter - 1`
    done
    pg_dump -U ${PG_USER} -b ${i} | gzip -c - > ${i}/${i}_0.sql.gz
    pg_dump -U ${PG_USER} -b -Fc ${i} > ${i}/${i}_0.dump
done
prog/arch-all-bases-pg.txt · Последние изменения: Sun, 18 Mar 2012 20:28 (внешнее изменение)