Skip to content

Commit 183b4ad

Browse files
committed
update pig docs
1 parent 6ee135f commit 183b4ad

File tree

10 files changed

+334
-0
lines changed

10 files changed

+334
-0
lines changed

content/pig/cmd/pb.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,43 @@ weight: 670
77

88
The `pig pgbackrest` command (alias `pig pb`) manages pgBackRest backup and point-in-time recovery (PITR). It wraps common `pgbackrest` operations for simplified backup management. All commands execute as database superuser (default `postgres`).
99

10+
```bash
11+
pig pb - Manage pgBackRest backup and point-in-time recovery.
12+
13+
Information:
14+
pig pb info show backup info
15+
pig pb ls list backups
16+
pig pb ls repo list configured repositories
17+
pig pb ls stanza list all stanzas
18+
19+
Backup & Restore:
20+
pig pb backup create backup (auto: full/incr)
21+
pig pb backup full create full backup
22+
pig pb restore restore from backup (PITR)
23+
pig pb restore -t "..." restore to specific time
24+
pig pb expire cleanup expired backups
25+
26+
Stanza Management:
27+
pig pb create create stanza (first-time setup)
28+
pig pb upgrade upgrade stanza (after PG upgrade)
29+
pig pb delete delete stanza (DANGEROUS!)
30+
31+
Control:
32+
pig pb check verify backup integrity
33+
pig pb start enable pgBackRest operations
34+
pig pb stop disable pgBackRest operations
35+
pig pb log view pgBackRest logs
36+
37+
Examples:
38+
pig pb info # show all backup info
39+
pig pb backup # auto: full if none, else incr
40+
pig pb backup full # full backup
41+
pig pb restore # restore to latest (default)
42+
pig pb restore -t "2025-01-01 12:00:00+08" # restore to time
43+
pig pb create # initialize stanza
44+
pig pb expire # cleanup per retention policy
45+
```
46+
1047
------
1148

1249
## Command Overview

content/pig/cmd/pb.zh.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,43 @@ weight: 660
77

88
`pig pgbackrest` 命令(别名 `pig pb`)用于管理 pgBackRest 备份和时间点恢复(PITR)。它封装了常用的 `pgbackrest` 操作,提供简化的备份管理体验。所有命令均以数据库超级用户身份执行。
99

10+
```bash
11+
pig pb - 管理 pgBackRest 备份和时间点恢复
12+
13+
信息查询:
14+
pig pb info 显示备份信息
15+
pig pb ls 列出备份
16+
pig pb ls repo 列出已配置的仓库
17+
pig pb ls stanza 列出所有 stanza
18+
19+
备份与恢复:
20+
pig pb backup 创建备份(自动:全量/增量)
21+
pig pb backup full 创建全量备份
22+
pig pb restore 从备份恢复(PITR)
23+
pig pb restore -t "..." 恢复到指定时间
24+
pig pb expire 清理过期备份
25+
26+
Stanza 管理:
27+
pig pb create 创建 stanza(首次设置)
28+
pig pb upgrade 升级 stanza(PG 升级后)
29+
pig pb delete 删除 stanza(危险!)
30+
31+
控制命令:
32+
pig pb check 验证备份完整性
33+
pig pb start 启用 pgBackRest 操作
34+
pig pb stop 禁用 pgBackRest 操作
35+
pig pb log 查看 pgBackRest 日志
36+
37+
示例:
38+
pig pb info # 显示所有备份信息
39+
pig pb backup # 自动:无备份则全量,否则增量
40+
pig pb backup full # 全量备份
41+
pig pb restore # 恢复到最新(默认)
42+
pig pb restore -t "2025-01-01 12:00:00+08" # 恢复到指定时间
43+
pig pb create # 初始化 stanza
44+
pig pb expire # 按保留策略清理
45+
```
46+
1047

1148
## 命令概览
1249

content/pig/cmd/pg.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,45 @@ weight: 650
77

88
The `pig pg` command (alias `pig postgres`) manages local PostgreSQL server and databases. It wraps native tools like `pg_ctl`, `psql`, `vacuumdb`, providing a simplified server management experience.
99

