-
-
Save eduardodeoh/164a38b73bc495a0c159 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/bin/sh # ## This is called to back up the WAL files to the slave. ## This is on top of replication and is used as another ## method to secure data successfully transferring from one ## database server to another. ARCHIVE_DIR_ON_SLAVE="/var/lib/postgresql/walfiles" LOG=1 LOG_FILE="/tmp/postgres_wal_archiving.log" log() { echo "`date --rfc-3339=ns` $1" >> "$LOG_FILE"; } log_error() { echo "`date --rfc-3339=ns` $1" >> "$LOG_FILE"; exit 1; } wal_path="$1" wal_file="$2" backup_server="db02" if [ $LOG -eq 1 ] then log "Transfering file to backup server, filename: $wal_file" fi rsync "$wal_path" "$backup_server:$ARCHIVE_DIR_ON_SLAVE" if [ $LOG -eq 1 ] then if [ "$?" -eq 0 ]; then log "Transfer to slave server completed" else log_error "Sending $wal_file failed." fi fi