먼저 postgres 로 사용자 변경을 한다.
~]# su - postgres
만약 db name 이 test_db 라면 백업 해 보자
~]$ pg_dump test_db > test_db.dump
좀더 자세히 알고 싶다면 아래 내용을 확인해 보자.
pd_dump 매뉴얼 에 설명된 내용이다.
EXAMPLES
To dump a database called mydb into a SQL-script file:
$ pg_dump mydb > db.sql
To reload such a script into a (freshly created) database named newdb:
$ psql -d newdb -f db.sql
To dump a database into a custom-format archive file:
$ pg_dump -Fc mydb > db.dump
To dump a database into a directory-format archive:
$ pg_dump -Fd mydb -f dumpdir
To reload an archive file into a (freshly created) database named newdb:
$ pg_restore -d newdb db.dump
To dump a single table named mytab:
$ pg_dump -t mytab mydb > db.sql
To dump all tables whose names start with emp in the detroit schema, except for the table named
employee_log:
$ pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb > db.sql
To dump all schemas whose names start with east or west and end in gsm, excluding any schemas
whose names contain the word test:
$ pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb > db.sql
The same, using regular expression notation to consolidate the switches:
$ pg_dump -n '(east|west)*gsm' -N '*test*' mydb > db.sql
To dump all database objects except for tables whose names begin with ts_:
$ pg_dump -T 'ts_*' mydb > db.sql
'Database > PostgreSQL' 카테고리의 다른 글
[PostgreSQL] 테이블 조회 한 내용을 csv 로 만들기 (0) | 2019.07.31 |
---|---|
[PostgresSQL] Centos 7 Postgresql 11 설치 방법 (0) | 2019.07.31 |
[PostgreSQL] PERFORM 결과가 없는 실행 Executing a Command With No Result (0) | 2019.04.16 |
[PostgreSQL] pgcrypto 설치 하기 (0) | 2019.04.10 |
[PostgreSQL] Function 만들기 (0) | 2018.01.29 |