Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

PostgreSQL Daily Backup Script

In this script is very useful to taking daily PostgreSQL Backup 

#!/bin/bash
# PostgreSQL Daily Base-Backup

FILES_PATH="/db_data/backup/"
dda=`date +%Y%m%d`
FILE_FORMAT="testing_"
EXTENSION_FORMAT=".tar.gz"
DATE=$(date +%G%m%d)
DATE2=$(date)
WALARCH="/db_data/backup/"
WALLOG="/db_data/backup/Daily_$DATE.log"
touch $WALLOG
echo -e "::::::::::::::: $DATE testing DB Backup :::::::::::::::"
>> $WALLOG
echo $DATE2 >> $WALLOG
cd /db_data/backup/
find /db_data/backup/pgbackup*.tar.gz -mtime +2 -exec rm {} \;
psql -U postgres -c "select pg_start_backup ('$DATE');"
cd  /db_data/backup/
tar -cvpzf "testingI_$DATE.tar.gz" /db_index/ >> $WALLOG 2>&1 &
tar -cvpzf "testingD_$DATE.tar.gz" /db_data/ >> $WALLOG 2>&1 &
tar -cvpzf "testingT_$DATE.tar.gz" /db_backup/temp_tablespace/ >> $WALLOG 2>&1 &
wait
echo "TAR completed" >> $WALLOG
psql -U postgres -c "select pg_stop_backup ();"
if [ $? -ne 0 ]
  then
  echo "PSQL pg_stop_backup failed"
  exit 1;
fi
echo "pg_stop_backup done successfully" >> $WALLOG
ls -la $WALARCH/ >> $WALLOG
echo $DATE2 >> $WALLOG
if [ $? -ne 0 ]
  then
  echo "Failed..." >> $WALLOG
  exit 1;
fi

Comments

Popular posts from this blog

VMWARE WORKSTATION 3,4,5,6,7,8,9,10,11,12,14,15...etc LICENSE KEYS COLLECTION

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

Oracle to Postgresql migration

PostgreSQL Enterprise Manager - PEM Monitoring Tools

7 Steps to configure BDR replication in postgresql