This is the multi-page printable view of this section. .
PIG 1.8 Documentation
- 1: Getting Started
- 2: Introduction
- 3: Installation
- 4: Release
- 5: pig
- 6: pig repo
- 7: pig ext
- 8: pig build
- 9: pig sty
- 10: pig inventory
- 11: pig postgres
- 12: pig patroni
- 13: pig pgbackrest
- 14: pig pitr
— Postgres Install Genius, the missing extension package manager for the PostgreSQL ecosystem
PIG is a command-line tool specifically designed for installing, managing, and building PostgreSQL and its extensions. Developed in Go, it is ready to use out of the box, simple, and lightweight (about 5 MB).
PIG is not a reinvented wheel, but rather a PiggyBack - a high-level abstraction layer that leverages existing Linux distribution package managers (apt/dnf).
It abstracts away the differences between operating systems, chip architectures, and PG major versions, allowing you to install and manage PG kernels and 576 packaged extensions with just a few simple commands.
PIG is also automation-friendly by design: consistent parameter styles, clear error messages, preview switches like --plan, and confirmation steps.
Please note: for extension installation, pig is not a mandatory component. You can still use apt/dnf package managers to directly access the Pigsty PGSQL repository.
- Introduction: Why do we need a dedicated PG package manager?
- Getting Started: Quick start guide and examples
- Installation: Download, install, and update pig
Quick Start
Use the following command to install PIG on your system:
Default Installation (Cloudflare CDN):
China Mirror:
After installation, you can get started with just a few commands. For example, to install PG 18 and the pg_duckdb extension:
Command Reference
Run pig help <command> to get detailed help for subcommands.
Extension Management:
- pig repo: Manage software repositories
- pig ext: Manage PG extensions
- pig build: Build extensions from source
- pig install: Install PostgreSQL and extension packages through the native package manager
Pigsty Management:
- pig sty: Manage Pigsty installation and Grafana dashboards
- pig inventory: Inspect, edit, validate, and exchange the Pigsty inventory
- pig context: Collect host, PostgreSQL, Patroni, pgBackRest, and extension context
- pig pg: Manage local PostgreSQL server
- pig pt: Run patronictl transparently to manage Patroni HA clusters
- pig pb: Manage pgBackRest backup & restore
- pig pitr: Point-in-time recovery workflow
About
The pig CLI tool is developed by Vonng ([email protected]) and is open-sourced under the Apache 2.0 license.
You can also check out the PIGSTY project, which provides a complete PostgreSQL RDS DBaaS experience including extension delivery.
1 - Getting Started
Here is a simple getting started tutorial to help you experience the core capabilities of the PIG package manager.
Short Version
Installation
You can install pig with the following command:
Global (Cloudflare CDN):
China Mainland:
PIG binary is about 5 MB. On Linux it uses rpm or dpkg to install the latest version available on the selected mirror. In the example output below, X.Y.Z is that mirrored version:
Check Environment
PIG is a Go-written binary program, installed by default at /usr/bin/pig. pig version prints version information:
Use pig status to print the current environment status, OS code, PG installation status, repository accessibility and latency.
Automation Tips
For production recovery tasks, it is recommended to run --plan first to preview the PITR execution plan before actually executing:
List Extensions
Use the pig ext list command to print the built-in PG extension catalog.
All extension metadata is defined in a data file named extension.csv.
This file is updated with each pig release. You can update it directly using the pig ext reload command.
The updated file is placed in ~/.pig/extension.csv by default. You can view and modify it, and the latest online catalog is available at pigsty.io/ext/data/extension.csv.
Add Repositories
To install extensions, you first need to add upstream repositories. pig repo can be used to manage Linux APT/YUM/DNF software repository configuration.
You can use the straightforward pig repo set to overwrite existing repository configuration, ensuring only necessary repositories exist in the system:
Warning:
pig repo setwill back up and clear existing repository configuration, then add required repositories with overwrite semantics.
Or choose the gentler pig repo add to add needed repositories:
PIG detects your network environment and chooses Cloudflare global CDN or China cloud CDN, but you can force a specific region with --region.
In China network environments, -m|--mirror explicitly selects the bundled china repository definitions, including pigsty.cc and maintained domestic mirrors:
PIG does not support offline installation. You can download RPM/DEB packages yourself and copy them to isolated servers for installation. The related PIGSTY project provides local software repositories. You can use pig to install pre-downloaded extensions from local repos.
Install PG
After adding repositories, you can use pig ext add to install extensions (and related packages):
This uses the “alias translation” mechanism to map clean PG kernel/extension logical names into real RPM/DEB lists. If you do not need translation, use apt/dnf directly,
or use the -n|--no-translation option with the pig install variant:
Alias Translation
PostgreSQL kernels and extensions map to many RPM/DEB packages. Remembering them is painful, so pig provides common aliases to simplify installation.
For example, on EL systems the following aliases translate to the RPM lists on the right:
Note the $v placeholder is replaced by the PG major version. When you use the pgsql alias, $v becomes 18, 17, etc.
So when you install the pg18-server alias, EL actually installs postgresql18-server, postgresql18-libs, postgresql18-contrib, while Debian/Ubuntu installs postgresql-18. Pig handles all details.
Alias translation list for Debian/Ubuntu
These aliases can be instantiated with major versions, or you can use versioned aliases like pg18, pg17, and so on.
The actively supported PostgreSQL major versions are now 14-18. For example, for PostgreSQL 18 you can use:
pgsql | pg18 | pg17 | pg16 | pg15 | pg14 |
|---|---|---|---|---|---|
pgsql | pg18 | pg17 | pg16 | pg15 | pg14 |
pgsql-mini | pg18-mini | pg17-mini | pg16-mini | pg15-mini | pg14-mini |
pgsql-core | pg18-core | pg17-core | pg16-core | pg15-core | pg14-core |
pgsql-full | pg18-full | pg17-full | pg16-full | pg15-full | pg14-full |
pgsql-main | pg18-main | pg17-main | pg16-main | pg15-main | pg14-main |
pgsql-client | pg18-client | pg17-client | pg16-client | pg15-client | pg14-client |
pgsql-server | pg18-server | pg17-server | pg16-server | pg15-server | pg14-server |
pgsql-devel | pg18-devel | pg17-devel | pg16-devel | pg15-devel | pg14-devel |
pgsql-basic | pg18-basic | pg17-basic | pg16-basic | pg15-basic | pg14-basic |
Install Extensions
Pig detects your PostgreSQL installation. If there is an active PG installation (detected via pg_config in PATH), pig installs extensions for that PG major by default.
Tip: to add a specific PG major version into PATH, use pig ext link:
If you want a specific package version, use name=ver syntax:
Warning: currently only PGDG YUM repositories provide historical extension versions. PIGSTY repo and PGDG APT repo only provide the latest extension versions.
Show Extensions
pig ext status shows installed extensions.
If PostgreSQL cannot be found in your current PATH (via pg_config), it is recommended to explicitly specify PG major with -v|-p to avoid version detection ambiguity.
Scan Extensions
pig ext scan provides a lower-level scan. It scans shared libraries under the target PG directory to discover installed extensions:
Container Practice
You can create a new VM or use the following Docker container for testing. Create a d13 directory and a Dockerfile:
2 - Introduction
Have you ever struggled with installing or upgrading PostgreSQL extensions? Digging through outdated documentation, cryptic configuration scripts, or searching GitHub for forks and patches? Postgres’s rich extension ecosystem also means complex deployment processes, especially across multiple distributions and architectures. PIG can solve these headaches for you.
This is exactly why Pig was created. Developed in Go, Pig is dedicated to one-stop management of Postgres and its 576 packaged extensions. Whether it’s TimescaleDB, Citus, PGVector, 30+ Rust extensions, or all the components needed to self-host Supabase, Pig’s unified CLI makes everything accessible. It completely eliminates source compilation and messy repositories, directly providing version-aligned RPM/DEB packages that perfectly support Debian, Ubuntu, RedHat, and other mainstream distributions on both x86 and Arm architectures, no guessing, no hassle.
Pig isn’t reinventing the wheel; it fully leverages native system package managers (APT, YUM, DNF) and strictly follows PGDG official packaging standards for seamless integration.
You do not need to choose between “the standard way” and “shortcuts”. Pig respects existing repositories, follows OS best practices, and coexists harmoniously with existing repositories and packages.
If your Linux system and PostgreSQL major version are not in the supported list, you can use pig build to compile extensions for your specific combination.
Want to supercharge your Postgres and escape the hassle? Visit the PIG official documentation for guides, and check out the extensive extension list, turning your local Postgres database into an all-capable multi-modal data platform with one click. If Postgres’s future is unmatched extensibility, then Pig is the magic lamp that helps you unlock it. After all, no one ever complains about “too many extensions”.
Automation-Friendly
PIG’s command system is automation-ready out of the box: consistent argument conventions, stable output behavior, --plan previews, and confirmation flows for high-risk operations to reduce mistakes.
Linux Compatibility
PIG and the Pigsty extension repository support the following Linux distribution and PostgreSQL version combinations:
| OS Code | Vendor | Major | Minor | Full Name | PG Versions | Notes |
|---|---|---|---|---|---|---|
el7.x86_64 | EL | 7 | 7.9 | CentOS 7 x86 | 13-15 | EOL |
el8.x86_64 | EL | 8 | 8.10 | RockyLinux 8 x86 | 14-18 | Near EOL |
el8.aarch64 | EL | 8 | 8.10 | RockyLinux 8 ARM | 14-18 | Near EOL |
el9.x86_64 | EL | 9 | 9.7 | RockyLinux 9 x86 | 14-18 | ✅ |
el9.aarch64 | EL | 9 | 9.7 | RockyLinux 9 ARM | 14-18 | ✅ |
el10.x86_64 | EL | 10 | 10.1 | RockyLinux 10 x86 | 14-18 | ✅ |
el10.aarch64 | EL | 10 | 10.1 | RockyLinux 10 ARM | 14-18 | ✅ |
d11.x86_64 | Debian | 11 | 11.11 | Debian 11 x86 | 14-18 | EOL |
d11.aarch64 | Debian | 11 | 11.11 | Debian 11 ARM | 14-18 | EOL |
d12.x86_64 | Debian | 12 | 12.14 | Debian 12 x86 | 14-18 | ✅ |
d12.aarch64 | Debian | 12 | 12.14 | Debian 12 ARM | 14-18 | ✅ |
d13.x86_64 | Debian | 13 | 13.6 | Debian 13 x86 | 14-18 | ✅ |
d13.aarch64 | Debian | 13 | 13.6 | Debian 13 ARM | 14-18 | ✅ |
u22.x86_64 | Ubuntu | 22 | 22.04.5 | Ubuntu 22.04 x86 | 14-18 | ✅ |
u22.aarch64 | Ubuntu | 22 | 22.04.5 | Ubuntu 22.04 ARM | 14-18 | ✅ |
u24.x86_64 | Ubuntu | 24 | 24.04.4 | Ubuntu 24.04 x86 | 14-18 | ✅ |
u24.aarch64 | Ubuntu | 24 | 24.04.4 | Ubuntu 24.04 ARM | 14-18 | ✅ |
u26.x86_64 | Ubuntu | 26 | 26.04.0 | Ubuntu 26.04 x86 | 14-18 | ✅ |
u26.aarch64 | Ubuntu | 26 | 26.04.0 | Ubuntu 26.04 ARM | 14-18 | ✅ |
Notes:
- EL refers to RHEL-compatible distributions, including RHEL, CentOS, RockyLinux, AlmaLinux, OracleLinux, etc.
- EOL indicates the operating system has reached or is about to reach end of support; upgrading to a newer version is recommended
- ✅ indicates full support; recommended for use
- PG versions 14-18 means support for PostgreSQL 14, 15, 16, 17, and 18 major versions
3 - Installation
Script Installation
The simplest way to install pig is to run the following installation script:
Default Installation (Cloudflare CDN):
China Mirror:
This script downloads the latest pig RPM/DEB package from the Pigsty software repository and installs it using rpm or dpkg.
Script installation targets Linux x86_64 / aarch64 RPM or DEB distributions. On macOS, use the binary from the release tarball.
Specify Version
You can request a particular version that is already published on the selected mirror by passing the version number as an argument:
Default Installation (Cloudflare CDN):
China Mirror:
Mirror publication can lag the GitHub release. For the exact current release, use the GitHub artifacts below.
Download Release Artifacts
Current v1.8.0 installation packages (RPM/DEB/tarball) are available from the GitHub Release, with published hashes in checksums.txt. Use the following direct URL pattern:
https://github.com/pgsty/pig/releases/download/v1.8.0/<filename>
After extracting, place the binary file in your system PATH. The equivalent Pigsty mirror directory becomes available after repository synchronization; check the target URL before using a version-pinned installer command.
Repository Installation
The pig software is located in the pigsty-infra repository. You can add this repository to your operating system and then install using the OS package manager:
YUM
For RHEL, RockyLinux, CentOS, Alma Linux, OracleLinux, and other EL distributions:
APT
For Debian, Ubuntu, and other DEB distributions:
Update
To upgrade an existing pig version to the latest available version, use the following command:
To update the extension data of an existing pig to the latest available version, use the following command:
Uninstall
Build from Source
You can also build pig yourself. pig is developed in Go and is very easy to build. The source code is hosted at github.com/pgsty/pig
All RPM/DEB packages are automatically built through GitHub CI/CD workflow using goreleaser.
4 - Release
The latest stable version is v1.8.0.
| Version | Date | Summary | GitHub |
|---|---|---|---|
| v1.8.0 | 2026-08-14 | Native sty boot and sty conf, 575 packaged extensions | v1.8.0 |
| v1.7.0 | 2026-08-12 | EL module policy, China mirrors, EL7 compatibility, 575 extensions | v1.7.0 |
| v1.6.2 | 2026-08-11 | 572 extensions, Grafana schema v2, SOW-first repository generation | v1.6.2 |
| v1.6.1 | 2026-07-30 | Catalog refresh and embedded Pigsty 4.5.0 | v1.6.1 |
| v1.6.0 | 2026-07-28 | 562 packaged extensions, patronictl passthrough, inventory & CMDB, Grafana | v1.6.0 |
| v1.5.1 | 2026-07-08 | PG kernel fork updates, mirror mode, bug fixes | v1.5.1 |
| v1.5.0 | 2026-07-04 | 531 extensions, pigsty v4.4, pg/pt/pb/pitr rework, clone & fork | v1.5.0 |
| v1.4.2 | 2026-06-18 | 524 extensions, PG19 beta, pgrx 0.18.1, Patroni fixes | v1.4.2 |
| v1.4.1 | 2026-05-01 | 510 extensions, Ubuntu 26.04 support, repo calibration | v1.4.1 |
| v1.4.0 | 2026-04-19 | 510 extensions, pgrx 0.18.0, more building specs | v1.4.0 |
| v1.3.4 | 2026-04-14 | 504 extensions refreshed, release checksums updated | v1.3.4 |
| v1.3.3 | 2026-04-10 | 481 extensions and Go 1.26.2 update | v1.3.3 |
| v1.3.2 | 2026-03-23 | Routine metadata refresh, new pg tune, new build aliases | v1.3.2 |
| v1.3.1 | 2026-03-05 | Retire PG13 defaults, unify PG14-18 support window, 464 extensions | v1.3.1 |
| v1.3.0 | 2026-02-27 | Build pipeline hardening, 461 extensions, new pgedge/ivory support | v1.3.0 |
| v1.2.0 | 2026-02-23 | Unified aliases, routine updates, plan mode, repo fixes | v1.2.0 |
| v1.1.0 | 2026-02-12 | 451 extensions, Agent-Native CLI framework | v1.1.0 |
| v1.0.0 | 2026-01-26 | New pg/pt/pb/pitr commands, availability matrix | v1.0.0 |
| v0.8.0 | 2025-12-26 | 440 extensions, remove sysupdate repo | v0.8.0 |
| v0.7.5 | 2025-12-12 | Routine extension update, fixed aliyun mirror | v0.7.5 |
| v0.7.4 | 2025-12-01 | Update ivory/pgtde kernel and pgdg extras | v0.7.4 |
| v0.7.3 | 2025-11-24 | Fix repo for el10 & debian13 | v0.7.3 |
| v0.7.2 | 2025-11-20 | 437 extensions, fix pig build issue | v0.7.2 |
| v0.7.1 | 2025-11-10 | New Website, improve in-docker experience | v0.7.1 |
| v0.7.0 | 2025-11-05 | Build Enhancement and massive upgrade | v0.7.0 |
| v0.6.2 | 2025-10-03 | PG 18 official Repo | v0.6.2 |
| v0.6.1 | 2025-08-14 | CI/CD, el10 stub, PGDG CN Mirror | v0.6.1 |
| v0.6.0 | 2025-07-17 | 423 extension, percona pg_tde, mcp toolbox | v0.6.0 |
| v0.5.0 | 2025-06-30 | 422 extension, new extension catalog | v0.5.0 |
| v0.4.2 | 2025-05-27 | 421 extension, halo & oriole deb | v0.4.2 |
| v0.4.1 | 2025-05-07 | 414 extension, pg18 alias support | v0.4.1 |
| v0.4.0 | 2025-05-01 | do & pt sub-cmd, halo & orioledb | v0.4.0 |
| v0.3.4 | 2025-04-05 | routine update | v0.3.4 |
| v0.3.3 | 2025-03-25 | alias, repo, deps | v0.3.3 |
| v0.3.2 | 2025-03-21 | new extensions | v0.3.2 |
| v0.3.1 | 2025-03-19 | minor bug fix | v0.3.1 |
| v0.3.0 | 2025-02-24 | new home page and extension catalog | v0.3.0 |
| v0.2.2 | 2025-02-22 | 404 extensions | v0.2.2 |
| v0.2.0 | 2025-02-14 | 400 extensions | v0.2.0 |
| v0.1.4 | 2025-02-12 | routine bugfix | v0.1.4 |
| v0.1.3 | 2025-01-23 | 390 extensions | v0.1.3 |
| v0.1.2 | 2025-01-12 | the anon extension and 350 other ext | v0.1.2 |
| v0.1.1 | 2025-01-09 | Update Extension List | v0.1.1 |
| v0.1.0 | 2024-12-29 | repo, ext, sty, and self-update | v0.1.0 |
| v0.0.1 | 2024-12-23 | Genesis Release | v0.0.1 |
v1.8.0
Pig v1.8.0 is a native controller-workflow update on top of v1.7.0.
pig sty boot and pig sty conf are now implemented in Go instead of wrapping the legacy
bootstrap and configure shell scripts. The packaged PostgreSQL extension count remains
575, and the embedded Pigsty version remains 4.5.0.
Highlights
pig sty bootcan elevate once through sudo, verifies Ansible and its actual Python runtime, and supports explicit local packages, HTTP(S) URLs, trusted automatic offline packages, committed local repositories, and regional online repositories. Repository replacement is backed up and rolled back on failure; localhost SSH and a missing~/pigstyare repaired on a best-effort basis.pig sty confnow generates Inventory natively from safe templates, with up to ten IP mappings, exact domain replacement, region and proxy settings, PostgreSQL-version selection, and random credentials. The complete candidate is validated and atomically written with mode0600.- Bootstrap download and extraction no longer require
curl,wget,tar, orgzip; offline operation is restricted topigsty-local, with the expected/www -> /data/nginxlayout. - EL8 and newer consistently prefer DNF, local RPM requirements are resolved by provider
capability, extension metadata and availability matrices receive their routine refresh, and
the release toolchain moves to Go
1.26.6.
Compatibility Notes
pig sty bootno longer executes<PIGSTY_HOME>/bootstrap; automation that relied on script side effects must migrate to the native command.pig sty conf --rawhas been removed;--conf MODEand positionalMODEare equivalent.--ipaccepts up to ten addresses and remains mutually exclusive with--skip.- EL8 and newer use DNF. The limited EL7 compatibility catalog keeps its separate legacy YUM path.
Checksums
Artifacts: GitHub Release · checksums.txt
Release: https://github.com/pgsty/pig/releases/tag/v1.8.0
v1.7.0
Pig v1.7.0 is a repository compatibility and catalog release on top of v1.6.2. It makes China-mirror selection explicit, preserves native DNF module filtering by default, restores a streamlined EL7 repository catalog, and grows the bundled extension snapshot from 572 to 575. The embedded Pigsty version remains 4.5.0.
Highlights
-m|--mirrornow selects the bundledchinarepository definitions directly. PGDG, Rocky Linux, Debian, Ubuntu, Docker, and other regional routes use the maintained mirror list instead of the former runtime PGDG proxy rewrite.- EL repository definitions no longer receive
module_hotfixes=1globally. Pigsty and PGDG repositories that intentionally override module streams opt in explicitly; BaseOS, AppStream, EPEL, and other repositories retain native DNF module filtering. - EL7 keeps a deliberately limited compatibility catalog: archived CentOS 7 Base/Updates/Extras/SCLo and EPEL definitions for
x86_64, plus shared Pigsty and supported PGDG entries. The DNF-onlymodule_hotfixeskey is stripped when rendering EL7 YUM configuration. - Repository setup now reports unsupported platforms when the catalog has no matching definitions, instead of continuing with an empty repository set.
Extension Catalog
- Packaged extensions: 572 -> 575, with no removals.
- Add
pg_local_cache 1.2.0,pg_statviz 0.1.0, andpg_policy 0.1.0. - Refresh
biscuit 3.0.0,pg_clickhouse 0.10.0,pg_search 0.25.2,pg_turbovecpackages1.29.0,pg_uuid_v8 1.1.0, and the Debianq3c 2.0.5package.
Compatibility Notes
- No commands or global flags are removed in this release.
-m|--mirroris now an explicit China-region selection rather than a PGDG proxy rewrite. Use--region=default|china|europewhen you need a specific route.- Custom EL repository definitions that require module-stream overrides must set
meta.module_hotfixes: 1explicitly. This setting is intentionally omitted for ordinary OS repositories and removed on EL7. - EL7 is end-of-life and only has limited compatibility coverage; prefer EL8 or newer for current PostgreSQL and extension packages.
Checksums
Artifacts: GitHub Release · checksums.txt
Release: https://github.com/pgsty/pig/releases/tag/v1.7.0
v1.6.2
Pig v1.6.2 is a feature and catalog release on top of v1.6.1. It grows the packaged extension catalog from 562 to 572, adds native Grafana dashboard schema v2 support, and improves local repository generation. The embedded Pigsty version remains locked at 4.5.0.
Highlights
pig sty grafananow accepts both legacy dashboard JSON and nativedashboard.grafana.app/v2Dashboard resources. Loading a v2 dashboard uses Grafana’s resource API so tabs and section variables survive the round trip; dumping preserves an existing v2 destination while new dumps keep the legacy format by default.pig repo createnow preferssow create --pigsty --timeout 10m -- <dir>when SOW is available, requires the resultingrepo_completemarker to exist as a regular file, and falls back tocreaterepo_c/dpkg-scanpackageson Linux.- Local repository creation now works on macOS through SOW, defaults to the current directory there, and does not require
sudo. The Linux default remains/www/pigsty. - Release metadata is bumped to
1.6.2; the embedded Pigsty version stays at4.5.0.
Extension Catalog
- Packaged extensions: 562 -> 572, with no removals.
- 10 new extensions:
pg_turbovec,pg_disorder,pg_mentat,plruby,jsonb_plruby,hstore_plruby,ltree_plruby,pg_describe,cat_tools, andpg_vault_tde. - 12 version refreshes:
timescaledb 2.29.1,q3c 2.0.5,pgmnemo 0.16.1,pg_search 0.25.1,citus 14.2.0,citus_columnar 14.2.0,provsql 1.12.0,plpgsql_check 2.10.4,pg_rational 0.0.3,pgbson 2.1.0,pg_readme 0.7.1, andpg_readme_test_extension 0.7.1. - Package metadata and availability matrices are refreshed. Run
pig ext reloadto replace the embedded release snapshot with the latest online catalog.
Compatibility Notes
- No commands or global flags are removed in this release.
- When SOW is installed,
pig repo createnow prefers it over the legacy Linux generators and checks that the completion marker exists before reporting success. - The catalog count is not a promise that every package is available on every PostgreSQL / OS / architecture combination; use
pig ext avail NAMEon the target host.
Checksums
Artifacts: GitHub Release · checksums.txt
Release: https://github.com/pgsty/pig/releases/tag/v1.6.2
v1.6.1
Pig v1.6.1 is a maintenance release that refreshes the bundled extension catalog and aligns the embedded Pigsty version with 4.5.0. It introduces no new commands or flag changes.
Highlights
- Regenerate the embedded
extension.csvfrom the Pigsty package repositories so fresh installs resolve against current package metadata without first runningpig ext reload. - Update the embedded Pigsty version reported by
pig styandpig statusfrom4.4.0to4.5.0. - Keep 562 packaged extensions across PostgreSQL 14-18, EL 8/9/10, Debian 12/13, and Ubuntu 22/24/26 on
x86_64andaarch64.
Checksums
Artifacts: Pigsty Mirror · checksums.txt
Release: https://github.com/pgsty/pig/releases/tag/v1.6.1
v1.6.0
Pig v1.6.0 is a major release: pig pt becomes a transparent patronictl launcher, the new root-level pig inventory command group brings lossless editing and validation of pigsty.yml (with an experimental PostgreSQL CMDB bridge), pig sty grafana adds native Grafana dashboard management, and the packaged extension catalog grows to 562.
Highlights
pig ptis rewritten as a nativepatronictlpassthrough: all cluster commands (list,restart,switchover,failover,edit-config, …) forward directly with native flags, prompts, output, and exit codes, so new patronictl features work without waiting for a pig release. Local helpersstatus,log,set, andservice/svcremain, with new-c/--config-file,-d/--dcs-url,-k/--insecureoptions and apig pt -- …escape hatch.- New root-level
pig inventorycommand group (aliasinv):status/list/show/edit/validate/check/diff— a lossless YAML engine that preserves comments, formatting, key order, and anchors byte-for-byte;editvalidates before writing and writes atomically, so invalid YAML can never reach disk. - New experimental
pig inventory cmdbsubcommands (check/init/load/dump/enable/disable) exchange the inventory with the Pigsty CMDB in PostgreSQL over a native driver, with bounded timeouts and digest-pinned confirmation for destructive operations. - New
pig sty grafana(aliasgf) manages Grafana dashboards natively over HTTP:info/list/boot/load/init/dump/clean/lang/style. Thepig stysurface is simplified:sty edit/validate/check/cmdb/dashboard/releaseare removed in favor ofpig inventory,pig sty grafana, andpig sty list/get. - Reliability hardening: repo / catalog / download writes are atomic (no more truncated files on interrupt); structured
-o json|yamlkeeps stdout as a pure result envelope with wrapped-tool output on stderr; finer exit codes (usage errors → 2, missing--yesconfirmation → 7); Ansible list variables are JSON-encoded. - Repository refresh: MySQL repos upgraded to 8.4 LTS, new Percona XtraBackup (
pxb84) and MySQL Tools repos, Kubernetes v1.36, LLVM apt coverage for Debian/Ubuntu 26, Percona TDE sourced directly from repo.percona.com,wiltondbrepo removed. - Toolchain: Go 1.26.5, new native PostgreSQL driver (pgx v5), embedded Pigsty version
4.4.0.
Extension Catalog
- Packaged extensions: 531 -> 562; the broader PGEXT.CLOUD directory contains 2,230 entries.
- 33 new extensions, including the
pg_lakefamily (pg_lake,pg_lake_table,pg_lake_engine,pg_lake_iceberg,pg_lake_copy),pg_jieba,pg_cjk_parser,pg_fts,pgmonitor,pgmemento,pg_tiktoken_c,online_advisor,pgsqlmock, andplx. - 2 removed:
pg_analytics,spat; 58 version refreshes, includingvector 0.8.5,timescaledb 2.28.3,pg_search 0.24.3,pg_tde 2.2.1, andpowa 5.2.0. - Package aliases synced with Pigsty:
kafkais renamed tokafka-stack; the Debian/Ubuntupostgresqlalias now maps topostgresql-$vonly (usepgsql/pgsql-fullfor the full dev set).
Compatibility Notes
- ⚠
pig pt failover <name>: the positional argument is now the cluster, not the promotion candidate — usepig pt failover CLUSTER --candidate MEMBERand review any failover automation before upgrading. pig ptpositionals are native cluster-first (restart CLUSTER [MEMBER]); forwarded commands return native patronictl exit codes, own their confirmation prompts (-yno longer gates them), and no longer support-o json(use native--format json).pig pt configis replaced bypig pt set K=Vand nativeshow-config/edit-config.- In structured output mode, wrapped-tool output moves to stderr and stdout carries only the JSON/YAML envelope — update scripts that parsed mixed output.
pig inventory edittightens the inventory file mode to 0600 after a successful edit, since the file may contain credentials.
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.6.0
v1.5.1
Pig v1.5.1 updates PG kernel forks to the latest package names.
Highlights
- Add mirror/proxy mode to repo, build, sty, update, and extension update workflows;
pig build rust -malso configures Cargo mirror settings withrsproxy.cn. - Add explicit PostgreSQL 19 beta build switches:
pig build repo --beta,pig build tool --beta, andpig build pgrx -b, while keeping PostgreSQL 18 and PG14-18 as the stable defaults. - Refresh kernel and fork package aliases for IvorySQL, PolarDB, OrioleDB, OpenHaloDB, Babelfish, and the pgEdge suite.
- Improve the Cloudberry package build flow for
cloudberry,cloudberry-backup, andcloudberry-pxf. - Refresh source/package metadata for Cloudberry, Babelfish, OrioleDB, pgEdge, PolarDB,
polarstore,zlog,libpgfeutils, andlibfq. - Improve repository generation for newer EL release strings, including PGDG on EL9.6+ / EL10+ and EPEL’s EL10
10zstream. - Refresh extension versions including
pg_ivm 1.15,spock 5.0.10,snowflake 2.5.0,pg_tde 2.2,decoderbufs 3.6.0, and IvorySQL5.4packages.
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.5.1
v1.5.0
Pig v1.5.0 is a PostgreSQL operations release for day-to-day DBA work. It adds local database clone/fork workflows, clarifies the boundaries between pg, pt, pb, and pitr, and tightens preview, confirmation, and structured-output behavior for high-risk operations.
Highlights
pig pgis now more focused on local PostgreSQL operations.pig pg clonecreates quick database-level copies, whilepig pg forkcreates disposable physical instance forks for local validation, recovery drills, and isolated experiments.- Recovery flows are split more clearly:
pig pitris the orchestration entry point across Patroni, PostgreSQL, and pgBackRest;pig pb restoreremains the low-level pgBackRest restore primitive. Restore commands now require an explicit target and provide more concrete plans and post-restore guidance. - Patroni operations are more predictable: high-risk actions such as
pig pt restart,reinit,switchover, andfailoveruse Pig-managed confirmation and plan output;pig pt config pgpoints operators topig pt restart --pendingwhen a restart is required. - Automation is safer: structured output no longer implies confirmation for destructive commands. High-risk execution requires explicit
-y/--yes, while--planandnext_actionsare more consistent for preview-then-execute workflows. - Logs and status output are more useful during incidents:
pg,pb, andptlog commands now cover common latest / tail / show / grep workflows, and structured log snapshots use JSONL semantics. - Build and release defaults were refreshed: Pig is
1.5.0, embedded Pigsty is4.4.0, andpig build pgrxdefaults tocargo-pgrx 0.19.1.
Extension Catalog
- Available extensions: 524 -> 531, with no removals.
- New extensions:
pg_ducklake,pgdisablelogerror,pg_stat_log,pg_stat_plans,passwordpolicy,db2fce,plpgsql_wrap. - Refreshed a batch of existing extension versions and package metadata, including
timescaledb 2.28.2,postgis 3.6.4,vector 0.8.4,biscuit 2.4.1,citus 14.1.0,orioledb 1.8,documentdb 0.113,credcheck 5.0, andpgtt 4.5. orioledbaliases no longer pin to PG17; they resolve against the requested PostgreSQL major. EL9 ARM64 Patroni aliases now point to noarch packages.
Compatibility Notes
- Use
-y/--yesfor destructive operations in automation; structured output mode no longer substitutes for human confirmation. pig pb restoreandpig pitrrequire exactly one explicit recovery target; use--target-action=promotefor auto-promote behavior.- Several ambiguous short options were cleaned up. For log commands,
-o jsonmeans a JSONL snapshot and is not used for tail/follow streaming modes.
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.5.0
v1.4.2
- Refresh the built-in extension catalog from 510 to 524 available extensions. This adds 14 extensions:
pg_stl,pgmnemo,psql_bm25s,pg_orca,pg_sorted_heap,graph,pgrdf,fsm_core,jsonschema,pg_durable,pg_mockable,pg_uuid_v8,pg_stat_backtrace, andpg_projection. - Update package metadata for 48 existing extensions, including
timescaledb 2.28.0,timescaledb_toolkit 1.23.0,pg_task 2.1.29,pg_search 0.24.0,pg_clickhouse 0.3.2,pg_graphql 1.6.1,documentdb 0.112,toastinfo 1.7,wrappers 0.6.1, andpgclone 4.3.2. No extensions were removed or demoted. - Add PostgreSQL 19 beta install/build/config support. PG19 is accepted as an explicit installable major, while PostgreSQL 18 remains the stable default for auto-detection, catalog display, and latest-version aliases.
- Add
pg19package aliases and PG19 category alias resolution. PG19 category aliases borrow the PostgreSQL 18 visibility template and limit beta package expansion to PGDG-origin entries. - Teach
pig sty conf -v 19to enable thebetarepository module when the template supports it, and emit clear warnings when a template is not tuned for PG19 beta or cannot enable the beta repo automatically. - Fix Patroni cluster operations by passing the resolved
CLUSTER_NAMEtopatronictl restart,reinit,switchover, andfailover;pig pt listalso accepts an optional cluster name. - Bump the default
pgrxversion forpig build pgrxfrom0.18.0to0.18.1. - Bump release metadata to
v1.4.2, refresh Go module checksums, and add focused tests for PG19 aliases/config generation plus Patroni cluster-scope behavior.
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.4.2
v1.4.1
- 510 extensions, 3 new extensions, 20 updated.
- Ubuntu 26.04
resolutesupport, drop support for Ubuntu 20.04focal. - Bump
el9.aarch64ad hocpatronito4.1.2. - Bump pgEdge to PostgreSQL 18.
- Calibrate upstream repo definition.
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.4.1
v1.4.0
- Refresh the extension catalog and increase the total available extensions to 510, with version bumps such as
timescaledb 2.26.3,decoderbufs 3.5.0,pgclone 4.0.0, andnominatim_fdw 1.3. - Bump the default
pgrxversion from0.17.0to0.18.0and align related Rust extension builds. - Refresh authoritative source bundles for
pig build get, covering Cloudberry / OrioleDB build inputs and bundled artifacts for RDKit and OneSparse-related packages. - Fix
repo setflag isolation and correct schema maintenance SQL. - Bump
patronito4.1.1forel9.aarch64.
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.4.0
v1.3.4
Bump total available extensions to 504.
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.3.4
v1.3.3
- Refresh extension catalog and increase total available extensions to 481.
- Bump Go toolchain from
1.26.0to1.26.2.
Extension Updates
| Extension | Old | New | Notes |
|---|---|---|---|
timescaledb | 2.25.2 | 2.26.2 | available, PG15-18 |
pg_background | 1.8 | 1.9.2 | DEB only, PG14-18 |
pg_ivm | 1.13 | 1.14 | upgraded, PG14-18 |
system_stats | 3.2 | 4.0 | upgraded, PG14-18 |
nominatim_fdw | 1.1.0 | 1.2 | upgraded, PG14-18 |
pg_textsearch | 0.5.0 | 1.0.0 | PG17-18 |
pg_clickhouse | 0.1.5 | 0.1.10 | available, PG14-18 |
pg_search | 0.22.2 | 0.22.6 | manual download, PG15-18 |
pg_store_plans | 1.9 | 1.10 | upgraded, PG14-18 |
pg_dispatch | 0.1.5 | new, PG14-18 | |
pg_fsql | 1.1.0 | new, PG14-18 | |
pg_liquid | 0.1.7 | new, PG14-18 | |
pg_regresql | 2.0.0 | new, PG14-18 | |
pg_slug_gen | 1.0.0 | new, PG15-18 | |
pg_stat_ch | 0.3.3 | new, PG16-18 | |
pg_variables | 1.2.5 | new, PG14-18 | |
pgcalendar | 1.1.0 | new, PG14-18 | |
pgclone | 2.2.0 | new, PG14-18 | |
pgelog | 1.0.2 | new, PG14-18 | |
pglock | 1.0.0 | new, PG14-18 | |
pgproto | 0.2.1 | new, PG14-18 | |
postgresbson | 2.0.2 | new, PG14-18 | |
rdf_fdw | 2.4.0 | new, PG14-18 | |
parray_gin | 1.4.0 | new, PG14-18 |
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.3.3
v1.3.2
Routine maintenance release.
- Refresh a batch of extension version metadata and catalog entries.
- Add the
pig pg tunesubcommand to generate PostgreSQL tuning parameters from hardware resources and workload profiles. - Add
pduandpgdogsource package aliases forpig build get. - Migrate extension catalog URLs from
pgext.cloudtopigsty.io/ext.
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.3.2
v1.3.1
This is a small maintenance release from v1.3.0 to v1.3.1.
- PG13 install/build support is removed because PGDG upstream has dropped PG13 archive/distribution.
- Active supported PostgreSQL major versions are now 14-18.
- Refresh extension catalog (
461 -> 464), includingpg_pinyin,pg_eviltransform, andqos. - Percona PPG upstream repo is bumped to
18.3. - Fix
pig builddependency/build sync issues; rsync now uses--keep-dirlinks. - In YUM repos, Nginx is split out from
infrainto its own module index (nginx).
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.3.1
v1.3.0
This release is a focused engineering update from v1.2.0 to v1.3.0: 15 commits, 74 files changed, +1184 / -236 LOC.
It hardens the pig build pipeline and extends catalog/alias coverage, increasing total extensions from 451 to 461.
Highlights
- Build source download improvements (
pig build get):- Parse multi-source
Sourcefields (whitespace/newline/tab) and deduplicate entries. - Add source mappings for
agensgraph/agentsgraph. pgedgenow downloads bothpostgresql-17.9.tar.gzandspock-5.0.5.tar.gz.
- Parse multi-source
- Dependency resolution and install improvements (
pig build dep):- RPM dependencies can infer PG major from
pgmajorversionin spec files; missing spec/control files now return explicit errors. - DEB dependency parsing now covers
Build-Depends/Build-Depends-Arch/Build-Depends-Indep, including multiline fields, alternatives, arch qualifiers, and build-profile cleanup. PGVERSIONplaceholders can be expanded from--pg, installed PG majors, or extension metadata.- Dependency install failures are downgraded to warnings so batch runs continue.
- RPM dependencies can infer PG major from
- DEB build result semantics fixed (
pig build ext/pkg):- Successful build command exit code is authoritative; artifact discovery is best-effort warning only.
- Suppress empty package-list banners on successful no-artifact runs.
- Partial artifacts are warnings, not failures.
- Build logs now print real metadata source/version values instead of always composing
name-version.
- Better machine-readable ext operation output (
pig ext rm/update):- After alias resolution,
removed/updatednow returns resolved package names instead of extension aliases.
- After alias resolution,
- Extension catalog and alias updates:
- New aliases:
agensgraph/agens,pgedge,babelfishpg. openhalodbis aligned to PG14 package naming;ivorysqldbnaming is aligned.- Fork metadata and availability matrix were refreshed in batch (including
timescaledb,pgmq,orioledb,documentdb,pg_tde, andbabelfishpg_*entries).
- New aliases:
- Engineering and release:
- Version bumped to
v1.3.0(including av1.2.1transition commit), copyright year moved to 2026, and README refreshed for 461 extensions and current alias docs.
- Version bumped to
Compatibility Notes
- Structured
removed/updatedfields inpig ext rm/updatenow contain package names. Automation that matched extension aliases should update parsing logic.
New Extensions (451 -> 461)
| Extension | Version | Notes |
|---|---|---|
aux_mysql | 1.5 | openHalo MySQL compatibility helper (PG14) |
gb18030_2022 | 1.0 | IvorySQL charset conversion module |
ivorysql_ora | 1.0 | IvorySQL Oracle compatibility extension |
ora_btree_gin | 1.0 | Oracle datatype GIN indexing support |
ora_btree_gist | 1.0 | Oracle datatype GiST indexing support |
pg_get_functiondef | 1.0 | Function definition utility |
plisql | 1.0 | PL/iSQL procedural language |
snowflake | 2.4 | pgEdge Snowflake-style ID generator |
spock | 5.0.5 | pgEdge multi-master logical replication extension |
lolor | 1.2.2 | pgEdge logical-replication-friendly large objects |
Full Commit List (v1.2.0..v1.3.0)
b8ecf8dbump version string to 1.2.155df9a4build/get: support multi-source parsing and pgedge spock tarballda8e347add agensgraph and pgedge alias86edbd7ext: show resolved package names in rm/update resultsef3c905build/dep: improve rpm/deb dependency resolution7144e09ext/catalog: refresh fork metadata and matrix entriesbefffbfbuild(deb): treat successful build command as authoritative result33fd517build(deb): avoid empty package list banner on successful no-artifact runs3b450f2avoid concat ext pkg name with version when download33847abfix(ext): satisfy staticcheck S1011 in rm/updateb8b917dbuild(dep): treat dependency install failures as warnings8110c00adjust ivorysqldb babelfishpg aliasfac9fafbump version to 1.3.01f88f06chore: update copyright year to 2026c804757v1.3.0
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.3.0
v1.2.0
Extension catalog and alias resolution enhancements:
- Introduce dynamic PG category alias resolution by PG major version.
- Add OS-level alias overrides (
ansible/bootstrap) and converge unknown distro fallback to PGDG-only. - Add aliases such as
node/infraandbabelfish/cloudberry, and refresh extension metadata to reduce package resolution ambiguity.
Plan preview for high-risk operations:
- Add
pig install --planwith structured execution plan output. - Align preview semantics for
pig pitrand pgBackRestrepack/expireunder--plan/--dry-run. - Add plan-flag consistency tests to keep subcommand behavior aligned.
- Add
Native
styconfiguration capability:- Add
pig sty configurewith full execution flow (preflight, argument handling, execution orchestration). - Unify
sty conf/configurebehavior: native implementation by default, with--rawfallback retained. - Add tests for configure main flow, preflight, routing, and install integration to improve maintainability.
- Add
Repo/build/reliability fixes:
- Fix nil dereference in repo cache on
os.Staterror paths. - Align Ubuntu and Debian repo channel mapping, and add timeout control for mirror pulls during reload.
- Harden
repo rmfor dotted module names with safe deletion and path validation. - Fix symlink preservation, cross-device migration, and target-directory handling in
sty initand build flows. - Improve text output and matrix color rendering, and fix ext command validation for empty args/targets.
- Fix nil dereference in repo cache on
35 commits, 66 files changed, LOC:
+5006 / -379PG extension and kernel package updates
| Package | Old | New | Notes |
|---|---|---|---|
timescaledb | 2.25.0 | 2.25.1 | |
citus | 14.0.0-3 | 14.0.0-4 | Rebuilt from the latest official upstream release |
age | 1.7.0 | 1.7.0 | Add PG 17 support for version 1.7.0 |
pg_background | - | 1.8 | DEB-only build; RPM package comes from PGDG |
pgmq | 1.10.0 | 1.10.1 | This extension package is currently unavailable |
pg_search | 0.21.6 | 0.21.8 | Used as direct download package |
oriolepg | 17.11 | 17.16 | OriolePG kernel update |
orioledb | beta12 | beta14 | Matched with OriolePG 17.16 |
cloudberry | - | 2.0.0 | New package |
babelfishpg | - | 5.5.0 | New BabelfishPG package group |
babelfish | - | 5.5.0 | New Babelfish compatibility package |
antlr4-runtime413 | - | 4.13 | New runtime dependency for Babelfish |
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.2.0
v1.1.0
This version is a planned architecture-level upgrade from v1.0.0 to v1.1.0 (79 commits, 193 files changed),
with the core goal of moving pig from a “human-friendly CLI” to an “agent-native orchestratable CLI”.
Seven new extensions are added, bringing the total available extensions to 451.
New Features
- Land the unified agent-native output framework: introduce global
--output(text/yaml/json/json-pretty), and provide unifiedResultstructure, stable status codes, and machine-readable output forext/repo/pg/pt/pb/pitr/status/version/context. - Introduce ANCS (Agent Native Command Schema) metadata: add semantic fields such as
type/volatility/parallel/risk/confirm/os_user/cost, and makehelpemit a command capability tree directly in structured mode for agent-side capability and risk discovery. - Add
pig context(pig ctx) environment snapshot command: aggregate host, PostgreSQL, Patroni, pgBackRest, and extension information in one call for direct agent workflow context injection. - Expand plan capabilities beyond PITR: add
pig ext add/rm --plan,pig pg stop/restart --plan,pig pt switchover/failover --plan, and align withpig pitr --plan/--dry-runinto a reviewable execution plan format (actions, scope, risks, expected outcomes). - Further improve structured result coverage: embed native
pgbackrest infoJSON, and unify structured return DTOs across Patroni/PostgreSQL/PITR/Repo/Ext subsystems for automation compatibility. - Strengthen compatibility layer: add legacy structured wrappers for existing command groups such as
pg_exporter/pg_probe/do/sty, preserving legacy interaction behavior while exposing structured execution results and output capture. - Update pigsty to
v4.1.0.
Extension Update
| Extension | Old | New |
|---|---|---|
| timescaledb | 2.24.0 | 2.25.0 |
| citus | 14.0.0-2 | 14.0.0-3 |
| pg_incremental | 1.2.0 | 1.4.1 |
| pg_bigm | 1.2-20240606 | 1.2-20250903 |
| pg_net | 0.20.0 | 0.20.2 |
| pgmq | 1.9.0 | 1.10.0 |
| pg_textsearch | 0.4.0 | 0.5.0 |
| pljs | 1.0.4 | 1.0.5 |
| sslutils | 1.4-1 | 1.4-2 |
| table_version | 1.11.0 | 1.11.1 |
| supautils | 3.0.2 | 3.1.0 |
| pg_math | 1.0 | 1.1.0 |
| pgsentinel | 1.3.1 | 1.4.0 |
| pg_uri | 1.20151224 | 1.20251029 |
| pgcollection | 1.1.0 | 1.1.1 |
| pg_readonly | 1.0.3 | 1.0.4 |
| timestamp9 | 1.4.0-1 | 1.4.0-2 |
| pg_uint128 | 1.1.1 | 1.2.0 |
| pg_roaringbitmap | 0.5.5 | 1.1.0 |
| plprql | 18.0.0 | 18.0.1 |
| pglinter | 1.0.1 | 1.1.0 |
| pg_jsonschema | 0.3.3 | 0.3.4 |
| pg_anon | 2.5.1 | 3.0.1 |
| vchord | 1.0.0 | 1.1.0 |
| pg_search | 0.21.4 | 0.21.6/0.21.7 |
| pg_graphql | 1.5.12-1 | 1.5.12-2 |
| pg_summarize | 0.0.1-2 | 0.0.1-3 |
| nominatim_fdw | - | 1.1.0 |
| pg_utl_smtp | - | 1.0.0 |
| pg_strict | - | 1.0.2 |
| pg_track_optimizer | - | 0.9.1 |
| pgmb | - | 1.0.0 |
Bug Fixes
- Security fix: resolve parsing panic in
pig build proxywhen receiving malformed proxy addresses. - Security fix: resolve path traversal risk in
pig pg log, preventing access to files outside the log directory via../../. - Security hardening: improve installer/repo path and quoting handling to reduce path injection and invalid-path misuse risks.
- Build pipeline reliability fixes: correctly propagate errors and return non-zero exit codes in
pig build get/pkg/extwhen download/build fails; fix false failures in DEB builds caused bypg_vermismatch. - Repo/catalog refresh fixes: support quiet mirror fallback for
ext/repo reload; makerepo add/set/rmreturn proper error status when cache updates fail. - Extension management fixes: adjust
ext updateto explicit-target updates and fix status drift issues; ensureext importdownloads requested DEB resources to the specified repo directory. - Output/observability fixes: align structured output exit code behavior with text mode rendering; improve permission handling and parsing stability in
pg status.
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.1.0
v1.0.0
This release introduces three major new subcommand groups (pig pg, pig pt, pig pb) for managing PostgreSQL, Patroni, and pgBackRest, along with an orchestrated PITR command and enhanced extension availability display.
New Commands
pig pg- PostgreSQL instance managementpg init/start/stop/restart/reload/status- Control and manage PostgreSQL instancespg role/promote- Detect and switch instance role (primary/replica)pg psql/ps/kill- Connection and session managementpg vacuum/analyze/freeze/repack- Database maintenance operationspg log- Log viewing (list/tail/cat/less)
pig pt- Patroni cluster managementpt list/config- View cluster status and configurationpt restart/reload/reinit- Manage cluster memberspt switchover/failover- Cluster failover operationspt pause/resume- Control automatic failoverpt start/stop/status/log- Patroni service management
pig pb- pgBackRest backup managementpb info/ls- View backup informationpb backup/restore/expire- Backup operationspb create/upgrade/delete- Stanza managementpb check/start/stop/log- Control operations
pig pitr- Orchestrated Point-In-Time Recovery- Automatic Patroni/PostgreSQL coordination
- Multiple recovery targets: time, LSN, XID, restore point
- Dry-run mode and post-recovery guidance
New Features
- Add availability matrix to
pig ext availandpig ext ls
Improvements
- Unified command aliases across pg/pt/pb commands
- Standardized error message format
- Code refactoring and cleanup
Bug Fixes
- Fix missing UTIL extension category
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v1.0.0
v0.8.0
Extension Updates
- Total extensions reached 440
- New extension: pg_ai_query 0.1.1
- New extension: pg_textsearch 0.1.0
- New extension: pg_clickhouse 0.1.0
- pg_biscuit upgraded from 1.0 to 2.0.1 (switched to new repo, renamed to biscuit)
- pg_search upgraded from 0.20.3 to 0.20.5
- pg_duckdb upgraded to official release 1.1.1
- vchord_bm25 upgraded from 0.2.2 to 0.3.0
- pg_semver upgraded from 0.40.0 to 0.41.0
- pg_timeseries upgraded from 0.1.7 to 0.1.8
- Fixed debian/ubuntu pg18 extension issues: supautils, pg_summarize, pg_vectorize, pg_tiktoken, pg_tzf, pglite_fusion, pgsmcrypto, pgx_ulid, plprql
- Pigsty version synced to 4.0.0
Repository Updates
- Removed pgdg yum sysupdate repo due to upstream changes
- Removed pgdg yum llvmjit package due to upstream changes
- Fixed patroni 3.0.4 duplicate package issue on el9.aarch64
- Added priority for el repo definitions, docker repo skipped when unavailable
- Added epel 10 / pgdg 9/10 OS minor version hotfix
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.8.0
v0.7.5
Extension Updates
- timescaledb 2.23.1 -> 2.24.0
- pg_search 0.20.0 -> 0.20.3
- convert 0.0.4 -> 0.0.5
- pglinter 1.0.0 -> 1.0.1
- pgdd 0.6.0 -> 0.6.1
- pg_session_jwt 0.3.3 -> 0.4.0
- pg_anon 2.4.1 -> 2.5.1
- pg_enigma 0.4.0 -> 0.5.0
- wrappers 0.5.6 -> 0.5.7
- pg_vectorize 0.25.0 -> 0.26.0
Repository Updates
Use the fixed Aliyun PGDG mirror repository
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.7.5
v0.7.4
- Update extension metadata:
pg_search,pgmq,pg_stat_monitor - Update pgdg repo URL, the
extrasnow move to parent directory - Bump ivorysql to 5.0 (compatible with PG 18.0)
- Bump Percona Postgres TDE Kernel to 18.1
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.7.4
v0.7.3
- Add new command:
pig repo reloadto update repo metadata - Fix EL PGDG sysupdate aarch64 repo issue (now aarch64 repo ready)
- Fix EL10.aarch64 PGDG repo renaming issue
- Update extension versions
- Bump Pigsty version to 3.7.0
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.7.3
v0.7.2
Extension list update, + 6 new extensions, 437 total
Add PGDG EL10 Sysupdate repo
Add LLVM APT repo
Use local extension.csv catalog in pig build sub command
Updated extensions: vchord pg_later pgvectorscale pglite_fusion pgx_ulid pg_search citus timescaledb pg_profile pg_stat_monitor documentdb
New extensions: pglinter pg_typeid pg_enigma pg_retry pg_biscuit pg_weighted_statistics
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.7.2
v0.7.1
- The brand-new website: /ext/
- Remove unnecessary sudo usage, now can be used inside docker
- Allow using
pg18,pg17arg format in pig ext link command - Add environment var
PIG_NO_SUDOto force not using sudo - RPM Changelog: Add PG 18 support to almost all extensions
- DEB Changelog: Add PG 18 support to almost all extensions
- Infra Changelog: Routine update to the latest version
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.7.1
v0.7.0
- Add support for Debian 13 and EL 10 distributions
- Massive extension updates to the latest versions with PostgreSQL 18 support
- Almost all Rust extensions now support PG 18 via pgrx 0.16.1
pig buildcommand overhaulpig build pkg <pkg>will now download source, prepare deps, and build in one gopig build pgrxis now separated frompig build rustpig build pgrx [-v pgrx_version]can now use existing PG installation directlypig build depwill now handle extension dependencies on both EL and Debian systemspig build extnow has more compact and elegant output, can build RPM on EL without build scriptpig build specnow supports downloading spec files directly from Pigsty repopig build repo/pig repo add/pig repo setnow usenode,pgsql,infraas default repo modules instead ofnode,pgdg,pigsty
- Optimized error logging
- Brand new catalog website based on hugo and hextra
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.7.0
v0.6.2
- Use official PG 18 repo instead of testing repo
- Add
vprefix when specifying pigsty version string - Improved network connectivity check
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.6.2
v0.6.1
- Add el10 and debian 13 trixie support stub
- Dedicated website: /docs/pig/
- Rebuild with go 1.25 and CI/CD pipeline
- Use PIGSTY PGDG mirror in mainland China
- Remove unused
pgdg-el10fixrepo - Use Pigsty WiltonDB mirror
- Add EL 10 dedicated epel repo
- pig version output with go build environment
Release: https://github.com/pgsty/pig/releases/tag/v0.6.1
v0.6.0
- New extension catalog: https://ext.pgsty.com
- New subcommand:
pig installto simplifypig ext install - Add new kernel support: percona with pg_tde
- Add new package: Google GenAI MCP toolbox for databases
- Add new repo: percona repo and clickhouse repo
- Change extension summary info links to https://ext.pgsty.com
- Fix orioledb broken on the Debian/Ubuntu system
- Fix epel repo on EL distributions
- Bump golang to 1.24.5
- Bump pigsty to v3.6.0
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.6.0
v0.5.0
- Update the extension list to 422
- New extension: pgactive from AWS
- Bump timescaledb to 2.20.3
- Bump citus to 13.1.0
- Bump vchord to 0.4.3
- Bug fix pgvectorscale debian/ubuntu pg17 failure
- Bump kubernetes repo to 1.33
- Bump default pigsty version to 3.5.0
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.5.0
v0.4.2
- Update the extension list to 421
- Add openhalo/orioledb support for Debian / Ubuntu
- pgdd 0.6.0 (pgrx 0.14.1)
- convert 0.0.4 (pgrx 0.14.1)
- pg_idkit 0.3.0 (pgrx 0.14.1)
- pg_tokenizer.rs 0.1.0 (pgrx 0.13.1)
- pg_render 0.1.2 (pgrx 0.12.8)
- pgx_ulid 0.2.0 (pgrx 0.12.7)
- pg_ivm 1.11.0 for debian/ubuntu
- orioledb 1.4.0 beta11
- Add el7 repo back
Checksums
Release: https://github.com/pgsty/pig/releases/tag/v0.4.2
v0.4.1
- Update the extension list to 414
- Add
citus_wal2jsonandcitus_pgoutputtopig ext scanmapping - Add PG 18 beta repo
- Add PG 18 package alias
Release: https://github.com/pgsty/pig/releases/tag/v0.4.1
v0.4.0
- Updated extension list, available extensions reached 407
- Added
pig dosubcommand for executing Pigsty playbook tasks - Added
pig ptsubcommand for wrapping Patroni command-line tools - Added extension aliases:
openhaloandorioledb - Added
gitlab-ce/gitlab-eerepository distinction - Built with the latest Go 1.24.2 and upgraded dependency versions
- Fixed
pig ext statuspanic issue under specific conditions - Fixed
pig ext scanunable to match several extensions
Release: https://github.com/pgsty/pig/releases/tag/v0.4.0
v0.3.4
- Routine extension metadata update
- Use aliyun epel mirror instead of broken tsinghua tuna mirror
- Bump pigsty version string
- Add
gitlabrepo to the repo list
Release: https://github.com/pgsty/pig/releases/tag/v0.3.4
v0.3.3
- Add
pig build depcommand to install extension build dependencies - Update default repo list
- Use pigsty.io mirror for
mssqlmodule (wiltondb/babelfish) - Merge docker module into
infra - Remove pg16/17 from el7 target
- Allow installing extensions in el7
- Update package alias
Release: https://github.com/pgsty/pig/releases/tag/v0.3.3
v0.3.2
Enhancement
- New extensions
- Use
upxto reduce binary size - Remove embedded pigsty to reduce binary size
Release: https://github.com/pgsty/pig/releases/tag/v0.3.2
v0.3.1
Routine bugfix
- Fix repo format string
- Fix ext info links
- Update pg_mooncake metadata
Release: https://github.com/pgsty/pig/releases/tag/v0.3.1
v0.3.0
The pig project now has a new homepage, along with the PostgreSQL Extension Catalog.
Release: https://github.com/pgsty/pig/releases/tag/v0.3.0
v0.2.2
404 Extensions Available in Pig v0.2.2
Release: https://github.com/pgsty/pig/releases/tag/v0.2.2
v0.2.0
Release: https://github.com/pgsty/pig/releases/tag/v0.2.0
v0.1.4
Release: https://github.com/pgsty/pig/releases/tag/v0.1.4
v0.1.3
v0.1.3, routine update, with 390 extensions available now!
Release: https://github.com/pgsty/pig/releases/tag/v0.1.3
v0.1.2
351 PostgreSQL Extensions, including the powerful postgresql-anonymizer 2.0
Release: https://github.com/pgsty/pig/releases/tag/v0.1.2
v0.1.0
pig CLI v0.1 released
Release: https://github.com/pgsty/pig/releases/tag/v0.1.0
v0.0.1
Genesis Release
5 - pig
The pig CLI provides a comprehensive toolkit for managing PostgreSQL installations, extensions, repositories, and extension builds from source. Use pig help <command> to view command documentation.
- pig repo: manage software repositories
- pig ext: manage PostgreSQL extensions
- pig build: build extensions from source
- pig install: install packages with the native package manager and translate PostgreSQL aliases
- pig sty: manage Pigsty installation and Grafana dashboards
- pig inventory: inspect, edit, validate, and exchange the Pigsty inventory (new in v1.6.0)
- pig do: run Pigsty administration playbook tasks
- pig pe: access pg_exporter metrics and configuration
- pig pg: manage local PostgreSQL servers
- pig pt: run patronictl transparently with service and config helpers
- pig pb: manage pgBackRest backup and restore
- pig pitr: run the full PITR workflow
- pig context: output an environment context snapshot for humans and agents
- pig status / update / version: inspect environment status, upgrade pig, and print version information
Overview
pig repo
Manage APT/YUM repositories for PostgreSQL packages. See pig repo for details.
pig ext
Manage PostgreSQL extensions and kernel packages. See pig ext for details.
pig build
Build PostgreSQL extensions from source. See pig build for details.
pig install
Install packages through the system’s native package manager and translate PostgreSQL kernel, extension, and common aliases into package names. Use -n/--no-translation when you need to pass raw system package names directly.
pig sty
Install the Pigsty distribution. See pig sty for details.
pig inventory
Inspect, edit, validate, check, and exchange the Pigsty inventory (pigsty.yml) with the
CMDB. Root-level command group with alias inv; see pig inventory
for details. (New in v1.6.0)
pig do
Run Pigsty administration tasks through the corresponding Ansible playbooks.
pig pe
Access PostgreSQL monitoring metrics exposed by pg_exporter. The default endpoint is 127.0.0.1:9630.
pig context
Output an environment context snapshot covering host, PostgreSQL, Patroni, pgBackRest, and installed extensions. This command is useful for troubleshooting and for automation scripts that need a quick view of the current node.
pig pg
Manage the local PostgreSQL server. See pig pg for details.
pig pt
Run patronictl transparently to manage Patroni HA clusters. See pig pt for details.
pig pb
Manage pgBackRest backup and restore. See pig pb for details.
pig pitr
Run orchestrated point-in-time recovery (PITR). See pig pitr for details.
Helper Commands
6 - pig repo
The pig repo command is a comprehensive package repository manager. It can add, remove, create, and manage repositories on RPM systems (RHEL/CentOS/Rocky/Alma) and Debian systems (Debian/Ubuntu).
| Command | Description | Notes |
|---|---|---|
repo list | Print available repositories and modules | |
repo info | Show repository details | |
repo status | Show current repository status | |
repo add | Add repositories | Requires sudo or root |
repo set | Clear, overwrite, and update repositories | Requires sudo or root |
repo rm | Remove repositories | Requires sudo or root |
repo update | Update repository cache | Requires sudo or root |
repo create | Create local YUM/APT repository | Requires sudo or root |
repo cache | Create offline package from local repo | Requires sudo or root |
repo boot | Bootstrap repository from offline package | Requires sudo or root |
repo reload | Refresh repository catalog |
Quick Start
Modules
In pig, APT/YUM repositories are organized as modules: groups of repositories serving a specific purpose.
| Module | Description | Repository List |
|---|---|---|
all | All core modules required to install PG | node + infra + pgsql |
pgsql | PGDG + Pigsty PG extensions | pigsty-pgsql + pgdg |
pigsty | Pigsty Infra + PGSQL repositories | pigsty-infra, pigsty-pgsql |
pgdg | PGDG official repositories | pgdg-common, pgdg14-18 |
node | Linux system repositories | base, updates, extras, epel, baseos, appstream… |
infra | Infrastructure component repositories | pigsty-infra, nginx, docker-ce |
docker | Docker repository | docker-ce |
beta | PostgreSQL 19 beta repositories | pgdg19-beta, pgdg-beta |
extra | PGDG non-free and third-party extensions | pgdg-extras, timescaledb, citus |
groonga | PGroonga repository | groonga |
mssql | WiltonDB repository (deprecated) | babelfish |
percona | Percona PG + PG_TDE | percona |
llvm | LLVM toolchain repository | llvm |
kube | Kubernetes repository | kubernetes |
grafana | Grafana repository | grafana |
haproxy | HAProxy repositories | haproxyd, haproxyu |
redis | Redis repository | redis |
mongo | MongoDB repository | mongo |
mysql | MySQL repository | mysql |
click | ClickHouse repository | clickhouse |
gitlab | GitLab repository | gitlab-ce, gitlab-ee |
Pig also includes APT/DNF repositories for other databases and systems such as redis, kubernetes, grafana, clickhouse, gitlab, haproxy, mongodb, and mysql.
In general, node (Linux system repositories) and pgsql (PGDG + Pigsty) are required for PostgreSQL installation. The infra repository is optional and contains tools, IvorySQL kernel packages, and similar components. The special all module adds all required repositories at once and is a suitable starting point for most users.
Repository Definitions
The full repository definition bundled with Pigsty is in cli/repo/assets/repo.yml.
You can create ~/.pig/repo.yml to explicitly modify and override pig’s repository definitions. When editing repository definitions, you can add extra regional mirror URLs under baseurl, such as China or Europe mirrors. When --region is specified, pig first looks for the matching regional URL and falls back to the default URL if the region is unavailable. Since v1.7.0, -m|--mirror explicitly selects the bundled china definitions, including pigsty.cc and the maintained domestic mirrors; it no longer rewrites PGDG URLs through a runtime proxy.
Ordinary EL repositories keep native DNF module filtering. Only definitions that explicitly declare module_hotfixes=1—notably Pigsty and PGDG repositories—override module streams, and the key is removed when rendering EL7 YUM configuration.
repo list
pig repo list lists all repository modules available on the current system.
repo info
Show detailed information for specific repositories or modules, including URLs, metadata, regional mirrors, and .repo / .list repository file content.
repo status
Show current repository configuration on the system.
repo add
Add repository configuration files to the system. Requires root/sudo privileges.
Options:
-r|--remove: remove existing repositories before adding new ones-u|--update: run package cache update after adding repositories-m|--mirror: explicitly select the bundledchinarepository definitions--region <region>: use regional mirror repositories (default/china/europe)
| Platform | Module Location |
|---|---|
| EL | /etc/yum.repos.d/<module>.repo |
| Debian | /etc/apt/sources.list.d/<module>.list |
repo set
Equivalent to repo add --remove --update. It clears existing repositories, sets up new ones, then updates cache.
repo set supports the same --region and -m|--mirror region selection as repo add; it always uses overwrite semantics, equivalent to repo add all --remove --update.
repo rm
Remove repository configuration files and back them up.
| Platform | Backup Location |
|---|---|
| EL | /etc/yum.repos.d/backup/ |
| Debian | /etc/apt/sources.list.d/backup/ |
repo update
Update package-manager cache to reflect repository changes.
| Platform | Equivalent Command |
|---|---|
| EL | dnf makecache |
| Debian | apt update |
repo create
Create a local package repository for offline installation.
The current implementation prefers sow when it is available in PATH. On Linux, the SOW backend runs the equivalent of the following with sudo for every target directory:
On macOS, SOW is required, runs without sudo, and the default target is the current directory. On Linux, if sow is not installed, EL falls back to createrepo_c and Debian/Ubuntu falls back to dpkg-scanpackages from dpkg-dev. If neither the preferred backend nor the platform fallback is available, pig repo create fails. A SOW execution error is returned directly rather than retried through the legacy backend. The 10m timeout limits the wait for SOW’s directory lock; it does not cap repository indexing time.
SOW’s --pigsty transaction:
- Scans only top-level regular
.rpmand.debfiles—no recursion and no symlink following. - Removes parsed 32-bit x86 packages (RPM
i386/i486/i586/i686, DEBi386) and packages whose binary name is exactlypatroniwith upstream version exactly3.0.4. - Builds the applicable RPM/DEB metadata atomically and writes
repo_completelast. The marker contains SHA-256 hashes for remaining top-level packages, sorted by basename.
Non-package files and directories are left untouched; malformed package candidates or conflicting package coordinates make the SOW transaction fail closed. The legacy fallback has different cleanup and metadata semantics and writes an MD5 package list to repo_complete. After either backend exits, PIG requires repo_complete to exist as a regular file, but it does not validate the marker contents or hashes. Consumers that use the marker as a delivery gate should perform that verification themselves.
repo cache
Create a compressed tarball of repository contents for offline distribution.
Options:
-d, --dir: source directory, default/www/-p, --path: output path, default/tmp/pkg.tgz
repo boot
Extract and set up a local repository from an offline package.
Options:
-p, --path: package path, default/tmp/pkg.tgz-d, --dir: target directory, default/www/
repo reload
Refresh repository metadata from GitHub to the latest version.
The updated file is placed in ~/.pig/repo.yml.
7 - pig ext
The pig ext command is an all-in-one tool for managing PostgreSQL extensions. It lets you search, install, remove, update, and manage PostgreSQL extensions, and it can also handle PostgreSQL kernel packages.
| Command | Description | Notes |
|---|---|---|
ext list | Search extensions | |
ext info | Show extension details | |
ext avail | Show extension availability matrix | |
ext status | Show installed extensions | |
ext scan | Scan installed extensions | |
ext add | Install extensions | Requires sudo or root |
ext rm | Remove extensions | Requires sudo or root |
ext update | Update extensions | Requires sudo or root |
ext import | Download extensions for offline use | Requires sudo or root |
ext link | Link a PG version into PATH | Requires sudo or root |
ext reload | Refresh extension catalog |
Quick Start
Before installing PostgreSQL extensions, add the required repositories with pig repo add:
Then search and install PostgreSQL extensions:
See the extension list for available extensions and package names.
Notes:
- If no PostgreSQL version is specified, pig tries to detect the active PostgreSQL installation from
pg_configinPATH. - PostgreSQL can be selected by major version (
-v) or by pg_config path (-p).- With
-v, pig uses the default PGDG kernel package path for that major version.- EL distros:
/usr/pgsql-$v/bin/pg_config - DEB distros:
/usr/lib/postgresql/$v/bin/pg_config
- EL distros:
- With
-p, pig locates PostgreSQL directly from that path.
- With
- The extension manager automatically adapts to the OS package format:
- RPM packages for RHEL/CentOS/Rocky Linux/AlmaLinux
- DEB packages for Debian/Ubuntu
- Extension dependencies are resolved automatically when possible.
- Use
-ycarefully because it auto-confirms prompts.
Pigsty assumes official PGDG kernel packages are installed. If not, install them with:
ext list
List or search extensions in the extension catalog.
Category filtering is done by passing the category name as the query. Supported categories include: time, gis, rag, fts, olap, feat, lang, type, func, util, admin, stat, sec, fdw, sim, and etl.
Options:
-v|--version: filter by PG version--pkg: show package names instead of extension names, listing only leading extensions
Status column:
installed: extension is installedavailable: extension is available but not installednot avail: extension is not available on the current system
The default extension catalog is defined in cli/ext/assets/extension.csv.
Use pig ext reload to refresh to the latest catalog. The downloaded catalog is stored at ~/.pig/extension.csv; the latest online catalog is also published at pigsty.io/ext/data/extension.csv.
ext info
Show detailed information for selected extensions.
ext avail
Show the extension availability matrix across operating systems, architectures, and PostgreSQL versions.
The matrix shows availability across operating systems (EL8/9/10, Debian 12/13, Ubuntu 22/24/26), architectures (x86_64/aarch64), and PostgreSQL versions (14-18).
ext status
Show installed extension status for the current PostgreSQL instance.
Options:
-c|--contrib: include contrib extensions in the result
ext scan
Scan installed extensions for the current PostgreSQL instance.
This command scans the PostgreSQL extension directory and finds extensions that are actually installed.
ext add
Install one or more PostgreSQL extensions. Same-level aliases for pig ext add include pig ext install, pig ext ins, and pig ext a. The top-level pig install command is a separate native package-manager wrapper that also supports PostgreSQL and extension alias translation.
Options:
-v|--version: specify PG major version-y|--yes: auto-confirm installation--plan: preview the install plan without running package-manager commands
ext rm
Remove one or more PostgreSQL extensions.
Options:
-v|--version: specify PG major version-y|--yes: auto-confirm removal--plan: preview the remove plan without running package-manager commands
ext update
Update explicitly selected installed extensions to the latest version. For safety, pig ext update with no arguments is a no-op; you must name the targets explicitly.
Options:
-v|--version: specify PG major version-y|--yes: auto-confirm update-m|--mirror: prefer thepigsty.ccmirror as the update source
ext import
Download extension packages into a local repository for offline installation.
Options:
-d|--repo: local repository directory (default:/www/pigsty)
ext link
Link a selected PG version into the system PATH.
This command creates the /usr/pgsql symlink and writes /etc/profile.d/pgsql.sh.
ext reload
Refresh extension metadata.
The updated catalog is stored at ~/.pig/extension.csv.
8 - pig build
The pig build command simplifies the full workflow for building PostgreSQL extensions from source. It provides build infrastructure setup, dependency management, and compilation environments for standard and custom PostgreSQL extensions across supported operating systems.
| Command | Description | Notes |
|---|---|---|
build spec | Initialize build specification directory | |
build repo | Initialize required repositories | Requires sudo or root |
build tool | Initialize build tools | Requires sudo or root |
build rust | Install Rust toolchain | Requires sudo or root |
build pgrx | Install and initialize pgrx | Requires sudo or root |
build proxy | Initialize build proxy | |
build get | Download source tarballs | |
build dep | Install extension build dependencies | Requires sudo or root |
build ext | Build extension packages | Requires sudo or root |
build pkg | Complete pipeline: get, dep, ext | Requires sudo or root |
Quick Start
The fastest way to set up a build environment and build an extension:
For finer control:
Build Infrastructure
Directory Layout
Build output locations:
- EL systems:
~/ext/pkg/, also accessible through~/rpmbuild/RPMS/ - Debian systems:
~/ext/pkg/, also accessible through~/debbuild/DEBS/
build spec
Set up build specifications and directory layout.
What it does:
- Downloads the RPM or DEB build specification tarball.
- Creates
~/ext/{pkg,src,log,tmp}and the platform build directory. - Links
RPMS/DEBSandSOURCESto~/ext/pkgand~/ext/src. - Syncs makefiles, specs, and Debian packaging files with incremental
rsync.
Working directory: ~/ext/ stores sources, packages, logs, and temporary files. The platform packaging directory is ~/rpmbuild/ or ~/debbuild/.
build repo
Initialize package repositories required for building extensions.
What it does: initializes build repositories with pig repo set -ru: remove old repositories, add required repositories, and refresh package caches. --beta/-b appends the beta module for explicit PostgreSQL 19 beta builds; the stable default path still uses PG14-18.
Options:
-b|--beta: additionally enable PostgreSQL beta repository modules-m|--mirror: select the built-inchinaregion sources
build tool
Install development tools and compilers.
Toolsets:
- Minimal (
mini): GCC/Clang compilers, Make, and generic build essentials; does not install PostgreSQL server/devel packages. - Default /
full: compilers, development libraries, packaging tools such asrpmbuildanddpkg-dev, plus stable PG14-18 build dependencies. --beta: additionally installs PG19 beta server/devel build packages on top of the default toolset.
build rust
Install the Rust toolchain required by Rust-based extensions.
Installed components: Rust compiler (rustc), Cargo, Rust standard library, and development tools. -m|--mirror uses mirror mode and writes rsproxy.cn Cargo configuration.
build pgrx
Install and initialize PGRX, the PostgreSQL extension framework for Rust.
Prerequisites: Rust toolchain and PostgreSQL development headers must be installed first. Default auto-detection only covers stable PG14-18; use -b|--beta, or explicitly pass --pg 19, when PG19 beta is required.
build proxy
Configure a proxy for build environments with restricted internet access.
build get
Download extension source tarballs.
Arguments to pig build get are extension names, package names, or source filenames. Unknown names are treated as source filenames. It does not expand all or std into built-in package sets; list the target package names explicitly for batch downloads.
Some source packages do not map directly to extension names, so pig build get includes special aliases for direct source downloads.
Common special source aliases include: babelfishpg / babelfish, agensgraph / agentsgraph, oriolepg / orioledb, cloudberry, pgedge, pdu, pgdog, rdkit, onesparse, and libfepgutils.
build dep
Install dependencies required to build extensions.
Options:
--pg: specify one or more PostgreSQL major versions. If omitted, pig infers versions from extension metadata or local PostgreSQL installations.
build ext
Compile extensions and create installation packages.
Options:
--pg: specify one or more PostgreSQL major versions.-s|--symbol: build debug symbol packages (RPM only).
build pkg
Run the complete build pipeline: download, dependency installation, and build.
Options:
--pg: specify one or more PostgreSQL major versions.-s|--symbol: build debug symbol packages (RPM only).-m|--mirror: prefer thepigsty.ccmirror when downloading source files.
Common Workflows
Workflow 1: Build a Standard Extension
Workflow 2: Build a Rust Extension
Workflow 3: Build Multiple Versions
Troubleshooting
Build Tools Not Found
Missing Dependencies
PostgreSQL Headers Not Found
Rust/PGRX Issues
Extension Build Matrix
Common Extensions to Build
| Extension | Type | Build Time | Complexity | Special Requirements |
|---|---|---|---|---|
| pg_repack | C | Fast | Simple | None |
| pg_partman | SQL/PLPGSQL | Fast | Simple | None |
| citus | C | Medium | Medium | None |
| timescaledb | C | Slow | Complex | CMake |
| postgis | C | Very slow | Complex | GDAL, GEOS, Proj |
| pg_duckdb | C++ | Medium | Medium | C++17 compiler |
| pgroonga | C | Medium | Medium | Groonga libraries |
| pgvector | C | Fast | Simple | None |
| plpython3 | C | Medium | Medium | Python development |
| pgrx extensions | Rust | Slow | Complex | Rust, PGRX |
9 - pig sty
pig can also be used as a CLI tool for Pigsty, a batteries-included free PostgreSQL RDS solution. It brings HA, PITR, monitoring, infrastructure as code (IaC), and rich extension support to your PostgreSQL clusters.
| Command | Description | Notes |
|---|---|---|
sty init | Install Pigsty | |
sty boot | Bootstrap the Pigsty controller | Auto-elevates when needed |
sty conf | Generate and validate Inventory | Native Go workflow |
sty deploy | Run deployment playbook | |
sty list | List available Pigsty versions | |
sty get | Download Pigsty source tarball | |
sty grafana | Manage Grafana dashboards (alias gf) | New in v1.6.0 |
Since v1.8.0,
pig sty bootandpig sty confare native Go workflows. They no longer invoke Pigsty’s legacybootstraporconfigureshell scripts. Since v1.6.0, the formerpig sty edit/validate/checkcommands moved to the root-levelpig inventorycommand group, and the experimentalpig sty dashboardwas replaced bypig sty grafana.
Quick Start
Use pig sty to bootstrap and deploy Pigsty on the current node.
See the detailed setup guide: https://pigsty.io/docs/setup/install/
sty boot initializes a missing default ~/pigsty tree on a best-effort basis. Use
pig sty init first when you need to select an explicit Pigsty version or installation path.
sty init
Download and install the Pigsty distribution into ~/pigsty.
Options:
-p|--path: target installation directory, default~/pigsty-f|--force: force overwrite of existing pigsty directory-m|--mirror: prefer thepigsty.ccmirror-v|--version: Pigsty version-d|--dir: download directory, default/tmp
sty boot
Bootstrap the Pigsty controller with the native Go workflow. The command prepares a usable
Ansible environment, supports online and offline repositories, repairs common controller
prerequisites, and reports a structured result. It never delegates to Pigsty’s legacy
bootstrap script and does not require curl, wget, tar, or gzip for package download
and extraction.
You may invoke the command without sudo. Pig resolves and downloads an explicit source first,
then re-executes itself through sudo once when root access is required. Set PIG_NO_SUDO=1 to
disable automatic elevation, or PIG_NON_INTERACTIVE=1 to make the sudo attempt non-interactive.
Bootstrap stages
The native workflow performs these stages:
- On Debian 12/13, check and repair
en_US.UTF-8when possible so Ansible can start. - Execute
ansible-playbook, discover its Python interpreter, and verifyyaml,jmespath, and eithercryptographyorOpenSSL. A binary that cannot actually run is not considered ready. - Resolve the repository source, prepare offline content when selected, and install the lean controller package set only when Ansible is missing or unusable.
- Verify Ansible again after package installation and retry locale preparation when packages may have made locale tools available.
- Probe controller helpers, repair key-based SSH to
127.0.0.1for the invoking admin user, and initialize a missing default~/pigstytree when possible.
Explicit, automatically discovered, and already committed offline sources are prepared even when
Ansible is already usable. This makes sty boot suitable for staging an offline repository on an
otherwise ready controller.
Source selection and modes
The result records one of four bootstrap modes:
| Mode | Meaning |
|---|---|
ready | Ansible was already usable and no offline source needed preparation. |
offline | An explicit, trusted automatic, or committed offline repository was selected. |
online | Regional online repositories were configured to repair the controller. |
existing | An online refresh failed under --keep, and existing repository definitions were successfully used as a fallback. |
Source precedence and safety rules are deterministic:
--pathaccepts a local archive or an HTTP(S) URL. URL credentials are rejected, and a bad explicit source is a hard error rather than an online fallback.- An automatically discovered
/tmp/pkg.tgzmust be a regular, non-group/world-writable file owned by root or the invoking sudo user. Unsafe candidates are ignored with a warning. - A completed
/www/pigstyrepository takes precedence over a selected package. If both exist, the committed repository is reused and the package is left untouched with a warning. - Archives are downloaded and extracted by Pig itself. If
/wwwdoes not exist, Pig creates/data/nginxand the expected/www -> /data/nginxsymbolic link before committing content.
Offline mode enables only the strict pigsty-local repository. Online mode configures the
selected region, installs Pigsty’s embedded signing key with repository signature checks enabled,
and installs the node and pigsty controller modules.
Repository transaction and failure boundary
By default, repository definitions are backed up before replacement. If repository setup or
package installation fails, Pig attempts to restore the backup and reports whether rollback
succeeded or failed. --keep changes the policy to additive operation: existing definitions are
preserved, online refresh may fall back to them, and no replacement rollback is required.
Invalid explicit sources, unsupported package management when installation is required, repository/package failures, and an unusable post-install Ansible runtime are command failures. Locale repair, optional helper probes, localhost SSH repair, and Pigsty tree initialization are advisory finishing steps; their failures are retained as warnings in an otherwise usable result.
Options:
-r|--region: region, such as default, china, europe-m|--mirror: equivalent to--region china; mutually exclusive with--region-p|--path: offline package file or HTTP(S) URL; an invalid explicit source is a hard error-k|--keep: preserve existing repositories instead of replacing them
Structured output
Use the global -o json or -o yaml flag for automation. The payload kind is
pig.sty.boot/v2 and includes the Ansible state, selected mode and package manager, repository
policy and rollback result, source and repository paths, locale, localhost SSH and Pigsty tree
initialization status, whether the machine changed, warnings, and these recommended next steps:
Dynamic progress is suppressed in structured mode, so stdout remains machine-readable.
See: https://pigsty.io/docs/setup/offline/#bootstrap
sty conf
Generate Pigsty Inventory through the native Go workflow. sty conf reads one template below
<PIGSTY_HOME>/conf, applies bounded structural mutations, validates the complete candidate,
and atomically writes an owner-only Inventory. It does not invoke or fall back to ./configure.
The default mode is meta; pig sty c and pig sty configure are command aliases. Note that
-O selects the Inventory output file, while the global lowercase -o selects text, JSON, or
YAML command output.
Template and output safety
- A mode is a slash-separated relative name below
<PIGSTY_HOME>/conf;.ymlis optional. Absolute paths, traversal, empty segments, and path escape are rejected. - Relative output paths are resolved below
<PIGSTY_HOME>; absolute output paths are retained. - The destination cannot alias the source through the same path, an existing symlink, a symlinked parent, or a hard link. An existing output symlink is always refused.
- Pig parses the source and rejects conflicting IP mappings before running external preflight checks. A parse, mutation, preflight, or validation failure leaves the destination unchanged.
- A successful result is written atomically with mode
0600.
Structural mutations
The command edits parsed YAML structures and bounded scalar tokens rather than applying broad text substitutions:
| Input | Native behavior |
|---|---|
--ip A,B,... | Maps up to ten distinct addresses, in order, to 10.10.10.10 through 10.10.10.19. Replacement is simultaneous, so swaps are safe and unrelated VIPs remain intact. |
no --ip | Detects local interfaces. Interactive mode asks when selection is ambiguous; --non-interactive or closed stdin fails with guidance to pass --ip. |
--domain NAME | Replaces only the exact i.pigsty token, not names such as cli.pigsty or i.pigsty.cc; NAME must be a valid DNS domain. |
| small controller | When detected CPU count is below four, rewrites node_tune: oltp and pg_conf: oltp.yml to their tiny profiles. |
--region REGION | Updates all.vars.region for non-default regions. china also activates template-provided Docker and pip mirrors, but never invents values absent from the template. |
--proxy | Writes non-empty HTTP_PROXY/http_proxy, HTTPS_PROXY (falling back to ALL_PROXY), ALL_PROXY, and NO_PROXY values into all.vars.proxy_env; a safe default no-proxy list is used when needed. |
--version MAJOR | Updates generic templates for PostgreSQL 14-18, or explicit 19 beta, and selects the matching locale. Version-pinned mssql, polar, and pgNN modes keep their template version and report a warning. |
--generate | Generates one 24-character value per known credential identifier and consistently replaces its active values and documented placeholders. |
An IP mapping that would collide with an unreplaced Inventory key is rejected as an invalid argument. A supplied address with no matching placeholder slot is retained in structured output as a discarded-IP warning rather than being silently ignored.
For PostgreSQL 19 beta, Pig also enables the beta repository after pgsql when the template
contains the expected repository list. Modes below conf/build/ intentionally bypass IP mapping
and controller-admin preflight so build templates remain portable.
Active password identifiers are grafana_admin_password, pg_admin_password,
pg_monitor_password, pg_replication_password, patroni_password,
haproxy_admin_password, minio_secret_key, and etcd_root_password. Generation also covers
the documented DBUser.Meta, DBUser.Viewer, S3User.Backup, S3User.Meta, S3User.Data,
DBUser.Supa, and Vibe.Coding placeholders. Repeated occurrences of one identifier receive the
same generated value.
Options:
-c|--conf: template mode, equivalent to positional[mode]; the two forms are exclusive--ip: up to ten distinct comma-separated IPv4 addresses--domain: replace the exacti.pigstyplaceholder with a valid DNS domain-v|--version: PostgreSQL major version, 18/17/16/15/14; 19 beta can be specified explicitly-r|--region: upstream repository region, such as default/china/europe-m|--mirror: equivalent to--region china; mutually exclusive with--region-O|--output-file: output config file path, defaultpigsty.yml-s|--skip: keep the placeholder IP and skip admin SSH/sudo preflight; exclusive with--ip-p|--port: SSH port-x|--proxy: write non-empty proxy environment variables intoall.vars.proxy_env-n|--non-interactive: refuse ambiguous IP selection instead of prompting-g|--generate: replace known demo credentials with random 24-character values
Preflight and validation
Unless --skip is used, Pig inspects the kernel, architecture, package manager, platform vendor,
controller resources, sudo/admin access, localhost SSH, and Ansible availability. --port is used
for the SSH check. These diagnostics are returned as actionable warnings where the Inventory can
still be generated; invalid arguments and unsafe configuration transformations remain errors.
The rendered candidate must pass Pig’s native Inventory validation. When ansible-inventory is
available, Pig also runs a bounded external parse before committing the file. --skip preserves
placeholder IPs and bypasses admin SSH/sudo preflight, but it does not disable template parsing,
safe mutation, Inventory validation, or atomic writing.
Structured output
With global -o json or -o yaml, the payload kind is pig.sty.configure/v1. It reports the
mode, source and output paths, region, chosen primary address, applied and discarded IPs, domain,
SSH port, requested and effective PostgreSQL versions, native-workflow marker, generated secret
identifiers, and warnings. Secret values are never printed.
See: https://pigsty.io/docs/setup/install/#configure
sty deploy
Deploy Pigsty with the deploy.yml playbook.
This command runs the deploy.yml playbook from your Pigsty installation directory. For backward compatibility, if deploy.yml does not exist but install.yml exists, install.yml is used instead.
Warning: This operation modifies your system, and invocation is explicit consent — deploy starts immediately without a
--yesgate; use Ctrl+C to interrupt a mistaken run. (Thepig sty install/insaliases were removed in v1.6.0.)
sty list
List available Pigsty versions.
sty get
Download the Pigsty source tarball.
sty grafana
Since v1.6.0, pig sty grafana (alias gf) manages Grafana dashboards through the native
HTTP API, replacing the experimental pig sty dashboard. The PATH argument may select the
grafana root, one direct folder, or one dashboard JSON file; without PATH, pig resolves
<PIGSTY_HOME>/files/grafana and never falls back to the current directory.
Connection and credentials:
| Option | Description |
|---|---|
--endpoint | Grafana origin and optional path prefix (default http://i.pigsty/ui) |
--username | Grafana API username |
--password | Grafana API password (insecure: visible in process arguments and shell history) |
--password-file | Owner-only file containing the password (recommended) |
Password resolution order: --password → --password-file → the GRAFANA_PASSWORD
environment variable → all.vars.grafana_admin_password from the inventory.
The HTTP client enforces timeouts and response-size limits, refuses redirects, and
verifies TLS certificates by default.
Legacy dashboards and schema v2 resources
load and init accept both classic Grafana dashboard JSON and the resource form whose identity is exactly:
The two formats are not flattened into one another during loading:
- Classic JSON takes its UID from top-level
uidand uses the legacy dashboard API. - Schema v2 takes its UID from
metadata.name, defaults a missing namespace todefault, requires an object-valuedspec, and uses Grafana’s dashboard resource API. - The JSON filename (without
.json) must match the resolved UID. Only one local folder layer is allowed; its directory name becomes the Grafana folder UID. - For schema v2, PIG preserves
specand thegrafana.app/messageannotation, setsgrafana.app/folderfrom the local folder, and deliberately removes server-managed metadata/status before upsert. dumppreserves schema v2 only when the target file already exists locally in v2 form; it then fetches the native v2 resource using that file’s namespace. A new dump target defaults to classic JSON. Local-only files are never deleted bydump.
Other dashboard.grafana.app/* versions or malformed resource envelopes are rejected instead of being silently treated as classic dashboards. Format preservation therefore depends on keeping the existing local file when round-tripping v2 resources.
10 - pig inventory
The pig inventory command group (alias pig inv), introduced in v1.6.0, provides
lossless inspection, editing, validation, and readiness checks for the Pigsty inventory
(pigsty.yml), plus an experimental cmdb subtree that exchanges the inventory with the
PostgreSQL CMDB.
The lossless engine preserves YAML comments, formatting, key order, anchors, and line
endings byte-for-byte; edit re-parses the whole document before writing and writes
atomically — invalid YAML can never reach disk.
| Command | Alias | Description |
|---|---|---|
inv status | Inspect the active inventory source (without executing) | |
inv list | ls | List inventory topology and value kinds (--depth) |
inv show | Show verbatim inventory YAML (may contain secrets) | |
inv edit | e | Edit the inventory or one fragment in $EDITOR |
inv validate | v | Validate one complete static Pigsty inventory |
inv check | ck | Check inventory, controller, and target readiness |
inv diff | Compare declarations of two inventories (value-free) | |
inv cmdb | Exchange with the PostgreSQL CMDB (experimental) |
The inventory path comes from pig’s config resolution (the global -i/--inventory flag or
the Pigsty home directory), and every command supports -o json|yaml structured output.
Quick Start
Selectors
list / show / edit accept an optional selector that addresses one fragment:
inv edit
Opens the selected fragment in $EDITOR. After you save and exit, pig re-applies
indentation and newline style → re-parses the whole document (aborting and keeping the
temp file on failure) → checks that the on-disk file was not concurrently modified → writes
atomically.
| Option | Description |
|---|---|
--from | Replace the selected fragment from a regular file or stdin (-), skipping the editor |
Note: after a successful edit, pig tightens the inventory file mode to
0600(the file may contain database passwords and other secrets); the result reports this via themode_tightenedfield. If other users or tools read the file directly, adjust permissions or ownership accordingly.
inv validate
Validates one complete static Pigsty inventory: YAML structure, Ansible conventions, and
Pigsty semantics (such as admin_ip, the infra group, and IPv4 host keys) are checked
layer by layer; diagnostics never echo sensitive values.
| Option | Description |
|---|---|
--strict | Treat validation warnings as failures |
--ansible | Also parse with a bounded ansible-inventory adapter |
--timeout | Timeout for --ansible compatibility validation (default 10s) |
validateis a Pigsty-semantics validator, not a generic Ansible linter; its rules stay aligned with Pigsty’s ownbin/validate(intentionally stricter in a few places). Also note that parsing outright rejects duplicate keys and multi-document YAML — such files cannot even be used withshow/edit.
inv check
Readiness checks on top of static validation: by default only the inventory and local
controller conditions are checked; add probes with --profile.
| Option | Short | Description |
|---|---|---|
--profile | -p | Additional probes: ansible / network / ssh |
--user | Explicit SSH user (defaults to the controller user) | |
--port | TCP/SSH target port (default 22) | |
--sudo | With the ssh profile, also observe sudo -n true |
inv cmdb (experimental)
Experimental: interfaces and behavior may change.
pig inventory cmdb exchanges the inventory with Pigsty’s existing CMDB schema
(files/cmdb.sql, the pigsty / pglog schemas) over a native PostgreSQL driver.
Connection resolution: -d/--database (database name, URI, or libpq conninfo) →
METADB_URL environment variable → service=meta.
| Subcommand | Description |
|---|---|
check | Read-only: verify CMDB projections, optionally against the static inventory |
init | Apply the cmdb.sql baseline (--yes required over existing schemas; --plan preview) |
load | Replace all CMDB declaration rows from the static inventory (single transaction; --yes; --plan/--strict) |
dump | Export the CMDB as a static inventory file (--force to overwrite a differing target) |
enable | Guarded switch of the ansible.cfg inventory to the CMDB (inventory.sh) |
disable | Switch back to the static pigsty.yml (both support --plan; atomic, rollback-safe writes) |
Note:
initapplies thecmdb.sqlbaseline directly and does not take a backup of an existing CMDB — back it up yourself before running against real data;loadreplaces all declaration rows. Destructive operations are gated by a target-fingerprint confirmation, and structured output mode requires an explicit--yes.
11 - pig postgres
The pig pg command (alias pig postgres) manages local PostgreSQL servers and databases. It wraps local primitives such as pg_ctl, psql, and vacuumdb; use pig pt for Patroni cluster operations and pig pitr for orchestrated PITR.
Command Overview
Service Control (pg_ctl wrapper):
| Command | Alias | Description | Notes |
|---|---|---|---|
pg init | initdb, i | Initialize data directory | Wraps initdb |
pg start | boot, up | Start PostgreSQL | Wraps pg_ctl start |
pg stop | halt, down | Stop PostgreSQL | Wraps pg_ctl stop |
pg restart | reboot | Restart PostgreSQL | Wraps pg_ctl restart |
pg reload | hup | Reload configuration | Wraps pg_ctl reload |
pg status | st, stat | Show service status | Shows processes & related services |
pg promote | pro | Promote replica to primary | Wraps pg_ctl promote |
pg role | r | Detect instance role | Outputs primary/replica |
Connection & Query:
| Command | Alias | Description | Notes |
|---|---|---|---|
pg psql | sql, connect | Connect to database | Wraps psql |
pg ps | activity, act | Show current connections | Queries pg_stat_activity |
pg kill | k | Terminate connections | Default dry-run mode |
pg clone | Clone a single database | CREATE DATABASE ... TEMPLATE ... FILE_COPY |
Database Maintenance:
| Command | Alias | Description | Notes |
|---|---|---|---|
pg vacuum | vac, vc | Vacuum tables | Wraps vacuumdb |
pg analyze | ana, az | Analyze tables | Wraps vacuumdb –analyze-only |
pg freeze | Freeze vacuum | Wraps vacuumdb –freeze | |
pg repack | rp | Online table repacking | Requires pg_repack extension |
Parameter Tuning:
| Command | Alias | Description | Notes |
|---|---|---|---|
pg tune | tuning | Generate PostgreSQL tuning parameters | Auto-detects hardware and supports structured output |
Instance Fork:
| Command | Alias | Description | Notes |
|---|---|---|---|
pg fork | Shortcut for fork init | Creates a managed fork by default, does not start it | |
pg fork init | create | Create a local one-off physical copy | Default /pg/data-<name> |
pg fork list | List managed forks | Scans /pg/data-* | |
pg fork start | Start an existing fork | Supports managed names or unmanaged --dst-data directories | |
pg fork stop | Stop an existing fork | Supports shutdown mode | |
pg fork rm | remove, delete | Remove a fork | Running forks require --stop |
Log Tools:
| Command | Alias | Description | Notes |
|---|---|---|---|
pg log | l | Log management | Parent command |
pg log list | ls | List log files | |
pg log tail | t, f | Real-time log viewing | tail -f |
pg log show | cat, c | Output log content | |
pg log less | vi, v | View with less | |
pg log grep | g, search | Search logs |
Service Subcommand (pg svc, also pg service or pg s):
| Command | Alias | Description |
|---|---|---|
pg svc start | boot, up | Start postgres service |
pg svc stop | halt, dn, down | Stop postgres service |
pg svc restart | reboot, rt | Restart postgres service |
pg svc reload | rl, hup | Reload postgres service |
pg svc status | st, stat | Show service status |
Quick Start
Global Options
These options apply to all pig pg subcommands:
| Option | Short | Default | Description |
|---|---|---|---|
--version | -v | auto-detect | PostgreSQL major version |
--data | -D | /pg/data | Data directory path |
--dbsu | -U | postgres | Database superuser (or $PIG_DBSU env) |
Systemd service operations use the dedicated pig pg svc ... commands; the local pg_ctl primitives do not have a global --systemd / -S switch.
Version Detection Logic:
- If
-vspecified, use that version - Otherwise read from
PG_VERSIONfile in data directory - If neither available, use default PostgreSQL in PATH
Service Control Commands
pg init
Initialize PostgreSQL data directory. Wraps initdb.
- Data checksums are enabled by default unless explicitly disabled with
-K|--no-data-checksums. - Prefer the platform-independent built-in
C.UTF-8locale on PG 17+, fall back to systemC.UTF-8/C, then system default locale. - If the data directory already exists, the command refuses to run unless
-f|--forceis used. If PostgreSQL is running on that data directory, it refuses even with--forceto prevent data loss. - Extra arguments after
--are passed toinitdb, for example--waldir=/wal. Useinitdbdirectly if you need to override locale or encoding options.
Options:
| Option | Short | Default | Description |
|---|---|---|---|
--no-data-checksums | -K | false | Disable data checksums |
--force | -f | false | Force init and remove existing data (dangerous!) |
--yes | -y | false | Skip overwrite confirmation when used with --force |
Safety: Even with --force, command refuses to run if PostgreSQL is running.
pg start
Start PostgreSQL with pg_ctl start. For a Patroni-managed instance, prefer pig pt start so PostgreSQL starts under Patroni. For a systemd-managed PostgreSQL service, use pig pg svc start.
Options:
| Option | Short | Description |
|---|---|---|
--log | -l | Redirect stdout/stderr to log file |
--timeout | -t | Wait timeout (seconds) |
--no-wait | Don’t wait for startup completion | |
--options | -O | Options to pass to postgres |
If PostgreSQL is already running, the command prints the existing postmaster PID and returns successfully.
pg stop
Stop PostgreSQL with pg_ctl stop.
On a Patroni-managed instance, stopping PostgreSQL directly can make Patroni restart it or initiate failover. Use pig pt stop or pig pt svc stop to stop Patroni and PostgreSQL together.
Options:
| Option | Short | Default | Description |
|---|---|---|---|
--mode | -m | fast | Shutdown mode: smart/fast/immediate |
--timeout | -t | 60 | Wait timeout (seconds) |
--no-wait | false | Don’t wait for shutdown completion | |
--plan | false | Preview local pg_ctl stop plan only |
Shutdown Modes:
| Mode | Description |
|---|---|
smart | Wait for all clients to disconnect |
fast | Rollback active transactions, disconnect clients, clean shutdown |
immediate | Terminate all processes immediately, requires recovery on next start |
pg restart
Restart PostgreSQL server.
Options: Same as pg stop, plus --options (-O) to pass to postgres.
pg reload
Reload PostgreSQL configuration. Sends SIGHUP signal to server.
pg status
Show PostgreSQL server status. Displays not only pg_ctl status output, but also postgres processes and Pigsty-related service status.
Output includes:
pg_ctl statusoutput (running status, PID, etc.)- PostgreSQL process list (
ps -u postgres) - Related service status:
postgres: PostgreSQL systemd servicepatroni: Patroni HA managerpgbouncer: Connection poolerpgbackrest: Backup servicevip-manager: VIP managerhaproxy: Load balancer
pg promote
Promote replica to primary.
Options:
| Option | Short | Description |
|---|---|---|
--timeout | -t | Wait timeout (seconds) |
--no-wait | Don’t wait for promotion completion | |
--plan | Preview promotion plan only | |
--yes | -y | Skip confirmation prompt |
pg role
Detect PostgreSQL instance role (primary or replica).
Options:
| Option | Short | Description |
|---|---|---|
--verbose | -V | Show detailed detection process |
Output:
primary: Current instance is primaryreplica: Current instance is replicaunknown: Cannot determine instance role
Detection Strategy (by priority):
- Process detection: Check for
walreceiver,recoveryprocesses - SQL query: Execute
pg_is_in_recovery()(requires PostgreSQL running) - Data directory check: Check for
standby.signal,recovery.signal,recovery.conffiles
Connection & Query Commands
pg psql
Connect to PostgreSQL database via psql.
Options:
| Option | Short | Description |
|---|---|---|
--command | -c | Execute single SQL command |
--file | -f | Execute SQL script file |
When the global -D/--data option is specified, pg psql reads postmaster.pid from that directory as the database superuser and connects with the recorded port and Unix socket directory. If the postmaster information cannot be read or parsed, the command fails instead of silently connecting to the default instance.
pg ps
Show PostgreSQL current connections. Queries pg_stat_activity view.
Options:
| Option | Short | Description |
|---|---|---|
--all | -a | Show all connections (including system) |
--user | -u | Filter by user |
--database | -d | Filter by database |
pg kill
Terminate PostgreSQL connections. Default is dry-run mode, requires -x to execute.
Options:
| Option | Short | Description |
|---|---|---|
--execute | -x | Actually execute (default is dry-run) |
--pid | Terminate specific PID | |
--user | -u | Filter by user |
--database | -d | Filter by database |
--state | -s | Filter by state (idle/active/idle in transaction) |
--query | -q | Filter by query pattern |
--all | -a | Include replication connections |
--cancel | -c | Cancel queries instead of terminating |
--watch | Repeat every N seconds | |
--plan | Preview execution plan without terminating connections |
Security: --state and --query parameters are validated to accept only simple alphanumeric patterns, preventing SQL injection.
pg clone
Clone a database inside the current PostgreSQL instance. This command wraps CREATE DATABASE ... TEMPLATE ... STRATEGY FILE_COPY, terminates existing sessions on the source database before cloning, and follows the same semantics as Pigsty’s pgsql-db clone workflow.
Options:
| Option | Short | Description |
|---|---|---|
--port | PostgreSQL port, default 5432 or $PG_PORT | |
--conn-db | Database used to execute CREATE DATABASE; defaults to template1 when cloning postgres | |
--owner | Try to change the owner of the cloned database | |
--conn-limit | Connection limit for the new database (-1 unlimited, 0 disallow connections) | |
--plan | Show execution plan only | |
--yes | -y | Skip confirmation prompt |
Notes: On PostgreSQL 18+ with file_copy_method=clone, database cloning can use CoW semantics; otherwise it falls back to ordinary file copy. This command clones a single database and does not create a new PostgreSQL instance.
Database Maintenance Commands
pg vacuum
Vacuum database tables. Wraps vacuumdb.
Options:
| Option | Short | Description |
|---|---|---|
--all | -a | Process all databases |
--schema | Specify schema | |
--table | -t | Specify table |
--verbose | -V | Verbose output |
--full | -F | VACUUM FULL (requires exclusive lock) |
Security: --schema and --table parameters are validated for proper PostgreSQL identifier format.
pg analyze
Analyze database tables to update statistics.
Options: Same as pg vacuum (without --full).
pg freeze
Freeze vacuum database to prevent transaction ID wraparound.
Options: Same as pg analyze.
pg repack
Online table repacking. Requires pg_repack extension.
Options:
| Option | Short | Description |
|---|---|---|
--all | -a | Process all databases |
--schema | Specify schema | |
--table | -t | Specify table |
--verbose | -V | Verbose output |
--jobs | -j | Number of parallel jobs (default 1) |
--plan | Show tables to be repacked |
Parameter Tuning Commands
pg tune
Generate a recommended set of PostgreSQL parameters based on the current PostgreSQL major version, host hardware, and workload profile. By default, it auto-detects CPU, memory, and data disk size, then prints the result as text output.
Options:
| Option | Short | Default | Description |
|---|---|---|---|
--profile | -p | oltp | Tuning profile: oltp / olap / tiny / crit |
--cpu | -c | 0 | CPU cores, 0 means auto-detect |
--mem | -m | 0 | Total memory in MB, 0 means auto-detect |
--disk | -d | 0 | Data disk size in GB, 0 means auto-detect |
--max-conn | -C | 0 | Override max_connections, 0 uses profile default |
--shmem-ratio | -R | 0.25 | Fraction of memory used for shared_buffers, range 0.1 ~ 0.4 |
Profiles:
| Profile | Best for | Characteristics |
|---|---|---|
oltp | General transactional workloads | Balanced connection count, cache, and parallelism |
olap | Analytical workloads | More aggressive parallelism and work memory |
tiny | Small instances | Constrained memory footprint and parallelism |
crit | Latency-sensitive workloads | Restricts parallel gather and favors stable response time |
Notes:
- Generated parameters are automatically gated by PostgreSQL major version. For example,
io_workersis only emitted for PG 18+. - Text output can be redirected into a config snippet, while structured output is better suited for automation.
- The command currently generates recommendations only; it does not modify PostgreSQL configuration files directly.
Instance Fork
pg fork
Create a local one-off PostgreSQL physical copy for temporary analysis, troubleshooting, recovery validation, and development testing. Managed forks are written to /pg/data-<name> by default and are not registered with Pigsty, systemd, or Patroni. When --dst-data is specified explicitly, the command creates an unmanaged fork that is not enumerated by fork list.
Create Options:
| Option | Short | Default | Description |
|---|---|---|---|
--dst-data | /pg/data-<name> | Unmanaged target data directory | |
--dst-port | auto-detect | Target port, probes free ports starting at 15432 | |
--src-data | /pg/data or $PG_DATA | Source data directory; can also be set globally with pg -D/--data | |
--src-port | 5432 or $PG_PORT | Source port | |
--start | -s | false | Start the fork after creation |
--force | -f | false | Overwrite an existing stopped target directory and skip confirmation |
--timeout | -t | 60 | Startup wait timeout in seconds |
--yes | -y | false | Skip confirmation prompt |
--plan | false | Show execution plan only |
Management Commands:
| Command | Common Options | Description |
|---|---|---|
pig pg fork list | -o json/yaml | List managed forks with optional structured output |
pig pg fork start <name> or --dst-data <dir> | --dst-data, --dst-port, -t/--timeout, --plan | Start existing fork |
pig pg fork stop <name> or --dst-data <dir> | --dst-data, -m/--mode, -t/--timeout, --plan | Stop existing fork |
pig pg fork rm <name> or --dst-data <dir> | --dst-data, --stop, -m/--mode, -t/--timeout, -f/--force, -y/--yes, --plan | Remove fork; running forks require --stop |
Behavior Notes:
- When the source instance is running, the command uses PostgreSQL low-level backup APIs to create a consistent physical copy; when the source is stopped, it can perform a cold copy.
- The command prefers CoW/reflink. If only ordinary copy is available, interactive mode warns about disk-space risk and waits for confirmation.
- To avoid deleting source data by mistake, the target directory cannot be
/,/pg, source PGDATA, or a parent/child of source PGDATA. Symlinks are resolved before checks. - After copy, runtime and replication state is cleaned from the fork and
fork.jsonis written. The new instance starts only when-s|--startis specified. - Managed forks must be managed by name. Unmanaged forks require
--dst-datawhen starting, stopping, or removing.
List Forks:
pig pg fork list scans /pg/data-*, reads fork.json, and refreshes each managed fork’s runtime state. Text output shows NAME, PORT, STATE, PID, AGE, SOURCE, COPY, and DATA; state is reported as running, stopped, or orphan.
JSON and YAML output return the full machine-readable fork objects, including source and target endpoints, copy and backup metadata, management commands, and Pig build metadata.
Structured Output:
Log Commands
Log commands view PostgreSQL log files. Default log directory is /pg/log/postgres, can be changed via --log-dir.
Log Command Global Options:
| Option | Description |
|---|---|
--log-dir | Log directory path (default: /pg/log/postgres) |
--lines / -n | Number of lines to show, default 50 |
--follow / -f | Follow latest log, only on parent pg log |
Permission Handling: If current user lacks permission to read log directory, command automatically retries with sudo. -o json emits JSONL log records; log snapshots do not support yaml or json-pretty.
pg log
Show the latest log snapshot; with -f, follow the latest log.
pg log list
List log files in log directory.
pg log tail
Real-time log viewing (like tail -f). Default views latest CSV log file.
Options:
| Option | Short | Default | Description |
|---|---|---|---|
--lines | -n | 50 | Number of lines to show |
pg log show
Output log file content.
Options:
| Option | Short | Default | Description |
|---|---|---|---|
--lines | -n | 50 | Number of lines to show |
pg log less
Open log file with less. Defaults to end of file (+G).
pg log grep
Search log file content.
Options:
| Option | Short | Description |
|---|---|---|
--ignore-case | Ignore case | |
--context | -C | Show context lines |
pg svc Subcommand
pg svc (also pg service or pg s) provides systemctl-based PostgreSQL service management:
Alias Reference:
| Command | Alias |
|---|---|
pg svc start | boot, up |
pg svc stop | halt, dn, down |
pg svc restart | reboot, rt |
pg svc reload | rl, hup |
pg svc status | st, stat |
Design Notes
Relationship with Native Tools:
pig pg is not a simple wrapper of PostgreSQL native tools, but a higher-level abstraction for common operations:
- Service control commands (init/start/stop/restart/reload/promote) call
pg_ctl statuscommand shows process and related service status beyondpg_ctl status- Connection management commands (psql/ps/kill) call
psql clonecommand uses SQL to create a database copy- Maintenance commands (vacuum/analyze/freeze) call
vacuumdb - repack command calls
pg_repack forkcommand uses PostgreSQL low-level backup APIs and local file copy to create one-off physical copies- Log commands call system tools like
tail,less,grep
For full native tool functionality, call the respective commands directly.
Security Considerations:
--state,--query,--schema,--tableparameters are validated to prevent SQL injectionpg killdefaults to dry-run mode to prevent accidentspg cloneterminates existing sessions on the source database; use it during a maintenance windowpg forkrejects dangerous target paths; ordinary-copy fallback warns about disk-space risk- Log commands auto-retry with sudo when permissions insufficient
Platform Support:
This command is designed for Linux systems. Some features depend on systemctl, and log commands depend on readable PostgreSQL log files plus common tools such as tail, less, and grep.
12 - pig patroni
Since v1.6.0, the pig patroni command (alias pig pt) is a transparent launcher for the
installed patronictl binary: pig only owns config-file selection and a few local helpers,
while every other command and all of its arguments are forwarded unchanged to patronictl —
with native flags, prompts, output, and exit codes. New patronictl features work without
waiting for a pig release.
The first non-option command token decides the dispatch:
set,start/up,stop/dn,service/svc,status/st, andlog/lselect pig’s local implementation;- every other token (
list,restart,reload,reinit,switchover,failover,pause,resume,show-config,edit-config,query,history,topology,dsn,version, …) and everything after it is forwarded verbatim topatronictl; pig pt -- <command> ...bypasses local-name collisions (e.g.pig pt -- sethandssetto patronictl);pig ptwith no command prints pig’s help and does not run patronictl; usepig pt <command> --helpfor native subcommand help andpig pt -- --helpfor patronictl root help.
Command Overview
Forwarded commands (native patronictl):
| Example | Description |
|---|---|
pig pt list [CLUSTER] | List cluster members (native output, --format json) |
pig pt restart CLUSTER [MEMBER] | Restart PostgreSQL of a cluster / member (native prompt) |
pig pt reload CLUSTER | Reload PostgreSQL configuration |
pig pt reinit CLUSTER MEMBER | Reinitialize a member (resync from primary) |
pig pt switchover CLUSTER [--candidate X] | Planned switchover |
pig pt failover CLUSTER --candidate MEMBER | Manual failover (positional arg is the cluster) |
pig pt pause / resume CLUSTER | Enter / leave maintenance mode |
pig pt show-config / edit-config | Show / edit cluster dynamic configuration |
pig pt query -c 'select 1' | Native query (-c here is query’s own SQL option) |
Forwarded positionals follow patronictl’s native cluster-first semantics; confirmation
prompts, output formats, and exit codes (including Click usage-error exit code 2) are all
owned by patronictl.
Local commands (implemented by pig):
| Command | Alias | Description |
|---|---|---|
pt set | Update PostgreSQL params or scalar Patroni settings | |
pt status | st | Combined status: systemd + processes + cluster |
pt service | svc | Manage the local patroni systemd service |
pt start | up | Hidden shortcut for pt svc start |
pt stop | dn | Hidden shortcut for pt svc stop |
pt log | l | View local Patroni logs (show / tail / grep) |
Note: top-level pt restart is not a daemon shortcut — it forwards to
patronictl restart (restarting PostgreSQL). Use pt svc restart to restart
the patroni daemon itself.
Quick Start
Pig/PT Options
These wrapper-level options must precede the native command; once the native command token appears, all remaining tokens belong to patronictl:
| Option | Short | Description |
|---|---|---|
--config-file | -c | Explicit Patroni/patronictl configuration file |
--dbsu | OS user used to execute patronictl (default $PIG_DBSU or postgres) | |
--dcs-url | -d | Override the Patroni DCS URL (--dcs is an alias) |
--insecure | -k | Allow TLS without certificate verification |
Since v1.6.0,
--dbsuno longer has the-Ushorthand (thepg/pbcommands keep it).
Config-File Resolution
Every config-aware patronictl invocation receives exactly one pig-selected root -c <path>,
resolved in this order:
- explicit
-c/--config-filegiven before the command; - non-empty
PATRONICTL_CONFIG_FILEenvironment variable; /etc/patroni/patroni.yml(exists and readable as the DBSU);/infra/conf/patronictl.yml(exists and readable as the DBSU);- fallback to
/etc/patroni/patroni.yml, so patronictl’s error names the conventional path.
Explicit and environment paths are authoritative: pig does not silently substitute another
candidate when they are missing or unreadable; relative paths are made absolute before
switching OS user. Conventional candidates are probed for readability as the resolved DBSU
(not by mode bits). Resolution is lazy: pure systemd operations like pt svc start never
probe a config, and native -h/--help takes a config-independent fast path that works on
machines without Patroni configured.
Transparent Execution and Output Modes
Forwarded execution directly inherits stdin / stdout / stderr and the terminal: native
prompts, the edit-config editor, --watch streaming, and exit codes are all preserved.
Pig performs no output capture, no duplicate error rendering, no retries, and no cluster/DCS
reads before or after execution. The logical invocation is:
Structured output: the forwarding path supports pig’s text mode only. A pig
-o json / -o yaml placed before the native command is rejected (with guidance to use
patronictl’s native output options); anything after the native command is forwarded as-is
and validated by patronictl:
Local commands (set / status / log / service) keep pig’s structured output behavior.
pig pt set
pt set is the only local configuration sugar; it edits the cluster selected by the
resolved configuration:
Key classification:
- These scalar Patroni dynamic keys translate to native
--set:loop_wait,ttl,retry_timeout,primary_race_backoff,maximum_lag_on_failover,maximum_lag_on_syncnode,max_timelines_history,primary_start_timeout,primary_stop_timeout,synchronous_mode,synchronous_mode_strict,synchronous_node_count,failsafe_mode,check_timeline,member_slots_ttl(pauseis deliberately excluded — use nativepause/resume); - every other key is treated as a PostgreSQL parameter and translates to native
--pg(including dotted custom GUCs liketimescaledb.telemetry_level); - structural keys starting with
postgresql.,standby_cluster.,slots., orignore_slots.are rejected, pointing to nativepig pt edit-config --set.
All pairs merge into one native edit-config call in input order — one diff, one
confirmation, one DCS update:
--yes/-yappends native--forceto skip confirmation; otherwise patronictl shows the diff and owns confirmation;--planmutates nothing and renders the selected config plus the translated native command (plans may contain sensitive values);- in structured output mode, execution requires an explicit
--yes(hidden prompts are forbidden); - values parse as YAML: both
KEY=nullandKEY=remove a key, passed unchanged; - after changing restart-required PostgreSQL parameters, pig suggests the follow-up:
first
pig pt list, thenpig pt restart CLUSTER --pending(explicit cluster required).
Service Management
pt service (alias pt svc) manages the local patroni systemd unit:
| Command | Alias | Description |
|---|---|---|
pt service start | pt svc up | Start the Patroni service |
pt service stop | pt svc dn | Stop the Patroni service |
pt service restart | pt svc rs | Restart the Patroni service |
pt service reload | pt svc rl | Reload the Patroni service |
pt service status | pt svc st | Show service status |
Top-level pt start / pt stop (aliases up / dn) are hidden shortcuts to the same
local implementation. Stopping the Patroni service may also stop PostgreSQL on this node
(depending on Patroni configuration).
pt status
Shows combined status: systemd service state, Patroni process info, and cluster members from patronictl.
pt log
View local Patroni logs. The log directory comes from log.dir in the selected config,
falling back to /pg/log/patroni, or set it explicitly with --log-dir. Only pt log and
pt log show support -o json (JSONL snapshot); follow / tail / grep are terminal streams
without structured output.
| Subcommand | Aliases | Description |
|---|---|---|
show | cat, c, s | Print recent Patroni logs |
tail | t, f, follow | Follow Patroni logs |
grep | g, search | Search Patroni logs |
| Option | Short | Default | Description |
|---|---|---|---|
--follow | -f | false | Follow log output |
--lines | -n | 50 | Number of lines shown |
--log-dir | auto | Log directory |
Migrating from v1.5.x
The v1.6.0 passthrough rewrite is a breaking change — review automation before upgrading:
| v1.5.x usage | v1.6.0 usage |
|---|---|
pig pt failover <candidate> | ⚠ pig pt failover CLUSTER --candidate MEMBER (the positional is now the cluster) |
pig pt restart [member] (auto scope) | pig pt restart CLUSTER [MEMBER] (explicit cluster) |
pig pt list -o json | pig pt list --format json (native JSON, different schema) |
pig pt config show | pig pt show-config |
pig pt config edit | pig pt edit-config |
pig pt config set K=V / pg K=V | pig pt set K=V |
pig pt restart -y (pig gate) | native patronictl confirmation; pt set -y still works |
pig pt list -W / -w 5 | native pig pt list --watch (patronictl semantics) |
aliases ls/rs/rl/ri/so/fo/p/r/c | removed — use full native command names |
--dbsu -U | --dbsu (-U shorthand removed) |
Also: forwarded commands return native patronictl exit codes (usage errors exit 2), and
the pig-side pause-guard preflight for switchover/failover is gone — maintenance-mode
semantics are fully owned by Patroni.
Design Notes
Single authority: there is one cluster-control path — the installed patronictl plus
one selected config, acting through the Patroni REST API / DCS. Pig embeds no DCS client or
REST control engine, keeps no patronictl command inventory, and adds no confirmation,
preflight, retry, or output rewriting to forwarded commands.
Privilege handling (unchanged from v1.5.x):
- if the current user is already the DBSU: execute directly;
- if the current user is root: execute via
su - postgres -c "..."; - otherwise: execute via
sudo -inu postgres -- ....
Platform: designed for Linux; service management relies on systemctl, and the log
helpers require readable Patroni log files.
13 - pig pgbackrest
The pig pgbackrest command (alias pig pb) manages pgBackRest backups and provides low-level restore primitives.
It wraps common pgbackrest operations for a simplified backup management experience. All commands run as the database superuser (default postgres).
For orchestrated point-in-time recovery on managed clusters, prefer pig pitr.
Command Overview
Information Query:
| Command | Alias | Description | Implementation |
|---|---|---|---|
pb info | i | Show backup repository info | pgbackrest info |
pb list | ls | List backup sets, repos, and stanzas | pgbackrest info |
Backup & Restore:
| Command | Alias | Description | Implementation |
|---|---|---|---|
pb backup | b | Create backup | pgbackrest backup |
pb restore | r | Low-level restore primitive | pgbackrest restore |
pb expire | e | Clean up expired backups | pgbackrest expire |
Stanza Management:
| Command | Alias | Description | Implementation |
|---|---|---|---|
pb create | c | Create stanza (first-time setup) | pgbackrest stanza-create |
pb upgrade | u | Upgrade stanza after PG major upgrade | pgbackrest stanza-upgrade |
pb delete | d | Delete stanza (dangerous!) | pgbackrest stanza-delete |
Control Commands:
| Command | Alias | Description | Implementation |
|---|---|---|---|
pb check | ck | Verify backup repository integrity | pgbackrest check |
pb start | up | Enable pgBackRest operations | pgbackrest start |
pb stop | dw | Disable pgBackRest operations | pgbackrest stop |
pb log | l | View logs | latest log snapshot / tail |
Quick Start
Global Options
These options apply to all pig pb subcommands:
| Option | Short | Description |
|---|---|---|
--stanza | -s | pgBackRest stanza name (auto-detected) |
--config | -c | Config file path |
--repo | -r | Repository number (multi-repo scenario) |
--dbsu | -U | Database superuser (default: $PIG_DBSU or postgres) |
Stanza Auto-Detection:
If -s is not specified, pig auto-detects the stanza name from the config file:
- Read the config file (default
/etc/pgbackrest/pgbackrest.conf) - Find sections that do not start with
[global*] - Use the first stanza found
If the config file contains multiple stanzas, pig emits a warning and uses the first one. In that case, specify --stanza explicitly.
Multi-Repo Support:
pgBackRest supports multiple repositories (repo1, repo2, etc.). Use -r to choose the target repository:
Information Commands
pb info
Show detailed backup repository information, including all backup sets and WAL archive status.
Options:
| Option | Short | Description |
|---|---|---|
--raw | -R | Raw output mode (passes through pgBackRest output) |
--raw-output | Raw output format: text, json (only in --raw mode) | |
--set | Show details for a specific backup set |
pb ls
List resources in the backup repository.
Types:
| Type | Description | Data Source |
|---|---|---|
| backup | List all backup sets (default) | pgbackrest info |
| repo | List configured repos | Parse pgbackrest.conf |
| stanza | List all stanzas | Parse pgbackrest.conf |
Backup Commands
pb backup
Create a physical backup. Backups can only run on the primary instance.
Options:
| Option | Short | Description |
|---|---|---|
--force | -f | Skip primary role check |
Backup Types:
| Type | Description |
|---|---|
| (empty) | Auto mode: full if no backup exists, otherwise incremental |
| full | Full backup: backup all data |
| diff | Differential backup: changes since the last full backup |
| incr | Incremental backup: changes since the last backup of any type |
Primary Check:
Before running a backup, the command automatically checks whether the current instance is primary. If it is a replica, the command exits with an error. Use --force to skip this check.
pb expire
Clean up expired backups and WAL archives according to the retention policy.
Options:
| Option | Short | Description |
|---|---|---|
--set | Delete a specific backup set | |
--plan | Preview cleanup plan only, do not delete backups | |
--yes | -y | Skip confirmation prompt when used with --set |
Retention Policy:
Retention policy is configured in pgbackrest.conf:
Restore Commands
pb restore
Restore from backup with recovery target support.
At least one recovery target (-d/-I/-t/--name/--lsn/--xid) must be specified explicitly. Without parameters, help is shown.
Recovery Target Options:
| Option | Short | Description |
|---|---|---|
--default | -d | Restore to end of WAL stream (latest data) |
--immediate | -I | Restore to backup consistency point |
--time | -t | Restore to specific timestamp |
--name | Restore to named restore point | |
--lsn | Restore to specific LSN | |
--xid | Restore to specific transaction ID |
Backup Set and Other Options:
| Option | Short | Description |
|---|---|---|
--set | -b | Restore from a specific backup set (can combine with target) |
--data | -D | Target data directory |
--exclusive | -X | Exclusive mode: stop before target |
--target-action | Action after reaching recovery target: pause/promote/shutdown | |
--target-timeline | -T | Recovery timeline: latest/current/N/0xN |
--plan | Preview restore plan only, do not execute | |
--yes | -y | Skip interactive y/yes confirmation |
Native args after -- | Pass through pgBackRest restore args, for example -- --delta |
Combination Rules: --target-action cannot be used with --default, because --default already means recovery to the end of the WAL stream. --exclusive/-X must be used with an explicit stop target: --time, --lsn, or --xid.
Native pgBackRest restore args after -- cannot override recovery targets, lifecycle, data directory, repository, config, or selection semantics already managed by Pig. Use Pig’s first-class options for those semantics. Tablespace/link migration options such as --tablespace-map, --link-map, and --link-all can still be passed through.
Time Formats:
Supports multiple time formats and auto-completes timezones (including non-integer-hour zones such as +05:30):
| Format | Example | Description |
|---|---|---|
| Full format | 2025-01-01 12:00:00+08 | Complete timestamp with timezone |
| Date only | 2025-01-01 | Auto-completes to 00:00:00 that day (current timezone) |
| Time only | 12:00:00 | Auto-completes to today (current timezone) |
Restore Flow:
- Validate parameters and environment
- Check that PostgreSQL is stopped
- Show restore plan and wait for interactive
y/yesconfirmation - Execute pgbackrest restore
- Provide post-restore guidance
Important: Stop PostgreSQL before restore. If the PGDATA is managed by Patroni, use pig pitr to orchestrate Patroni, PostgreSQL, and pgBackRest:
Stanza Management Commands
pb create
Initialize a new stanza. Must run before the first backup.
Options:
| Option | Short | Description |
|---|---|---|
--no-online | Create when PostgreSQL is not running | |
--force | -f | Force create |
pb upgrade
Update stanza after a PostgreSQL major version upgrade.
Options:
| Option | Description |
|---|---|
--no-online | Upgrade when PostgreSQL is not running |
Use Case:
After a PostgreSQL major version upgrade (for example, 16 -> 17), run this command to update stanza metadata.
pb delete
Delete a stanza and all its backups.
Options:
| Option | Short | Description |
|---|---|---|
--plan | Preview delete plan only, do not execute | |
--yes | -y | Skip interactive y/yes confirmation |
Warning: This is a destructive and irreversible operation. All backups will be permanently deleted.
The command includes multiple safety mechanisms:
- In text mode, it requires interactive
y/yesconfirmation unless--yesis specified - Structured output mode requires explicit
--yes - If the config file contains multiple stanzas and
--stanzais not specified, pig refuses to auto-select a deletion target
Control Commands
pb check
Verify backup repository integrity and configuration.
This command checks:
- WAL archive configuration correctness
- Repository accessibility
- Stanza configuration validity
pb start
Enable pgBackRest operations.
Use this command after pb stop to resume normal operations.
pb stop
Disable pgBackRest operations for maintenance.
Options:
| Option | Short | Description |
|---|---|---|
--force | -f | Terminate running operations |
Use Case:
Use this command during system maintenance to prevent new backup operations from starting.
Log Commands
pb log
View pgBackRest log files. The log directory is read from pgBackRest config log-path first, and falls back to /pg/log/pgbackrest/ when not configured. The parent command shows the latest log snapshot by default; use tail or -f for live follow. Only pb log and pb log show support -o json JSONL output; log snapshots do not support yaml or json-pretty, and follow/tail does not support structured output.
Subcommands:
| Subcommand | Aliases | Description |
|---|---|---|
| list | ls | List log files |
| show | cat, c | Show latest log content |
| tail | t, f, follow | Real-time follow latest log |
Options:
| Option | Short | Default | Description |
|---|---|---|---|
--lines | -n | 50 | Number of lines to show |
--follow | -f | false | Makes parent command pb log follow; no-op in pb log tail because tail always follows |
Permission Handling:
If the current user does not have permission to read the log directory, the command automatically retries with sudo.
Design Notes
Command Execution:
All pig pb commands run as the database superuser (DBSU), because pgBackRest needs access to PostgreSQL data files and WAL archives.
Execution logic:
- If the current user is DBSU: execute directly
- If the current user is root: use
su - postgres -c "..."to execute - Other users: use
sudo -inu postgres -- ...to execute
Relationship with pgbackrest:
pig pb is not a complete wrapper for pgbackrest; it is a higher-level abstraction for common operations:
- Auto-detect stanza name without specifying it every time
- Auto-check primary role before backup
- Show restore plan and require interactive
y/yesconfirmation before restore - Provide user-friendly time format input
- Provide post-restore guidance
For full pgbackrest functionality, use the pgbackrest command directly.
Default Configuration Paths:
| Config | Default |
|---|---|
| Config file | /etc/pgbackrest/pgbackrest.conf |
| Log directory | /pg/log/pgbackrest |
| Data directory | pg1-path from config, or $PGDATA, or /pg/data |
Security Considerations:
pb deleterequires interactivey/yesconfirmation when--yesis not specified, and--stanzamust be explicit under multi-stanza configspb restorerequires an explicit recovery target, validates--time, and requires interactivey/yesconfirmation when--yesis not specifiedpb backupchecks primary role by default to prevent running on a replicapb log taildoes not support structured output; usepb log show -n N -o jsonwhen a JSONL snapshot is required
Platform Support:
This command is designed for Linux systems and depends on Pigsty’s default directory layout.
14 - pig pitr
The pig pitr command performs point-in-time recovery through pgBackRest and conservatively handles the local PostgreSQL and Patroni lifecycle. Unlike the lower-level pig pb restore, pig pitr runs pre-restore checks, stops Patroni and PostgreSQL when needed, executes restore, then decides whether to start PostgreSQL based on the selected options.
Note: for a managed default data directory, pig pitr leaves Patroni stopped after recovery. Validate the restored result first, then manually restore Patroni management. This command does not automatically rejoin a Patroni cluster, perform failover, or validate cluster member state.
Overview
The default target of pig pitr is the Pigsty-managed primary data directory. A typical workflow:
- Validate recovery target parameters. One of
-d/-I/-t/--name/--lsn/--xidis required. - Resolve pgBackRest configuration and target data directory.
- For default data-directory recovery, stop Patroni if it is running.
- Ensure PostgreSQL is stopped.
- Run
pgbackrest restore. - Start PostgreSQL unless
--no-restartis specified. - Print post-recovery validation and Patroni recovery guidance.
Comparison with pig pb restore:
| Feature | pig pitr | pig pb restore |
|---|---|---|
| Stop Patroni | Automatic for default data-directory recovery | Manual |
| Stop PostgreSQL | Checks and stops automatically | Must be pre-stopped |
| Start PostgreSQL | Automatic by default, can be disabled with --no-restart | Manual |
| Patroni recovery | Not automatic; restore manually after verification | Not handled |
| Use case | Production recovery orchestration | Low-level restore or scripting |
Quick Start
Parameters
Recovery Target
At least one recovery target is required.
| Parameter | Short | Description |
|---|---|---|
--default | -d | Recover to the end of the WAL stream, the latest data |
--immediate | -I | Recover to the backup consistency point |
--time | -t | Recover to a specific timestamp |
--name | Recover to a named restore point | |
--lsn | Recover to a specific LSN | |
--xid | Recover to a specific transaction ID |
Backup And Target Options
| Parameter | Short | Description |
|---|---|---|
--set | -b | Start recovery from a specific backup set |
--target-action | Action when the recovery target is reached: pause/promote/shutdown | |
--target-timeline | -T | Recovery timeline: latest/current/N/0xN |
--exclusive | -X | Exclusive mode: stop before target |
Use --target-action=shutdown with --no-restart, because PostgreSQL exits after reaching that recovery target. --target-action cannot be used with --default, because --default already means recovery to the end of WAL. --exclusive/-X requires a precise stop-before target: --time, --lsn, or --xid.
Native pgBackRest restore arguments after -- cannot override recovery target, lifecycle, data directory, repository, config, or selection parameters managed by Pig. Use Pig’s first-class parameters for these semantics. This restriction is consistent with the pig pb restore passthrough blocklist.
Flow Control
| Parameter | Short | Description |
|---|---|---|
--no-restart | Do not start PostgreSQL after restore | |
--plan | Show execution plan only, do not execute | |
--yes | -y | Skip interactive y/yes confirmation |
--timeout | PostgreSQL startup/recovery wait timeout, default 120 seconds | |
--force-stop | Allow immediate shutdown and kill fallback if fast stop fails |
Configuration
| Parameter | Short | Description |
|---|---|---|
--stanza | -s | pgBackRest stanza name |
--config | -c | pgBackRest config file path |
--repo | -r | Repository number |
--dbsu | -U | Database superuser, default postgres |
--data | -D | Target data directory |
Time Format
The --time parameter supports multiple formats and completes missing parts using the current timezone:
| Format | Example | Description |
|---|---|---|
| Full | 2025-01-01 12:00:00+08 | Complete timestamp with timezone |
| Date time without timezone | 2025-01-01 12:00:00 | Adds the current local timezone automatically; T separator is also accepted |
| Date only | 2025-01-01 | Completes to 00:00:00 on that date |
| Time only | 12:00:00 | Completes to that time today |
Plan output and replayable next-action commands normalize date-only and time-only targets into deterministic timestamps with timezone. This rule is consistent with pig pb restore --plan.
Managed Directory And Side Restore
The managed PostgreSQL data directory comes from the effective pgBackRest pg1-path and command parameters. It is not hardcoded to /pg/data. For example, if managed PGDATA is /var/lib/pgsql/18/data, the command still treats it as a managed restore. Path comparison resolves symlinks as the database superuser when needed, so a symlink to managed PGDATA is not mistaken for a side restore.
An explicit -D/--data that resolves to a path different from the managed directory is a side restore. Side restores must use --no-restart; they do not stop Patroni and do not manage the default PostgreSQL service. After restore, handle the side instance manually with commands such as pg_ctl -D <dir> -o "-p 5433" start, pg_ctl -D <dir> status, and pgbackrest --pg1-path=<dir> stanza-create. The side-restore directory must already exist and be owned by the DBSU. Unlike managed PGDATA, it does not need a pre-existing PG_VERSION marker. Pig does not create this directory automatically because it needs a concrete path for destructive-restore classification, owner checks, and safe guidance before restore.
For managed PGDATA outside /pg/data, post-restore runbook commands explicitly include the effective data directory:
pig pg psql -D <dir> reads postmaster.pid under that directory and uses the recorded port and socket directory to connect to the restored instance. If postmaster information cannot be resolved, it does not silently fall back to the default connection target.
Execution Flow
Phase 1: Pre-Checks
- Validate recovery target parameters; missing targets only print help and return an error.
- Resolve effective pgBackRest config, stanza, repository, and managed
pg1-path. - Check that the managed data directory exists and is initialized.
- For side restore, check that the custom data directory exists and is owned by the DBSU.
- Verify the selected stanza is healthy and has backups; if
--setis specified, verify that backup set exists. - Detect Patroni service state and PostgreSQL runtime state.
Phase 2: Patroni Handling
For managed data-directory recovery, if Patroni is running, the command stops Patroni so the target PGDATA stays offline during restore. Patroni remains stopped after recovery. A custom -D side restore does not touch the managed data directory and therefore does not stop Patroni.
Phase 3: Ensure PostgreSQL Is Stopped
The command first waits for PostgreSQL to exit after Patroni stops, then retries pg_ctl stop -m fast. If PostgreSQL still cannot stop, it does not use more aggressive methods by default. Only explicit --force-stop allows immediate shutdown and final kill fallback.
Phase 4: Restore
The command runs pgBackRest restore and maps recovery target, backup set, timeline, target action, and related options into pgbackrest restore. Native pgBackRest arguments can be placed after --:
Phase 5: Start Or Stay Stopped
Unless --no-restart is specified, the command starts PostgreSQL after restore and waits for recovery completion. For --default and --target-action=promote, it waits until pg_is_in_recovery() becomes false on the recovered instance. Recovery and subsequent SQL probes bind to the port recorded in postmaster.pid for the restored data directory and use the socket directory there when present. Use --no-restart when:
- Running a custom
-Dside restore, because the restored config still keeps the original port and must be started manually on a free port. - Using
--target-action=shutdown, because PostgreSQL exits after reaching the recovery target. - You need to inspect the restored directory before deciding whether to start.
Examples
Scenario 1: Recover Dropped Data
Scenario 2: Recover To Latest
Scenario 3: Recover To Backup Consistency Point
Scenario 4: Keep Stopped After Restore
Scenario 5: Custom Directory Side Restore
Execution Plan Example
Running pig pitr -d --plan shows a plan like:
Post-Recovery Actions
After successful recovery, verify data before restoring orchestration:
Leaving Patroni stopped after managed data-directory recovery is intentional. It prevents restored old state from re-entering HA orchestration before validation.
Safety Mechanisms
Recovery target required: Without -d/-I/-t/--name/--lsn/--xid, the command only shows help and does not run restore.
Confirmation: In text mode, destructive recovery asks for interactive y/yes confirmation before execution. Automation can use -y|--yes. Structured output mode does not prompt interactively; it must use --yes to execute or --plan to preview.
Patroni boundary: For managed data-directory recovery, the command stops Patroni when needed to prevent Patroni from restarting PostgreSQL during restore. It does not automatically rejoin Patroni after recovery.
Side restore boundary: A custom -D side restore must use --no-restart because the restored PostgreSQL config still uses the original port. Side restore does not manage Patroni or the default PostgreSQL service.
Failure boundary: If restore fails after Patroni has been stopped, Patroni remains stopped and the target data directory may be partially restored. Fix the underlying issue and rerun PITR, or validate the recovery state first; do not start Patroni before confirmation. If restore has run but PostgreSQL startup fails, inspect PostgreSQL and pgBackRest logs and validate the data directory before deciding whether to restore Patroni management.
Structured output: Structured execution requires --yes; --plan is the preview path. After successful execution, structured PITR results put post-restore actions in the Result envelope’s next_actions, not inside data. data includes requested_data_dir, effective_data_dir, managed_data_dir, and side_restore so automation can distinguish user input from the actual recovery target.
Design Notes
pig pitrcalls pgBackRest restore and handles local Patroni/PostgreSQL stop and optional start.pig pitris not a cluster recovery controller. It does not handle Patroni failover, rejoin, VIP, or application traffic switching.- Use
pig pb restorewhen you need lower-level restore semantics or fine-grained scripting control. - Use
pig pt switchover CLUSTERorpig pt failover CLUSTER --candidate MEMBERwhen you need manual Patroni cluster switching (native patronictl passthrough since v1.6.0; the cluster name is required).
Privilege execution:
- If the current user is the DBSU: execute directly.
- If the current user is root: execute with
su - postgres -c. - Other users: execute with
sudo -inu postgres --.
Platform support:
This command is designed for Linux and depends on pgBackRest, systemd for managed service scenarios, and data/log paths accessible by the DBSU.