Script for postgres archive move – If Data is full
In this script will be helpful to move & compress your archive files to some other partition , it will be used at the time of bulk restore and data partition full or archive partition full. it is one of the maintenance activity in postgres as well
cat /script/archive_move_bkp.sh #!/bin/bash ##### Script is to take backup of the Archives PGDATA=/data/ PGHOME=/opt/PostgreSQL/9.3/bin HOT=/backup WAL_LOC=/archive/emut_15 LOG=/home/postgres/script_logs PGDATABASE=postgres PGUSER=postgres PGPORT=5432 TODAY=$(date +"%m-%d-%Y-%T") echo "Archive backup Start Time: `date +%d-%m-%y-%T`" >> $LOG/archiveinfo_$TODAY.log /opt/PostgreSQL/9.3/bin/psql -U $PGUSER -d $PGDATABASE -p $PGPORT -c "select pg_switch_xlog();" >> $LOG/archiveinfo_$TODAY.log tar --remove-files -cvzf $HOT/arch18_$TODAY.tar.gz $WAL_LOC/* >> $LOG/archiveinfo_$TODAY.log echo "Archive backup End Time: `date +%d-%m-%y-%T`" >> $LOG/archiveinfo_$TODAY.log exit 0 bash-4.1$