milis/talimatname/genel/p/postgresql/postgresql_db_yukselt

45 lines
839 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
PGDATA="$1"
PGBACKUP="$2"
if [ -z "$PGDATA" ]
then
echo "Usage: $0 database-path backup-sql"
exit 1
fi
if [ -z "$PGBACKUP" ]
then
echo "Usage: $0 database-path backup-sql"
echo "Usage example:$0 /srv/pgsql/data /srv/pgsql/yedek/yedek-9.6.3"
exit 1
fi
if [ ! -f "$PGBACKUP" ]
then
echo "$PGBACKUP not found"
echo "Usage example:$0 /srv/pgsql/data /srv/pgsql/yedek/yedek-9.6.3"
exit 1
fi
# servis durdurulur.
servis postgresql stop
# eski yedeğe alınır.
_ustdizin=$(dirname $PGDATA)
mv ${_ustdizin}/data ${_ustdizin}/eskidata
# yeni dizin ve izinleri atanır.
mkdir ${_ustdizin}/data
chown postgres:postgres ${_ustdizin}/data
# yeni vt oluşturulur.
su - postgres -c '/usr/bin/initdb -E UTF8 -D /srv/pgsql/data'
servis postgresql start
sleep 3
su - postgres -c "psql -f $PGBACKUP"