1. basic

http://www.sqlines.com/postgresql/how-to/pg_dump_database_file

2. script

https://m.blog.naver.com/PostView.nhn?blogId=dimigozzang&logNo=220629436373&proxyReferer=https%3A%2F%2Fwww.google.com%2F


script 폴더 보완 및 9.6으로 수정


#!/bin/bash

#I need user and password

export PGUSER=user

export PGPASSWORD=

DBNAME=dbname

#Where should i save pg dump-s?

TARGET=/mnt/seeme

if [ ! -d "/mnt/seeme/" ];then

    mkdir /mnt/seeme

fi

#Give pg_dump location

PGDUMP=/usr/lib/postgresql/9.6/bin/pg_dump

#Give me psql location

PSQL=/usr/lib/postgresql/9.6/bin/psql

#Give me psql connection port

PORT=5432

BEFOREDATE=$(date '+%Y-%m-%d' -d '10 day ago')

echo BEFORDATE

rm -rf $TARGET/dbname-$BEFOREDATE.sql

$PGDUMP -h 127.0.0.1 -p $PORT -U $PGUSER -d $DBNAME -f $TARGET/dbname-`date +%Y-%m-%d`.sql

'SQL' 카테고리의 다른 글

Oracle hint  (0) 2018.10.15
postgreSql 백업  (0) 2018.10.10
postgreSQL 백업스크립트  (0) 2018.10.10
컬럼값에서 HTML 태그 제거하기  (0) 2017.06.20
하이버네이트 API 문서  (0) 2017.06.19
JOIN 종류 정리  (0) 2017.06.18

+ Recent posts