zoukankan      html  css  js  c++  java
  • postgres 文件系统级别的备份 pg_dump

    一,pg_dump 介绍

    [postgres@kafka01 psql]$ pg_dump --help
    pg_dump dumps a database as a text file or to other formats.
    
    Usage:
      pg_dump [OPTION]... [DBNAME]
    
    General options:
      -f, --file=FILENAME          output file or directory name
      -F, --format=c|d|t|p         output file format (custom, directory, tar,
                                   plain text (default))
      -j, --jobs=NUM               use this many parallel jobs to dump
      -v, --verbose                verbose mode
      -V, --version                output version information, then exit
      -Z, --compress=0-9           compression level for compressed formats
      --lock-wait-timeout=TIMEOUT  fail after waiting TIMEOUT for a table lock
      --no-sync                    do not wait for changes to be written safely to disk
      -?, --help                   show this help, then exit
    
    Options controlling the output content:
      -a, --data-only              dump only the data, not the schema
      -b, --blobs                  include large objects in dump
      -B, --no-blobs               exclude large objects in dump
      -c, --clean                  clean (drop) database objects before recreating
      -C, --create                 include commands to create database in dump
      -E, --encoding=ENCODING      dump the data in encoding ENCODING
      -n, --schema=SCHEMA          dump the named schema(s) only
      -N, --exclude-schema=SCHEMA  do NOT dump the named schema(s)
      -o, --oids                   include OIDs in dump
      -O, --no-owner               skip restoration of object ownership in
                                   plain-text format
      -s, --schema-only            dump only the schema, no data
      -S, --superuser=NAME         superuser user name to use in plain-text format
      -t, --table=TABLE            dump the named table(s) only
      -T, --exclude-table=TABLE    do NOT dump the named table(s)
      -x, --no-privileges          do not dump privileges (grant/revoke)
      --binary-upgrade             for use by upgrade utilities only
      --column-inserts             dump data as INSERT commands with column names
      --disable-dollar-quoting     disable dollar quoting, use SQL standard quoting
      --disable-triggers           disable triggers during data-only restore
      --enable-row-security        enable row security (dump only content user has
                                   access to)
      --exclude-table-data=TABLE   do NOT dump data for the named table(s)
      --if-exists                  use IF EXISTS when dropping objects
      --inserts                    dump data as INSERT commands, rather than COPY
      --no-publications            do not dump publications
      --no-security-labels         do not dump security label assignments
      --no-subscriptions           do not dump subscriptions
      --no-synchronized-snapshots  do not use synchronized snapshots in parallel jobs
      --no-tablespaces             do not dump tablespace assignments
      --no-unlogged-table-data     do not dump unlogged table data
      --quote-all-identifiers      quote all identifiers, even if not key words
      --section=SECTION            dump named section (pre-data, data, or post-data)
      --serializable-deferrable    wait until the dump can run without anomalies
      --snapshot=SNAPSHOT          use given snapshot for the dump
      --strict-names               require table and/or schema include patterns to
                                   match at least one entity each
      --use-set-session-authorization
                                   use SET SESSION AUTHORIZATION commands instead of
                                   ALTER OWNER commands to set ownership
    
    Connection options:
      -d, --dbname=DBNAME      database to dump
      -h, --host=HOSTNAME      database server host or socket directory
      -p, --port=PORT          database server port number
      -U, --username=NAME      connect as specified database user
      -w, --no-password        never prompt for password
      -W, --password           force password prompt (should happen automatically)
      --role=ROLENAME          do SET ROLE before dump
    
    If no database name is supplied, then the PGDATABASE environment
    variable value is used.
    
    Report bugs to <pgsql-bugs@postgresql.org>.

    二, 应用

      

    pg_dump -h 192.168.0.188 -U kingle -p 5432 -Fc -Z 9 -t tbl_partition >test_20200608 kingledb
    
    
    --9级压缩备份
    --转储表
    [postgres@kafka01 backup]$ pg_dump -h 192.168.0.188 -U kingle -p 5432 -Fp --insert --column-inserts -t tbl_partition >test_20200608_2 kingledb
    [postgres@kafka01 backup]$ cat test_20200608_2
    --
    -- PostgreSQL database dump
    --
    
    -- Dumped from database version 10.12
    -- Dumped by pg_dump version 10.12
    
    SET statement_timeout = 0;
    SET lock_timeout = 0;
    SET idle_in_transaction_session_timeout = 0;
    SET client_encoding = 'UTF8';
    SET standard_conforming_strings = on;
    SELECT pg_catalog.set_config('search_path', '', false);
    SET check_function_bodies = false;
    SET xmloption = content;
    SET client_min_messages = warning;
    SET row_security = off;
    
    SET default_tablespace = '';
    
    SET default_with_oids = false;
    
    --
    -- Name: tbl_partition; Type: TABLE; Schema: kingle; Owner: kingle
    --
    
    CREATE TABLE kingle.tbl_partition (
        id integer,
        name character varying(20),
        gender boolean,
        join_date date,
        dept character(4)
    );
    
    
    ALTER TABLE kingle.tbl_partition OWNER TO kingle;
    
    --
    -- Data for Name: tbl_partition; Type: TABLE DATA; Schema: kingle; Owner: kingle
    --
    
    
    
    --
    -- Name: tbl_partition insert_tbl_partition_trigger; Type: TRIGGER; Schema: kingle; Owner: kingle
    --
    
    CREATE TRIGGER insert_tbl_partition_trigger BEFORE INSERT ON kingle.tbl_partition FOR EACH ROW EXECUTE PROCEDURE kingle.tbl_partition_insert_trigger();
    
    
    --
    -- PostgreSQL database dump complete
    --
    
    [postgres@kafka01 backup]$
    View Code
  • 相关阅读:
    设计模式原则—依赖倒转原则(三)
    设计模式原则—单一职责原则(二)
    一步一个脚印学习WCF系列之WCF基础术语—契约的名称与命名空间(二)
    命名规范汇总文档供下载
    BCM平台全自动刷机软件,TFTP正式版1.62隆重发布,增加固件记忆功能
    WayOs内置免拉黑,就是把免拉黑程序集成在WayOs内部,增加守护进程及修改访问参数立即生效
    WayOs帐号获取保存工具增加提交的功能,WayOs扩展WAN口工具1.6发布增加网卡和VLAN混合组网功能
    好奇:WayOs破解、OEM、修复、打包等工具大全,满足大家的好奇心发下截图
    WayOs PPPoE群集服务器:自动同步用户信息,包括增加,更新,同步操作!保证多台服务器数据同步
    WayOs全面支持安卓手机,防二级路由开关、充值卡到期自动跳转页面功能隆重发布
  • 原文地址:https://www.cnblogs.com/kingle-study/p/13066258.html
Copyright © 2011-2022 走看看