Under windows postgresql database backup and restore

1, by cmd into the bin directory database

cd C:\Program Files\PostgreSQL\9.6\bin

2, the implementation pg_dump backup command, localhost or IP

pg_dump -h host -p port -U username  -d dbname> C:\dbname.bak

After the implementation, will remind password is to enter a password

示例:pg_dump -h localhost -p 5432 -U postgres -d ship> C:\ship.bak

3, execute psql to restore order, before that, the need to build a database of the same name blank
psql -h localhost -p 5432 -U postgres -d ship <C: \ ship.bak

psql -h localhost -p 5432 -U postgres -d ship -f "C:\ship.bak"

After the implementation, will remind password is to enter a password

 

 

Command Description:

pg_dump to dump a database as plain text files or other formats. 

Usage: 
  pg_dump [options] ... [database name] 

general options:
   -f, --file = FILENAME output file or directory name
   -F, --format c = | d | t | the p-output file format (custom, directory, tar) 
                               in clear text (default value))
   -v, - verbose verbose mode
   -V, - version output version information, then exit
   -Z, --compress = 0 - . 9            is the level of compression format
   - lock -wait-timeout = tIMEOUT operation fails after waiting table lock timeout
   - ?, - help display this help and exit 

control output content options:
   -a, --data - only dump only the data, not including the mode
   -b, -blobs include large objects in the dump
   -c, - Clean before re-create, to clear (delete) database objects
   -C, - the Create command included in the dump in order to create a database
   -E, --encoding = the ENCODING Transfer of data in encoded form eNCODING
   -n, --schema = SCHEMA dump mode only the specified name
   -N, --exclude = Schema- SCHEMA not named dump mode
   -o, - OIDs in the dump including the OID
   -O, --no- owner in plain text format, an owner to restore the object is ignored

   -s, --schema- only just dump mode, data does not include
   -S, = --superuser NAME specified in plain text format super user name
   -t, --table = tABLE dumps only the specified name table
   -T, --exclude-= table tABLE table designation does not dump the name
  -x, --no-privileges do not dump permission (Grant / REVOKE)
   --binary- upgrade can only be used by the upgrade tool
   --column- inserts to INSERT commands with column names in the form of dump
   --disable-dollar - quoting cancel dollar (sign) in quotation marks, using standard SQL quotes
   --disable the triggers disable triggers during data recovery only in the
   --exclude-table-data = data table tABLE does not specify the name of the dump
   - inserts in the INSERT command, rather than to dump the data in the form of COPY command
   --no-security- dispensing labels do not dump the security tag
   --no- the tablespaces not dump space allocation table information
   --no-unlogged-the table- data not turn no log storage table data
   --quote-all- identifiers quoted identifiers of all, if not a keyword
   --section =(Before and after data, data, and data) SECTION backup named section
   --serializable- DEFERRABLE wait until backup can run without exception
   --use- the SET -session- the Authorization 
                               to use SESSION AUTHORIZATION commands instead of 
                ALTER OWNER commands to set ownership 

connection options:
   - h, --host = host name of the database server's host name or socket directory
   -p, --port = port number of the database server port number of
   -U, --username = name of the user to specify the database connection
   -w, - -NO- password never prompt for a password
   -W, - password Force password prompt (automatic)
   --role = ROLENAME run SET ROLE before dumping 

if no database name, use PGDATABASE environment variable 
values. 

report mistake to<[email protected]>.

 

Guess you like

Origin www.cnblogs.com/tiandi/p/11809277.html