10+
```bash
11+
pig pg - Manage local postgres server (pg_ctl, psql, vacuumdb)
12+
13+
Control Commands (via pg_ctl or systemctl):
14+
pig pg init initialize postgres data directory
15+
pig pg start start postgres server
16+
pig pg stop stop postgres server
17+
pig pg restart restart postgres server
18+
pig pg reload reload postgres server
19+
pig pg status show postgres server status
20+
pig pg promote promote replica to primary
21+
pig pg role detect and print postgres role
22+
23+
Connection & Query (via psql):
24+
pig pg psql [db] [-c sql] connect to postgres
25+
pig pg ps show current connections
26+
pig pg kill [-a] [-x] [-u user] [-d db] [-q sql] [-w secs]
27+
28+
Maintenance (via vacuumdb & pg_repack):
29+
pig pg vacuum [db] [-a] vacuum database
30+
pig pg analyze [db] [-a] analyze database
31+
pig pg freeze [db] [-a] vacuum freeze tables
32+
pig pg repack [db] [-a] online repack database
33+
34+
Log Commands:
35+
pig pg log list list log files
36+
pig pg log tail <logfile> tail -f log file
37+
pig pg log cat <logfile> cat log file
38+
pig pg log less <logfile> less log file
39+
pig pg log grep <logfile> <pat> grep log file
40+
41+
Service Management (via systemctl):
42+
pig pg svc start start postgres service
43+
pig pg svc stop stop postgres service
44+
pig pg svc restart restart postgres service
45+
pig pg svc reload reload postgres service
46+
pig pg svc status show postgres service status
47+
```
48+
1049
------
1150

1251
## Command Overview

content/pig/cmd/pg.zh.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,45 @@ weight: 640
77

88
`pig pg` 命令(别名 `pig postgres`)用于管理本地 PostgreSQL 服务器和数据库。它封装了 `pg_ctl``psql``vacuumdb` 等原生工具,提供简化的服务器管理体验。
99

10+
```bash
11+
pig pg - 管理本地 PostgreSQL 服务器(pg_ctl, psql, vacuumdb)
12+
13+
控制命令(通过 pg_ctl 或 systemctl):
14+
pig pg init 初始化 PostgreSQL 数据目录
15+
pig pg start 启动 PostgreSQL 服务器
16+
pig pg stop 停止 PostgreSQL 服务器
17+
pig pg restart 重启 PostgreSQL 服务器
18+
pig pg reload 重载 PostgreSQL 服务器配置
19+
pig pg status 显示 PostgreSQL 服务器状态
20+
pig pg promote 将备库提升为主库
21+
pig pg role 检测并打印 PostgreSQL 角色
22+
23+
连接与查询(通过 psql):
24+
pig pg psql [db] [-c sql] 连接到 PostgreSQL
25+
pig pg ps 显示当前连接
26+
pig pg kill [-a] [-x] [-u user] [-d db] [-q sql] [-w secs]
27+
28+
维护命令(通过 vacuumdb 和 pg_repack):
29+
pig pg vacuum [db] [-a] 清理数据库
30+
pig pg analyze [db] [-a] 分析数据库
31+
pig pg freeze [db] [-a] 冻结清理表
32+
pig pg repack [db] [-a] 在线重整数据库
33+
34+
日志命令:
35+
pig pg log list 列出日志文件
36+
pig pg log tail <logfile> tail -f 查看日志
37+
pig pg log cat <logfile> cat 查看日志
38+
pig pg log less <logfile> less 查看日志
39+
pig pg log grep <logfile> <pat> grep 搜索日志
40+
41+
服务管理(通过 systemctl):
42+
pig pg svc start 启动 postgres 服务
43+
pig pg svc stop 停止 postgres 服务
44+
pig pg svc restart 重启 postgres 服务
45+
pig pg svc reload 重载 postgres 服务
46+
pig pg svc status 显示 postgres 服务状态
47+
```
48+
1049
## 命令概览
1150

1251
**服务控制**(pg_ctl 封装):

content/pig/cmd/pitr.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,39 @@ weight: 680
77

