Backup Postgres SQL format






Check it out from private

git clone https://username@bitbucket.org/onlinesolutionsgroup/backup_admin_scripts.git


Mkdir /backup/database/


Update script BACKUP_DIR pg_backup.config


Set password


su - postgres

psql

\password



root@vindazo /mnt/extradrive/backup/scripts # cp pgpass.conf ~/.pgpass

root@vindazo /mnt/extradrive/backup/scripts # chmod 0600 ~/.pgpass


It should automatically start backup from script


If you using Citus you have to edit script for vim pg_backup_rotated.sh and add -p 9700 configuration

./pg_backup_rotated.sh



Create crontab for daily backup


0 0 * * * /mnt/extradrive/backup/scripts/pg_backup_rotated.sh


Check werking over 2 days.. And best monthly control all backups and create one copy for backup copy.



Backup install old fashion


vim pg_backup.config

BACKUP_DIR=/home/backup/database/


./pg_backup_rotated.sh



vim /etc/environment

PGPASSFILE="/home/backup/scripts/pgpass.conf"



Install Tartarus


http://wiki.hetzner.de/index.php/Tartarus_Backup-Konfiguration


wget http://wertarbyte.de/apt/tartarus/tartarus_0.9.8-1_all.deb

sudo dpkg -i tartarus_0.9.8-1_all.deb



- Tartarus configuration filesbackup.bash

-----------------------------------------------

Each file for all directories example



vim /etc/tartarus/generic.inc


vim /home/backup/tartarus/database.conf


# /etc/tartarus/root.conf

#

# Read main config

source /etc/tartarus/generic.inc

# Profile name

# !!!!! CHANGE NAME !!!!

NAME="database-carzando-propenda"

# Directory / Backup

DIRECTORY="/media/sdc/backups/database"

#Backup no temporary files

# separate several folders with a space

EXCLUDE="/tmp/"

# No LVM snapshot

CREATE_LVM_SNAPSHOT="no"

# incremental backup

# !!!! CREATE PATH HERE !!!!

INCREMENTAL_TIMESTAMP_FILE="/var/spool/tartarus/timestamps/database"



Backup config files /etc/ /var/ crontab and list of packeges en python lib..

Automation and upload





Crontab

-----------------------------


0 0 * * * /etc/cron.daily/logrotate

0 0 * * * /home/backup/scripts/pg_backup_rotated.sh

0 4 * * mon-sat /home/backup/scripts/filesbackup.bash -i

0 4 * * sun /home/backup/scripts/filesbackup.bash

#0 12 * * * /media/sdc/backups/scripts/checkbackup.bash




Comments