#!/bin/bash make_master_backup() { /opt/omnipitr/bin/omnipitr-backup-master -p 54001 -t /home/depesz/omnipitr/tmp/backup-master/ -D /home/depesz/data-master/ -x /home/depesz/omnipitr/backup-archive/ -dl gzip=/home/depesz/omnipitr/backup/ -f "master-__FILETYPE__.tar__CEXT__" -l /home/depesz/omnipitr/log -v if [[ ! -e /home/depesz/omnipitr/backup/master-data.tar.gz ]] then echo "/home/depesz/omnipitr/backup/master-data.tar.gz does not exist?!" >&2 exit 1 fi if [[ ! -e /home/depesz/omnipitr/backup/master-xlog.tar.gz ]] then echo "/home/depesz/omnipitr/backup/master-xlog.tar.gz does not exist?!" >&2 exit 1 fi data_size="$( du -k /home/depesz/omnipitr/backup/master-data.tar.gz | awk '{print $1}')" xlog_size="$( du -k /home/depesz/omnipitr/backup/master-xlog.tar.gz | awk '{print $1}')" if (( $data_size < 1024 )) then echo "/home/depesz/omnipitr/backup/master-data.tar.gz exists but looks too small to be sensible!" >&2 exit 1 fi if (( $xlog_size < 8 )) then echo "/home/depesz/omnipitr/backup/master-xlog.tar.gz exists but looks too small to be sensible!" >&2 exit 1 fi # Rotate xlog to make sure there is something in replication archive. echo "create table xxx_tmp as select generate_series(1,10) as i; checkpoint; select pg_switch_xlog(); drop table xxx_tmp; checkpoint; " | psql -p 54001 &> /dev/null }