88
The `pig pitr` command performs **Orchestrated Point-In-Time Recovery**. Unlike `pig pb restore`, this command automatically coordinates Patroni, PostgreSQL, and pgBackRest to complete the full PITR workflow.
99

10+
```bash
11+
pig pitr - Perform PITR with automatic Patroni/PostgreSQL lifecycle management.
12+
13+
This command orchestrates a complete PITR workflow:
14+
1. Stop Patroni service (if running)
15+
2. Ensure PostgreSQL is stopped (with retry and fallback)
16+
3. Execute pgbackrest restore
17+
4. Start PostgreSQL
18+
5. Provide post-restore guidance
19+
20+
Recovery Targets (at least one required):
21+
--default, -d Recover to end of WAL stream (latest)
22+
--immediate, -I Recover to backup consistency point
23+
--time, -t Recover to specific timestamp
24+
--name, -n Recover to named restore point
25+
--lsn, -l Recover to specific LSN
26+
--xid, -x Recover to specific transaction ID
27+
28+
Time Format:
29+
- Full: "2025-01-01 12:00:00+08"
30+
- Date only: "2025-01-01" (defaults to 00:00:00)
31+
- Time only: "12:00:00" (defaults to today)
32+
33+
Examples:
34+
pig pitr -d # Recover to latest (most common)
35+
pig pitr -t "2025-01-01 12:00" # Recover to specific time
36+
pig pitr -I # Recover to backup consistency point
37+
pig pitr -d --dry-run # Show execution plan without running
38+
pig pitr -d -y # Skip confirmation (for automation)
39+
pig pitr -d --skip-patroni # Skip Patroni management
40+
pig pitr -d --no-restart # Don't auto-start PostgreSQL after restore
41+
```
42+
1043

1144
## Overview
1245

content/pig/cmd/pitr.zh.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,39 @@ weight: 670
77

88
`pig pitr` 命令用于执行**编排式时间点恢复**(Orchestrated Point-In-Time Recovery)。与 `pig pb restore` 不同,此命令会自动协调 Patroni、PostgreSQL 和 pgBackRest,完成完整的 PITR 工作流。
99

10+
```bash
11+
pig pitr - 执行编排式 PITR(自动管理 Patroni/PostgreSQL 生命周期)
12+
13+
此命令编排完整的 PITR 工作流:
14+
1. 停止 Patroni 服务(如果正在运行)
15+
2. 确保 PostgreSQL 已停止(带重试和降级策略)
16+
3. 执行 pgbackrest restore
17+
4. 启动 PostgreSQL
18+
5. 提供恢复后操作指引
19+
20+
恢复目标(至少需要指定一个):
21+
--default, -d 恢复到 WAL 流末尾(最新数据)
22+
--immediate, -I 恢复到备份一致性点
23+
--time, -t 恢复到指定时间戳
24+
--name, -n 恢复到命名还原点
25+
--lsn, -l 恢复到指定 LSN
26+
--xid, -x 恢复到指定事务 ID
27+
28+
时间格式:
29+
- 完整格式: "2025-01-01 12:00:00+08"
30+
- 仅日期: "2025-01-01"(默认为 00:00:00)
31+
- 仅时间: "12:00:00"(默认为今天)
32+
33+
示例:
34+
pig pitr -d # 恢复到最新(最常用)
35+
pig pitr -t "2025-01-01 12:00" # 恢复到指定时间
36+
pig pitr -I # 恢复到备份一致性点
37+
pig pitr -d --dry-run # 仅显示执行计划
38+
pig pitr -d -y # 跳过确认(用于自动化)
39+
pig pitr -d --skip-patroni # 跳过 Patroni 管理
40+
pig pitr -d --no-restart # 恢复后不自动启动 PostgreSQL
41+
```
42+
1043

1144
## 命令概览
1245

content/pig/cmd/pt.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@ weight: 660
77

88
The `pig patroni` command (alias `pig pt`) manages Patroni service and PostgreSQL HA clusters. It wraps common `patronictl` and `systemctl` operations for simplified cluster management.
99

