図1に示すように、ローカルのPostgreSQLビューミラー
[ルート@ localhostのホーム]#]ドッキングウィンドウの画像| grepのpostgresの 最新0d2531ee3abd postgresの 4日前に397メガバイト
図2に示すように、ミラーを初期化します
[ルート@ localhostのホーム]#]ドッキングウィンドウの実行--name postgres2 -e POSTGRES_PASSWORD =パスワード-p 5432:5432 -v PGDATA:は/ var / libに/ postgresqlの/データ- Dのpostgres 72c5af7ed83cf389d8a950411dd25124d0feae1b017213818d1b19d2609c7a49
-pポートマッピング
ホストサーバに格納されたデータを-v
-e POSTGRES_PASSWORDパスワード(デフォルトのユーザ名はpostgres)
-e TZ = PRCのタイムゾーン、中国
-d背景
--nameコンテナ名
タイムゾーンの問題
タイムゾーンがコンテナの開始時に提供されていない場合は、デフォルトでは、デフォルト値の時間差を設定することになりました()を使用して、UTCです。
図3に示すように、ミラーに
[ルート@ localhostのホーム]#ドッキングウィンドウのexec -it postgres2 / binに/ bashの 72c5af7ed83c @ルート: /#lsの ビンブートdevのドッキングウィンドウ -entrypoint-initdb.dドッキングウィンドウ-エントリポイント。SH などの家庭用LIB lib64をメディアはOPTのprocルートの実行をmntにsbinにSRV SYS tmpにUSR VAR
/ var / libに/ postgresqlの/データのミラーリングデータディレクトリ
ルート@ 72c5af7ed83c:/#CDの/ var / libに/ postgresqlの/ データ 72c5af7ed83c @ルート:の/ var / libに/ postgresqlの/データ#のLS ベースpg_dynshmem pg_logical pg_replslot pg_stat pg_tblspc pg_wal postgresql.confの グローバルpg_hba.confのpg_multixact pg_serial pg_stat_tmp pg_twophase pg_xact postmaster.opts pg_commit_tsなpg_ident.conf pg_notify pg_snapshots pg_subtrans PG_VERSION postgresql.auto.conf postmaster.pid
4、PostgreSQLのツールへのディレクトリは/ usr / libに/ postgresqlの/ 12 / binに
ルート@ 72c5af7ed83c:/#CDの/ usr / libに/ postgresqlの/ 12 / binに 72c5af7ed83c @ルート:は/ usr / libに/ postgresqlの/ 12 /ビン#のLS clusterdbはdropdbのoid2name pgbenchはpg_controldata pg_dumpallはpg_recvlogical pg_rewind pg_test_timing postgresのreindexdbは CREATEDB dropuserはpg_archivecleanup pg_checksumsにpg_ctl pg_isready pg_resetwal pg_standbyのpg_upgradeの郵便局長vacuumdbの createuserはinitdbをpg_basebackupはpg_configのpg_dump pg_receivewal pg_restoreのpg_test_fsync pg_waldump PSQL vacuumloを
5、データベースに接続します
ルート@ 72c5af7ed83cします。/ usr / lib / postgresqlの/ 12 / binに#psqlと- Upostgres PSQL(12.2(Debianの12.2 - 1 .pgdg100 + 1 )) 入力し、「助けを」 ための助け。 postgresの =#
図6に示すように、復元するデータベースDB1、DB1に挿入されたオブジェクト、データバックアップDB1及びDB2を作成します
-データベースの作成
のPostgresを=#CREATE DATABASEのDB1; CREATE DATABASEの Postgresのを=#CREATE DATABASE DB2; CREATE DATABASE
- Viewデータベース
のPostgres = #\ L リストのデータベース 名前 | 所有者 | エンコーディング| 部単位 | CTYPE | アクセス権限 - --------- + ---------- + ---------- + ------------ + - ----------- + ----------------------- DB1 | postgresの| UTF8 | en_US.utf8の| en_US.utf8の| DB2 | postgresの| UTF8 | en_US.utf8の| en_US.utf8の| postgresの | postgresの| UTF8 |en_US.utf8の| en_US.utf8の| template1では| Postgresの| UTF8 | en_US.utf8の| en_US.utf8の| = C / Postgresの + | | | | | postgresの= CTC / Postgresの template1 | Postgresの| UTF8 | en_US.utf8の| en_US.utf8の| = C / Postgresの + | | | | | postgresの= CTC / Postgresの (5 行)
-スイッチングデータベース postgresの= #\ C DB1 あなたは、現在接続されているに データベース「DB1」として ユーザー「はpostgres」。 DB1 =#作成し 、テーブル T1(int型); CREATE TABLE DB1 =#インサート に、T1 値(123 )。 INSERT 0 1 DB1 =#選択 * からT1。 A - --- 123 (1行)
バックアップ
。/ pg_dumpの- Upostgres - DDB1 - FのC - F ダンプ .SQL
削減
。/ pg_restoreの- Upostgres - DDB2 -のFc ダンプ .DMP
表示結果が復元します
ルート72c5af7ed83c @:/ USR / libに/ postgresqlの/ 12 /ビン#psqlと- Upostgres - D DB2 PSQL(12.2(Debianの12.2 - 1 .pgdg100 + 1 )) 「ヘルプ」を入力するために役立ちます。 DB2 =#選択 * からT1; A - --- 123 (1行)
- -終わり