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

PostgreSQL pgBadger

ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated ORA-01262: Stat failed on a file destination directory Linux-x86_64 Error: 2: No such file or directory

Migrating From Oracle to PostgreSQL using ora2pg open source tools

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

How to configure Replication Manager (repmgr) ?