10+
```bash
11+
pig pt - Manage Patroni cluster using patronictl commands.
12+
13+
Cluster Operations (via patronictl):
14+
pig pt list list cluster members
15+
pig pt restart [member] restart PostgreSQL (rolling restart)
16+
pig pt reload reload PostgreSQL config
17+
pig pt reinit <member> reinitialize a member
18+
pig pt pause pause automatic failover
19+
pig pt resume resume automatic failover
20+
pig pt switchover perform planned switchover
21+
pig pt failover perform manual failover
22+
pig pt config <action> manage cluster config
23+
24+
Service Management (via systemctl):
25+
pig pt status show comprehensive patroni status
26+
pig pt start start patroni service (shortcut)
27+
pig pt stop stop patroni service (shortcut)
28+
pig pt svc start start patroni service
29+
pig pt svc stop stop patroni service
30+
pig pt svc restart restart patroni service
31+
pig pt svc status show patroni service status
32+
33+
Logs:
34+
pig pt log [-f] [-n 100] view patroni logs
35+
```
36+
1037
------
1138

1239
## Command Overview

content/pig/cmd/pt.zh.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@ weight: 650
77

88
`pig patroni` 命令(别名 `pig pt`)用于管理 Patroni 服务和 PostgreSQL HA 集群。它封装了常用的 `patronictl``systemctl` 操作,提供简化的集群管理体验。
99

10+
```bash
11+
pig pt - 使用 patronictl 命令管理 Patroni 集群
12+
13+
集群操作(通过 patronictl):
14+
pig pt list 列出集群成员
15+
pig pt restart [member] 重启 PostgreSQL(滚动重启)
16+
pig pt reload 重载 PostgreSQL 配置
17+
pig pt reinit <member> 重新初始化成员
18+
pig pt pause 暂停自动故障切换
19+
pig pt resume 恢复自动故障切换
20+
pig pt switchover 执行计划内主从切换
21+
pig pt failover 执行手动故障切换
22+
pig pt config <action> 管理集群配置
23+
24+
服务管理(通过 systemctl):
25+
pig pt status 显示 Patroni 综合状态
26+
pig pt start 启动 Patroni 服务(快捷方式)
27+
pig pt stop 停止 Patroni 服务(快捷方式)
28+
pig pt svc start 启动 Patroni 服务
29+
pig pt svc stop 停止 Patroni 服务
30+
pig pt svc restart 重启 Patroni 服务
31+
pig pt svc status 显示 Patroni 服务状态
32+
33+
日志:
34+
pig pt log [-f] [-n 100] 查看 Patroni 日志
35+
```
36+
1037

1138
## 命令概览
1239

content/pig/cmd/repo.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,37 @@ weight: 610
77

88
The `pig repo` command is a comprehensive tool for managing package repositories on Linux systems. It provides functionality to add, remove, create, and manage software repositories for both RPM-based (RHEL/CentOS/Rocky/Alma) and Debian-based (Debian/Ubuntu) distributions. This command is essential for setting up the required repositories to install PostgreSQL and its extensions.
99

10+
```bash
11+
pig repo - Manage Linux software repo (apt/dnf)
12+
13+
Usage: pig repo <command>
14+
15+
Commands:
16+
add Add new repository
17+
set Wipe and overwrite and update repository
18+
rm Remove repository
19+
list Print available repo and module list
20+
info Get repo detailed information
21+
status Show current repo status
22+
update Update repo cache
23+
create Create local YUM/APT repository
24+
cache Create offline package from local repo
25+
boot Bootstrap repo from offline package
26+
reload Refresh repo catalog
27+
28+
Flags:
29+
-h, --help help for repo
30+
31+
Global Flags:
32+
--debug enable debug mode
33+
-H, --home string pigsty home path
34+
-i, --inventory string config inventory path
35+
--log-level string log level: debug, info, warn, error, fatal, panic (default "info")
36+
--log-path string log file path, terminal by default
37+
38+
Use "pig repo [command] --help" for more information about a command.
39+
```
40+
1041
------
1142

1243
## Subcommands

0 commit comments

Comments
 (0)