[フル・エディション]Postgresqlデータベースのバックアップとリカバリのプロセス

3911 ワード

0.準備
linux          pg   
       pg                        .

1.バックアップ先
1.        :
pg_dump -h 10.24.193.25 -U postgres -p 5432  -F c -f  /TestPG/TestDS0816.dmp TestDS0816
# -h           
# -U         
# -p    pg         .
# -F       . c          pg_dump  .
# -f     
#          . 

man    :
       -F format
       --format=format
           Selects the format of the output.  format can be one of the following:

           p
           plain
               Output a plain-text SQL script file (the default).

           c
           custom
               Output a custom-format archive suitable for input into pg_restore. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is
               also compressed by default.

           d
           directory
               Output a directory-format archive suitable for input into pg_restore. This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable
               format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports
               parallel dumps.

           t
           tar
               Output a tar-format archive suitable for input into pg_restore. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression.
               Also, when using tar format the relative order of table data items cannot be changed during restore.

2.ユーザーの作成およびデータベースの作成
     

 psql -U postgres

, , "" .
( .. .)


create role "TestDS0816" superuser login;

create database "TestDS0816" ;

alter role "TestDS0816" with password 'Test6530';
:
\q


 
3.リカバリの実行
pg_restore -U postgres -d TestDS0816 /TestPG/TestDS0816.dmp
# -U
# -d .

 
転載先:https://www.cnblogs.com/jinanxiaolaohu/p/11447639.html