|
|
<!DOCTYPE html>
|
|
|
<html lang="en-us">
|
|
|
<head><meta charset="utf-8">
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
<script type="application/ld+json">
|
|
|
{
|
|
|
"@context" : "http://schema.org",
|
|
|
"@type" : "BlogPosting",
|
|
|
"mainEntityOfPage": {
|
|
|
"@type": "WebPage",
|
|
|
"@id": "https:\/\/h.cowbay.org"
|
|
|
},
|
|
|
"articleSection" : "post",
|
|
|
"name" : "[筆記] 在Ubuntu 18.04 下 透過 pgbarman streaming backup 備份 postgresql 10\/ backup postgresql 10 with pgbarman straming backup in ubuntu 18.04",
|
|
|
"headline" : "[筆記] 在Ubuntu 18.04 下 透過 pgbarman streaming backup 備份 postgresql 10\/ backup postgresql 10 with pgbarman straming backup in ubuntu 18.04",
|
|
|
"description" : "\x3cp\x3e很久以前就有看到這個用來備份postgresql 的 pgbarman\x3c\/p\x3e\n\n\x3cp\x3e\x3ca href=\x22https:\/\/www.pgbarman.org\/\x22\x3ehttps:\/\/www.pgbarman.org\/\x3c\/a\x3e\x3c\/p\x3e\n\n\x3cp\x3e前幾天老闆在slack 上面又提到,所以這次就花了點時間來玩玩看\x3c\/p\x3e\n\n\x3cp\x3e不過呢,雖然有弄起來,但是還真不知道有些問題是怎麼解決的\x26hellip;\x3c\/p\x3e",
|
|
|
"inLanguage" : "en",
|
|
|
"author" : "Eric Chang",
|
|
|
"creator" : "Eric Chang",
|
|
|
"publisher": "Eric Chang",
|
|
|
"accountablePerson" : "Eric Chang",
|
|
|
"copyrightHolder" : "Eric Chang",
|
|
|
"copyrightYear" : "2019",
|
|
|
"datePublished": "2019-08-23 13:53:40 \x2b0800 CST",
|
|
|
"dateModified" : "2019-08-23 13:53:40 \x2b0800 CST",
|
|
|
"url" : "https:\/\/h.cowbay.org\/post\/pgbarman-in-ubuntu-1804-postgresql-10\/",
|
|
|
"wordCount" : "776",
|
|
|
"image" : "https://h.cowbay.orghttps://h.cowbay.org/images/post-default-4.jpg"",
|
|
|
"keywords" : [ ""postgresql"",""pgbarman"","Blog" ]
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
|
|
|
<title>[筆記] 在Ubuntu 18.04 下 透過 pgbarman streaming backup 備份 postgresql 10/ backup postgresql 10 with pgbarman straming backup in ubuntu 18.04 </title>
|
|
|
|
|
|
|
|
|
<meta name="description" content="some articles about job,food,passion sisters" />
|
|
|
|
|
|
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
<meta name="robots" content="all,follow">
|
|
|
<meta name="googlebot" content="index,follow,snippet,archive">
|
|
|
<link rel="stylesheet" id="ct-tracks-google-fonts-css" href="https://fonts.googleapis.com/css?family=Raleway%3A400%2C700&subset=latin%2Clatin-ext&ver=4.7.2" type="text/css" media="all">
|
|
|
|
|
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
|
|
|
|
|
|
<link href="https://h.cowbay.org/css/style.css?v=1624607940" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
|
|
|
|
|
|
<link href="https://h.cowbay.org/css/custom.css?v=1624607940" rel="stylesheet" type='text/css' media='all'>
|
|
|
<link rel="shortcut icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
|
|
|
<link rel="icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
|
|
|
|
|
|
|
|
|
<script type="application/javascript">
|
|
|
var doNotTrack = false;
|
|
|
if (!doNotTrack) {
|
|
|
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
|
|
|
ga('create', 'UA-138954876-1', 'auto');
|
|
|
|
|
|
ga('send', 'pageview');
|
|
|
}
|
|
|
</script>
|
|
|
<script async src='https://www.google-analytics.com/analytics.js'></script>
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
<body class="post-template-default single single-post single-format-standard ct-body singular singular-post not-front standard">
|
|
|
|
|
|
<div id="overflow-container" class="overflow-container">
|
|
|
<a class="skip-content" href="#main">Skip to content</a>
|
|
|
<header id="site-header" class="site-header" role="banner">
|
|
|
<div class='top-navigation'>
|
|
|
<div class='container'>
|
|
|
|
|
|
<div id="menu-secondary" class="menu-container menu-secondary" role="navigation">
|
|
|
<button id="toggle-secondary-navigation" class="toggle-secondary-navigation"><i class="fas fa-plus"></i></button>
|
|
|
|
|
|
<div class="menu">
|
|
|
|
|
|
<ul id="menu-secondary-items" class="menu-secondary-items">
|
|
|
|
|
|
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
|
|
<a href="/categories/"></a>
|
|
|
</li>
|
|
|
|
|
|
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
|
|
<a href="/categories/ansible">ansible</a>
|
|
|
</li>
|
|
|
|
|
|
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
|
|
<a href="/categories/linux">linux</a>
|
|
|
</li>
|
|
|
|
|
|
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
|
|
<a href="/categories/proxmox">proxmox</a>
|
|
|
</li>
|
|
|
|
|
|
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
|
|
<a href="/categories/ps">ps</a>
|
|
|
</li>
|
|
|
|
|
|
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
|
|
<a href="/categories/%E7%A2%8E%E5%BF%B5">碎念</a>
|
|
|
</li>
|
|
|
|
|
|
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
|
|
<a href="/categories/%E7%AD%86%E8%A8%98">筆記</a>
|
|
|
</li>
|
|
|
|
|
|
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
|
|
<a href="/categories/%E7%BE%A4%E6%9A%89">群暉</a>
|
|
|
</li>
|
|
|
|
|
|
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
|
|
|
<a href="/categories/%E9%9B%9C%E5%BF%B5">雜念</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
<ul class="social-media-icons">
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="full%20Social%20profile%20url%20in%20facebook" data-animate-hover="pulse" class="facebook" target="_blank">
|
|
|
<i class="fab fa-facebook-square" title="facebook"></i>
|
|
|
<span class="screen-reader-text">facebook</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="full%20profile%20url%20in%20googleplus" data-animate-hover="pulse" class="gplus" target="_blank">
|
|
|
<i class="fab fa-google-plus-g" title="googleplus"></i>
|
|
|
<span class="screen-reader-text">googleplus</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="chang0206" data-animate-hover="pulse" class="twitter" target="_blank">
|
|
|
<i class="fab fa-twitter-square" title="twitter"></i>
|
|
|
<span class="screen-reader-text">twitter</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="chang0206" data-animate-hover="pulse" class="instagram" target="_blank">
|
|
|
<i class="fab fa-instagram" title="instagram"></i>
|
|
|
<span class="screen-reader-text">instagram</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="mailto:mc@hotshraingmy.info" data-animate-hover="pulse" class="email">
|
|
|
<i class="fas fa-envelope" title="email"></i>
|
|
|
<span class="screen-reader-text">email</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="full%20profile%20url%20in%20linkedin" data-animate-hover="pulse" class="linkedin" target="_blank">
|
|
|
<i class="fab fa-linkedin-in" title="linkedin"></i>
|
|
|
<span class="screen-reader-text">linkedin</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="full%20profile%20url%20in%20stackoverflow" data-animate-hover="pulse" class="stackoverflow" target="_blank">
|
|
|
<i class="fab fa-stack-overflow" title="stackoverflow"></i>
|
|
|
<span class="screen-reader-text">stackoverflow</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="changchichung" data-animate-hover="pulse" class="github" target="_blank">
|
|
|
<i class="fab fa-github" title="github"></i>
|
|
|
<span class="screen-reader-text">github</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="full%20profile%20url%20in%20pinterest" data-animate-hover="pulse" class="pinterest" target="_blank">
|
|
|
<i class="fab fa-pinterest" title="pinterest"></i>
|
|
|
<span class="screen-reader-text">pinterest</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="https://h.cowbay.org/index.xml" data-animate-hover="pulse" class="rss" target="_blank">
|
|
|
<i class="fas fa-rss" title="rss"></i>
|
|
|
<span class="screen-reader-text">rss</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
</ul></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="container">
|
|
|
<div id="title-info" class="title-info">
|
|
|
<div id='site-title' class='site-title'>
|
|
|
|
|
|
<a href="/"> MC部落 </a>
|
|
|
</div>
|
|
|
</div>
|
|
|
<button id="toggle-navigation" class="toggle-navigation">
|
|
|
<i class="fas fa-bars"></i>
|
|
|
</button>
|
|
|
|
|
|
<div id="menu-primary-tracks" class="menu-primary-tracks"></div>
|
|
|
<div id="menu-primary" class="menu-container menu-primary" role="navigation">
|
|
|
|
|
|
<p class="site-description">What’s the Worst That Could Happen?</p>
|
|
|
|
|
|
|
|
|
<div class="menu">
|
|
|
<ul id="menu-primary-items" class="menu-primary-items">
|
|
|
|
|
|
|
|
|
<li class='menu-item menu-item-type-custom menu-item-object-custom '>
|
|
|
<a href="https://h.cowbay.org/">Home</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
<li class='menu-item menu-item-type-post_type menu-item-object-page '>
|
|
|
<a href="https://h.cowbay.org/about/">About</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
<li class='menu-item menu-item-type-post_type menu-item-object-page '>
|
|
|
<a href="https://h.cowbay.org/contact/">Get in touch</a>
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
</header>
|
|
|
|
|
|
<div id="main" class="main" role="main">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div id="loop-container" class="loop-container">
|
|
|
|
|
|
<div class="post type-post status-publish format-standard has-post-thumbnail hentry category-design tag-design tag-standard-2 tag-tagalicious tag-travel entry full-without-featured odd excerpt-1">
|
|
|
|
|
|
<div class='featured-image lazy lazy-bg-image' data-background="https://h.cowbay.org/images/post-default-4.jpg">
|
|
|
</div>
|
|
|
|
|
|
<div class="entry-meta">
|
|
|
<span class="date">23 August</span> <span> / </span>
|
|
|
|
|
|
<span class="author">
|
|
|
<a href="https://github.com/changchichung" title="Posts by Eric Chang" rel="author">Eric Chang</a>
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
<span class="category">
|
|
|
<span> / </span>
|
|
|
|
|
|
<a href="/categories/%E7%AD%86%E8%A8%98">筆記</a>
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
<div class='entry-header'>
|
|
|
<h1 class='entry-title'> [筆記] 在Ubuntu 18.04 下 透過 pgbarman streaming backup 備份 postgresql 10/ backup postgresql 10 with pgbarman straming backup in ubuntu 18.04</h1>
|
|
|
</div>
|
|
|
<div class="entry-container">
|
|
|
<div class="entry-content">
|
|
|
<article>
|
|
|
<p>很久以前就有看到這個用來備份postgresql 的 pgbarman</p>
|
|
|
|
|
|
<p><a href="https://www.pgbarman.org/">https://www.pgbarman.org/</a></p>
|
|
|
|
|
|
<p>前幾天老闆在slack 上面又提到,所以這次就花了點時間來玩玩看</p>
|
|
|
|
|
|
<p>不過呢,雖然有弄起來,但是還真不知道有些問題是怎麼解決的…</p>
|
|
|
|
|
|
<p>pgbarman 的備份有分兩種</p>
|
|
|
|
|
|
<p>streaming && rsync/SSH</p>
|
|
|
|
|
|
<p>原理就不說了,我一直沒搞懂 postgresql 的 streaming ..</p>
|
|
|
|
|
|
<p>依照官方網站上的說法,比較推薦 streaming 備份的方式</p>
|
|
|
|
|
|
<p>原因是,設定相對簡單,WTF !</p>
|
|
|
|
|
|
<pre><code>On a general basis, starting from Barman 2.0, backup over streaming replication is the recommended setup for PostgreSQL 9.4 or higher
|
|
|
The reason why we recommend streaming backup is that, based on our experience, it is easier to setup than the traditional one
|
|
|
</code></pre>
|
|
|
|
|
|
<p>事實上呢,設定的確是很簡單,可是有個致命的缺點</p>
|
|
|
|
|
|
<pre><code>Because Barman transparently makes use of pg_basebackup, features such as incremental backup, parallel backup, deduplication, and network compression are currently not available. In this case, bandwidth limitation has some restrictions - compared to the traditional method via rsync.
|
|
|
</code></pre>
|
|
|
|
|
|
<p>如果要做差異/增量備份, streaming backup 不能做</p>
|
|
|
|
|
|
<p>所以每次備份都是完整備份,也因此,barman server 需要準備很大的硬碟空間</p>
|
|
|
|
|
|
<p>以我測試的資料庫來說,一次備份,目前是133G ,如果一天四次,保留七天</p>
|
|
|
|
|
|
<p>就需要 133 x 4 x 7 = 3724G</p>
|
|
|
|
|
|
<p>咦,這樣看起來,其實也還好啦 XDD</p>
|
|
|
|
|
|
<hr />
|
|
|
|
|
|
<p>現在開始設定的部份</p>
|
|
|
|
|
|
<h4 id="設定-postgresql-server">設定 postgresql server</h4>
|
|
|
|
|
|
<p>IP: 192.168.11.19
|
|
|
hostname: hqs019</p>
|
|
|
|
|
|
<h5 id="在postgresql-建立相關帳號">在postgresql 建立相關帳號</h5>
|
|
|
|
|
|
<p>streaming backup 需要先在postgresql Server 上建立一個具有 superuser 權限的帳號</p>
|
|
|
|
|
|
<p>以及一個用來做replication 的資料庫帳號</p>
|
|
|
|
|
|
<p>這裡就簡單帶過</p>
|
|
|
|
|
|
<pre><code>sudo su - postgres
|
|
|
psql
|
|
|
|
|
|
create user barman with login superuser login password 'barmanpassword';
|
|
|
CREATE ROLE stream_barman WITH REPLICATION PASSWORD 'password' LOGIN;
|
|
|
</code></pre>
|
|
|
|
|
|
<h5 id="鄉改-pg-hba-conf">鄉改 pg_hba.conf</h5>
|
|
|
|
|
|
<p>然後修改 pg_hba.conf,加入底下兩行</p>
|
|
|
|
|
|
<pre><code># for barman test
|
|
|
host database_name barman 192.168.11.192/32 md5
|
|
|
host replication stream_barman 192.168.11.192/32 md5
|
|
|
</code></pre>
|
|
|
|
|
|
<p>當然,如果不考慮安全性問題, md5 直接改成用 trust ,可以省去一些麻煩。</p>
|
|
|
|
|
|
<h5 id="修改-postgresql-conf">修改 postgresql.conf</h5>
|
|
|
|
|
|
<p>接著修改postgresql.conf</p>
|
|
|
|
|
|
<pre><code>### for barman test
|
|
|
max_wal_senders = 5
|
|
|
max_replication_slots = 3
|
|
|
wal_level = 'archive'
|
|
|
archive_mode = on
|
|
|
</code></pre>
|
|
|
|
|
|
<p>重起 postgresql service</p>
|
|
|
|
|
|
<h4 id="設定barman-server">設定barman server</h4>
|
|
|
|
|
|
<p>IP: 192.168.11.192
|
|
|
hostname: barman</p>
|
|
|
|
|
|
<h5 id="安裝-barman">安裝 barman</h5>
|
|
|
|
|
|
<p>barman 在18.04 中,已經被放到標準repository 中</p>
|
|
|
|
|
|
<p>所以只要直接</p>
|
|
|
|
|
|
<pre><code>sudo apt install barman
|
|
|
</code></pre>
|
|
|
|
|
|
<p>就可以了</p>
|
|
|
|
|
|
<h5 id="設定-barman-conf">設定 barman.conf</h5>
|
|
|
|
|
|
<p>安裝完成後,在/etc/barman.d/ 底下會有兩個範例檔案</p>
|
|
|
|
|
|
<pre><code>streaming-server.conf-template
|
|
|
ssh-server.conf-template
|
|
|
</code></pre>
|
|
|
|
|
|
<p>複製 streaming-server 檔案</p>
|
|
|
|
|
|
<pre><code>sudo cp /etc/barman.d/streaming-server.conf-template /etc/barman.d/hqs019.conf
|
|
|
</code></pre>
|
|
|
|
|
|
<p>內容如下</p>
|
|
|
|
|
|
<pre><code>[hqs019]
|
|
|
description = "hqs019 "
|
|
|
conninfo = host=192.168.11.19 user=barman dbname=database_name password=barmanpassword
|
|
|
streaming_conninfo = host=192.168.11.19 user=stream_barman dbname=database_name password=password
|
|
|
backup_method = postgres
|
|
|
retention_policy_mode = auto
|
|
|
streaming_archiver = on
|
|
|
slot_name = barman
|
|
|
</code></pre>
|
|
|
|
|
|
<p>接著修改 /etc/barman.conf</p>
|
|
|
|
|
|
<pre><code>[barman]
|
|
|
barman_user = barman
|
|
|
configuration_files_directory = /etc/barman.d
|
|
|
barman_home = /var/lib/barman
|
|
|
log_file = /var/log/barman/barman.log
|
|
|
log_level = DEBUG
|
|
|
compression = gzip
|
|
|
immediate_checkpoint = true
|
|
|
basebackup_retry_times = 3
|
|
|
basebackup_retry_sleep = 30
|
|
|
last_backup_maximum_age = 1 DAYS
|
|
|
</code></pre>
|
|
|
|
|
|
<p>基本上這樣就設定完成了</p>
|
|
|
|
|
|
<h5 id="檢查設定">檢查設定</h5>
|
|
|
|
|
|
<p>barman 有一些指令可以用來檢查目前的設定</p>
|
|
|
|
|
|
<p>barman show-server hqs019 可以看到所有的設定,這裡的 hqs019 跟 barman.d/hqs019.conf 裡面用”[ ]” 包起來的名稱要一致</p>
|
|
|
|
|
|
<pre><code>barman@barman:~$ barman show-server hqs019
|
|
|
Server hqs019:
|
|
|
active: True
|
|
|
archiver: False
|
|
|
archiver_batch_size: 0
|
|
|
backup_directory: /var/lib/barman/hqs019
|
|
|
backup_method: postgres
|
|
|
backup_options: BackupOptions(['concurrent_backup'])
|
|
|
bandwidth_limit: None
|
|
|
barman_home: /var/lib/barman
|
|
|
barman_lock_directory: /var/lib/barman
|
|
|
basebackup_retry_sleep: 30
|
|
|
basebackup_retry_times: 3
|
|
|
basebackups_directory: /var/lib/barman/hqs019/base
|
|
|
check_timeout: 30
|
|
|
compression: gzip
|
|
|
config_file: /etc/postgresql/10/main/postgresql.conf
|
|
|
connection_error: None
|
|
|
conninfo: host=192.168.11.19 user=barman dbname=database_name password=barmanpassword
|
|
|
current_size: 142740768562
|
|
|
current_xlog: 0000000100000264000000BA
|
|
|
custom_compression_filter: None
|
|
|
custom_decompression_filter: None
|
|
|
data_directory: /database
|
|
|
description: hqs019
|
|
|
disabled: False
|
|
|
errors_directory: /var/lib/barman/hqs019/errors
|
|
|
hba_file: /etc/postgresql/10/main/pg_hba.conf
|
|
|
ident_file: /etc/postgresql/10/main/pg_ident.conf
|
|
|
immediate_checkpoint: True
|
|
|
incoming_wals_directory: /var/lib/barman/hqs019/incoming
|
|
|
is_in_recovery: False
|
|
|
is_superuser: True
|
|
|
last_backup_maximum_age: 1 day (WARNING! latest backup is No available backups old)
|
|
|
max_incoming_wals_queue: None
|
|
|
minimum_redundancy: 0
|
|
|
msg_list: []
|
|
|
name: hqs019
|
|
|
network_compression: False
|
|
|
parallel_jobs: 1
|
|
|
path_prefix: None
|
|
|
pg_basebackup_bwlimit: True
|
|
|
pg_basebackup_compatible: True
|
|
|
pg_basebackup_installed: True
|
|
|
pg_basebackup_path: /usr/bin/pg_basebackup
|
|
|
pg_basebackup_tbls_mapping: True
|
|
|
pg_basebackup_version: 10.10-0ubuntu0.18.04.1)
|
|
|
pg_receivexlog_compatible: True
|
|
|
pg_receivexlog_installed: True
|
|
|
pg_receivexlog_path: /usr/bin/pg_receivewal
|
|
|
pg_receivexlog_supports_slots: True
|
|
|
pg_receivexlog_synchronous: False
|
|
|
pg_receivexlog_version: 10.10-0ubuntu0.18.04.1)
|
|
|
pgespresso_installed: False
|
|
|
post_archive_retry_script: None
|
|
|
post_archive_script: None
|
|
|
post_backup_retry_script: None
|
|
|
post_backup_script: None
|
|
|
pre_archive_retry_script: None
|
|
|
pre_archive_script: None
|
|
|
pre_backup_retry_script: None
|
|
|
pre_backup_script: None
|
|
|
recovery_options: RecoveryOptions([])
|
|
|
replication_slot: Record(slot_name='barman', active=True, restart_lsn='264/BA000000')
|
|
|
replication_slot_support: True
|
|
|
retention_policy: None
|
|
|
retention_policy_mode: auto
|
|
|
reuse_backup: None
|
|
|
server_txt_version: 10.10
|
|
|
slot_name: barman
|
|
|
ssh_command: None
|
|
|
streaming: True
|
|
|
streaming_archiver: True
|
|
|
streaming_archiver_batch_size: 0
|
|
|
streaming_archiver_name: barman_receive_wal
|
|
|
streaming_backup_name: barman_streaming_backup
|
|
|
streaming_conninfo: host=192.168.11.19 user=stream_barman dbname=database_name password=password
|
|
|
streaming_supported: True
|
|
|
streaming_wals_directory: /var/lib/barman/hqs019/streaming
|
|
|
synchronous_standby_names: ['']
|
|
|
systemid: 6688476041000599317
|
|
|
tablespace_bandwidth_limit: None
|
|
|
timeline: 1
|
|
|
wal_level: replica
|
|
|
wal_retention_policy: main
|
|
|
wals_directory: /var/lib/barman/hqs019/wals
|
|
|
xlogpos: 264/BA000F08
|
|
|
</code></pre>
|
|
|
|
|
|
<p>然後用 barman check hqs019 來檢查config 有沒有問題</p>
|
|
|
|
|
|
<pre><code>barman@barman:~$ barman check hqs019
|
|
|
Server hqs019:
|
|
|
PostgreSQL: OK
|
|
|
is_superuser: OK
|
|
|
PostgreSQL streaming: OK
|
|
|
wal_level: OK
|
|
|
replication slot: OK
|
|
|
directories: OK
|
|
|
retention policy settings: OK
|
|
|
backup maximum age: FAILED (interval provided: 1 day, latest backup age: No available backups)
|
|
|
compression settings: OK
|
|
|
failed backups: OK (there are 0 failed backups)
|
|
|
minimum redundancy requirements: OK (have 0 backups, expected at least 0)
|
|
|
pg_basebackup: OK
|
|
|
pg_basebackup compatible: OK
|
|
|
pg_basebackup supports tablespaces mapping: OK
|
|
|
pg_receivexlog: OK
|
|
|
pg_receivexlog compatible: OK
|
|
|
receive-wal running: OK
|
|
|
archiver errors: OK
|
|
|
barman@barman:~$
|
|
|
</code></pre>
|
|
|
|
|
|
<p>那個backup maximum age FAILED 不用管他,因為都還沒跑過備份,這邊錯誤是正常的</p>
|
|
|
|
|
|
<p>其他都OK 的話,就可以開始備份了</p>
|
|
|
|
|
|
<p>barman backup hqs019</p>
|
|
|
|
|
|
<pre><code>barman@ubuntu:~$ barman backup hqs019
|
|
|
Starting backup using postgres method for server hqs019 in /var/lib/barman/hqs019/base/20190823T082258
|
|
|
Backup start at LSN: 264/A10001A8 (0000000100000264000000A1, 000001A8)
|
|
|
Starting backup copy via pg_basebackup for 20190823T082258
|
|
|
WARNING: pg_basebackup does not copy the PostgreSQL configuration files that reside outside PGDATA. Please manually backup the following files:
|
|
|
/etc/postgresql/10/main/postgresql.conf
|
|
|
/etc/postgresql/10/main/pg_hba.conf
|
|
|
/etc/postgresql/10/main/pg_ident.conf
|
|
|
|
|
|
Copy done (time: 1 hour, 6 minutes, 28 seconds)
|
|
|
Finalising the backup.
|
|
|
Backup size: 133.0 GiB
|
|
|
Backup end at LSN: 264/A3000060 (0000000100000264000000A3, 00000060)
|
|
|
Backup completed (start time: 2019-08-23 08:22:58.116372, elapsed time: 1 hour, 6 minutes, 28 seconds)
|
|
|
Processing xlog segments from streaming for hqs019
|
|
|
0000000100000264000000A2
|
|
|
|
|
|
barman@ubuntu:~$
|
|
|
</code></pre>
|
|
|
|
|
|
<p>跑完可以用 barman list-backup hqs019 檢查</p>
|
|
|
|
|
|
<pre><code>barman@ubuntu:~$ barman list-backup hqs019
|
|
|
hqs019 20190823T082258 - Thu Aug 22 17:29:26 2019 - Size: 133.0 GiB - WAL Size: 0 B (tablespaces: tablespace_a:/var/lib/postgresql/10/main/tablespace_A, tablespace_b:/var/lib/postgresql/10/main/tablespace_B)
|
|
|
</code></pre>
|
|
|
|
|
|
<p>要刪除的話,要加入 backupID</p>
|
|
|
|
|
|
<pre><code>barman@ubuntu:~$ barman delete hqs019 20190822T171355
|
|
|
Deleting backup 20190822T171355 for server hqs019
|
|
|
Delete associated WAL segments:
|
|
|
00000001000002640000009F
|
|
|
0000000100000264000000A0
|
|
|
0000000100000264000000A1
|
|
|
Deleted backup 20190822T171355 (start time: Fri Aug 23 09:36:43 2019, elapsed time: 3 seconds)
|
|
|
|
|
|
</code></pre>
|
|
|
|
|
|
<p>restore 的部份,暫時沒有測試,我想應該是要找時間測試看看怎麼還原才對</p>
|
|
|
|
|
|
<p>不過呢,前面有提到,用streaming backup ,每一次備份都是完整備份,非常的佔用空間、時間、頻寬</p>
|
|
|
|
|
|
<p>所以還是要來試試看用rsync/SSH 備份的機制</p>
|
|
|
</article>
|
|
|
</div>
|
|
|
|
|
|
<div class='entry-meta-bottom'>
|
|
|
|
|
|
|
|
|
<div class="entry-categories"><p><span>Categories</span>
|
|
|
|
|
|
<a href="/categories/%E7%AD%86%E8%A8%98" title="View all posts in 筆記">筆記</a>
|
|
|
</p>
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="entry-tags"><p><span>Tags</span>
|
|
|
|
|
|
<a href="/tags/postgresql" title="View all posts tagged postgresql">postgresql</a>
|
|
|
|
|
|
<a href="/tags/pgbarman" title="View all posts tagged pgbarman">pgbarman</a>
|
|
|
|
|
|
|
|
|
</p></div> </div>
|
|
|
|
|
|
|
|
|
<div class="author-meta">
|
|
|
|
|
|
<div class="author">
|
|
|
|
|
|
<img alt='Eric Chang' src="https://www.gravatar.com/avatar/23f8ed94e007297499ac8df1641b3ff5?s=100&d=identicon" class='avatar avatar-72 photo' height='72' width='72'>
|
|
|
|
|
|
<span>
|
|
|
Written by:<a href="https://github.com/changchichung" title="Posts by Eric Chang" rel="author">Eric Chang</a> </span>
|
|
|
</div>
|
|
|
<div class="bio">
|
|
|
|
|
|
|
|
|
<p>塵世裡一個迷途小書僮</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="facebook" target="_blank"
|
|
|
href="full%20Social%20profile%20url%20in%20facebook">
|
|
|
<i class="fab fa-facebook-f"
|
|
|
title="facebook icon"></i>
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
<a class="googleplus" target="_blank"
|
|
|
href="full%20profile%20url%20in%20googleplus">
|
|
|
<i class="fab fa-google-plus-g"
|
|
|
title="googleplus icon"></i>
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="twitter" target="_blank"
|
|
|
href="chang0206">
|
|
|
<i class="fab fa-twitter-square"
|
|
|
title="twitter icon"></i>
|
|
|
</a>
|
|
|
|
|
|
|
|
|
<a class="linkedin" target="_blank"
|
|
|
href="full%20profile%20url%20in%20linkedin">
|
|
|
<i class="fab fa-linkedin"
|
|
|
title="linkedin icon"></i>
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
<a class="email" target="_blank"
|
|
|
href="mailto:mc@hotshraingmy.info">
|
|
|
<i class="fas fa-envelope"
|
|
|
title="email icon"></i>
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
<a class="instagram" target="_blank"
|
|
|
href="chang0206">
|
|
|
<i class="fab fa-instagram"
|
|
|
title="instagram icon"></i>
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
<a class="stackoverflow" target="_blank"
|
|
|
href="full%20profile%20url%20in%20stackoverflow">
|
|
|
<i class="fab fa-stack-overflow"
|
|
|
title="stackoverflow icon"></i>
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
<a class="github" target="_blank"
|
|
|
href="changchichung">
|
|
|
<i class="fab fa-github"
|
|
|
title="github icon"></i>
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="pinterest" target="_blank"
|
|
|
href="full%20profile%20url%20in%20pinterest">
|
|
|
<i class="fab fa-pinterest"
|
|
|
title="pinterest icon"></i>
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<section id="comments" class="comments">
|
|
|
<div id="disqus_thread"></div>
|
|
|
<script type="application/javascript">
|
|
|
var disqus_config = function () {
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
(function() {
|
|
|
if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
|
|
|
document.getElementById('disqus_thread').innerHTML = 'Disqus comments not available by default when the website is previewed locally.';
|
|
|
return;
|
|
|
}
|
|
|
var d = document, s = d.createElement('script'); s.async = true;
|
|
|
s.src = '//' + "h-cowbay-org-1" + '.disqus.com/embed.js';
|
|
|
s.setAttribute('data-timestamp', +new Date());
|
|
|
(d.head || d.body).appendChild(s);
|
|
|
})();
|
|
|
</script>
|
|
|
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
|
|
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<footer id="site-footer" class="site-footer" role="contentinfo">
|
|
|
<h1>
|
|
|
|
|
|
<a href=""> MC部落 </a>
|
|
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
|
<p class="site-description">What’s the Worst That Could Happen?</p>
|
|
|
|
|
|
|
|
|
<div id="menu-footer" class="menu-container menu-footer" role="navigation">
|
|
|
<div class="menu">
|
|
|
|
|
|
<ul id="menu-footer-items" class="menu-footer-items">
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</div> </div>
|
|
|
|
|
|
<ul class="social-media-icons">
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a class="facebook" target="_blank"
|
|
|
href="full%20Social%20profile%20url%20in%20facebook" >
|
|
|
<i class="fab fa-facebook-f" title="facebook"></i>
|
|
|
<span class="screen-reader-text">facebook</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a class="googleplus" target="_blank"
|
|
|
href="full%20profile%20url%20in%20googleplus" >
|
|
|
<i class="fab fa-google-plus-g" title="googleplus"></i>
|
|
|
<span class="screen-reader-text">googleplus</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="chang0206" class="twitter" target="_blank">
|
|
|
<i class="fab fa-twitter-square" title="twitter"></i>
|
|
|
<span class="screen-reader-text">twitter</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="chang0206" class="instagram" target="_blank">
|
|
|
<i class="fab fa-instagram" title="instagram"></i>
|
|
|
<span class="screen-reader-text">instagram</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="mailto:mc@hotshraingmy.info" class="email">
|
|
|
<i class="fas fa-envelope" title="email"></i>
|
|
|
<span class="screen-reader-text">email</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="full%20profile%20url%20in%20linkedin" class="linkedin" target="_blank">
|
|
|
<i class="fab fa-linkedin-in" title="linkedin"></i>
|
|
|
<span class="screen-reader-text">linkedin</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="full%20profile%20url%20in%20stackoverflow" class="stackoverflow" target="_blank">
|
|
|
<i class="fab fa-stack-overflow" title="stackoverflow"></i>
|
|
|
<span class="screen-reader-text">stackoverflow</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="changchichung" class="github" target="_blank">
|
|
|
<i class="fab fa-github" title="github"></i>
|
|
|
<span class="screen-reader-text">github</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="full%20profile%20url%20in%20pinterest" class="pinterest" target="_blank">
|
|
|
<i class="fab fa-pinterest" title="pinterest"></i>
|
|
|
<span class="screen-reader-text">pinterest</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
<a href="https://h.cowbay.org/index.xml" data-animate-hover="pulse" class="rss" target="_blank">
|
|
|
<i class="fas fa-rss" title="rss"></i>
|
|
|
<span class="screen-reader-text">rss</span>
|
|
|
</a>
|
|
|
</li>
|
|
|
|
|
|
|
|
|
</ul> <div class="design-credit">
|
|
|
|
|
|
<p>© 2018 Göran Svensson</p>
|
|
|
|
|
|
<p>Nederburg Hugo Theme by <a href="https://appernetic.io">Appernetic</a>.</p>
|
|
|
|
|
|
<p>A port of Tracks by Compete Themes.</p>
|
|
|
|
|
|
</div>
|
|
|
</footer>
|
|
|
|
|
|
</div>
|
|
|
<script src="https://h.cowbay.org/js/jquery.min.js"></script>
|
|
|
<script src="https://h.cowbay.org/js/jquerymigrate.js"></script>
|
|
|
<script src="https://h.cowbay.org/js/production.min.js?v=1624607940"></script>
|
|
|
|
|
|
</body>
|
|
|
</html>
|