설문조사
PostgreSQL/PPAS 관련 듣고 싶은 교육은


총 게시물 187건, 최근 0 건
   

pg_dump 로 partition table 를 dump 할때요..^^

글쓴이 : 디비에이2 날짜 : 2015-05-19 (화) 10:40 조회 : 7299
안녕하세요..
ppas 에서는 일반 테이블들은 쉽게 dump 사용 하는데요 .
partition table 을 어떻게  dump 하고 복구할때는 어떤 방법으로 하는게 효과적인가요.?

부탁드립니다..^^

PostgresDBA 2015-05-19 (화) 18:42
파티션 테이블이라고 dump 하는 방법이 다르진 않습니다.
parent 테이블 dump 하면 아래 처럼 child table 까지 전부 dump 됩니다.

[enterprisedb@localhost:/ppas/test]$ pg_dump -U mig -d mydb -t sales > sales.sql
[enterprisedb@localhost:/ppas/test]$ cat sales.sql
--
-- EnterpriseDB database dump
--

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET edb_redwood_date = off;
SET default_with_rowids = off;
SET check_function_bodies = false;
SET client_min_messages = warning;

SET search_path = mig, pg_catalog, sys, dbo;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: sales; Type: TABLE; Schema: mig; Owner: mig; Tablespace:
--

CREATE TABLE sales (
    date character varying(10),
    amount numeric
)
PARTITION BY RANGE(date)

(
  PARTITION q1_2012 VALUES LESS THAN ('2012-04-01'),
  PARTITION q2_2012 VALUES LESS THAN ('2012-06-01'),
  PARTITION q3_2012 VALUES LESS THAN ('2012-08-01'),
  PARTITION q4_2012 VALUES LESS THAN ('2013-12-01'),
  PARTITION q4_2014 VALUES LESS THAN ('2015-01-01'),
  PARTITION q1_2015 VALUES LESS THAN ('2015-01-04'),
  PARTITION q2_2015 VALUES LESS THAN ('2015-12-30')
);


ALTER TABLE sales OWNER TO mig;

--
-- Data for Name: sales; Type: TABLE DATA; Schema: mig; Owner: mig
--

COPY sales (date, amount) FROM stdin;
2014-01-30      10
2015-01-30      10
\.


--
-- EnterpriseDB database dump complete
--

[enterprisedb@localhost:/ppas/test]$
댓글주소
     
     
디비에이2 2015-05-20 (수) 12:07
감사합니다..^^
댓글주소
PostgresDBA 2018-11-30 (금) 16:35
Ver 10 포함 이상 버전부터 이렇게 파티션테이블 parent 명만 명시해서 파티션 테이블 dump 가 불가능해졌습니다. 본사 공식문의했는데,  child  뺀 parent 테이블만 달랑 백업됩니다. 당근 데이터가 없겠지요 --;

Damn it.

테이블 단위 백업을 이용하는 고객은 반드시 점검하시기 바랍니다.
댓글주소
   

postgresdba.com