https://www.postgresql.org/docs/12/app-pgdump.html
1. full 백업 & 복원
# pg_dumpall > backup.file
plain text형태의 query형 dump 파일생성
[root@linux /]# su - postgres
Last login: Sat Jul 4 11:27:18 KST 2020 on pts/0
-bash-4.2$ ps -ef | grep postgres
root 4185 3698 0 11:33 pts/0 00:00:00 su - postgres
postgres 4186 4185 0 11:33 pts/0 00:00:00 -bash
postgres 4245 4186 0 11:33 pts/0 00:00:00 ps -ef
postgres 4246 4186 0 11:33 pts/0 00:00:00 grep --color=auto postgres
postgres 104695 1 0 Jun08 ? 00:01:59 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/
postgres 104702 104695 0 Jun08 ? 00:00:02 postgres: logger
postgres 104705 104695 0 Jun08 ? 00:00:07 postgres: checkpointer
postgres 104706 104695 0 Jun08 ? 00:00:41 postgres: background writer
postgres 104707 104695 0 Jun08 ? 00:00:58 postgres: walwriter
postgres 104708 104695 0 Jun08 ? 00:00:53 postgres: autovacuum launcher
postgres 104709 104695 0 Jun08 ? 00:02:12 postgres: stats collector
postgres 104710 104695 0 Jun08 ? 00:00:02 postgres: logical replication launcher
postgres 116461 104695 0 Jul03 ? 00:00:00 postgres: blog blog.daonelab.com 220.122.150.231(1957) idle in transaction
-bash-4.2$
-bash-4.2$ cd /var/lib/pgsql/12/backups
-bash-4.2$ pwd
/var/lib/pgsql/12/backups
-bash-4.2$
-bash-4.2$ pg_dumpall > full_20200704.sql
-bash-4.2$ ls -al
total 6892
drwx------ 2 postgres postgres 30 Jul 4 11:34 .
drwx------ 4 postgres postgres 48 May 14 18:49 ..
-rw-r--r-- 1 postgres postgres 7054582 Jul 4 11:34 full_20200704.sql
-bash-4.2$
# psql -f backup.file
-bash-4.2$ pwd
/var/lib/pgsql/12/backups
-bash-4.2$
-bash-4.2$
-bash-4.2$ ls -al
total 6892
drwx------ 2 postgres postgres 30 Jul 4 11:34 .
drwx------ 4 postgres postgres 48 May 14 18:49 ..
-rw-r--r-- 1 postgres postgres 7054582 Jul 4 11:34 full_20200704.sql
-bash-4.2$
-bash-4.2$
-bash-4.2$
-bash-4.2$ psql -f full_20200704.sql
Windows에서 복원할때는 DB를 미리 생성해둬야 됐는데, RadHat에서는 미리 만들어 놓지 않고 복원해도 잘되었다.
-bash-4.2$ psql -U postgres -f full_2021.10.24.sql blog.daonelab.com