This is the multi-page printable view of this section. .
PIG 1.10.0 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 do
- 12: pig postgres
- 13: pig patroni
- 14: pig pe
- 15: pig pgbackrest
- 16: pig pitr
Current stable version: v1.10.0. Read the release notes.
PIG provides commands to find, install, and build PostgreSQL extension packages. It also manages PostgreSQL, Patroni, pgBackRest, and Pigsty workflows. Package installation uses the system’s apt, dnf, or yum.
Start here
| Your task | Page |
|---|---|
| Install PostgreSQL and enable your first extension | Getting started |
| Learn what PIG does and which platforms it supports | Introduction |
| Download, install, update, or remove PIG | Installation |
| Look up commands, options, and automation features | Command reference |
Install PostgreSQL and extensions
On a Linux host with root or sudo access, run:
In mainland China, use https://repo.pigsty.cc/pig for the installer. These commands install PostgreSQL 18 and pgvector packages. Continue with Getting started to start a test instance and enable the extension with CREATE EXTENSION vector.
Command reference
| Task | Command |
|---|---|
| Configure APT/DNF repositories | pig repo |
| Query the catalog, install, or update extension packages | pig ext, pig install |
| Build extension packages from source | pig build |
| Manage local PostgreSQL instances and databases | pig pg |
| Manage Patroni clusters through patronictl | pig pt |
| Inspect or reload pg_exporter | pig pe |
| Back up and restore with pgBackRest | pig pb |
| Run point-in-time recovery | pig pitr |
| Install and configure Pigsty, manage Grafana | pig sty |
| Read, edit, and validate Pigsty inventory | pig inventory |
| Run Pigsty administration playbooks | pig do |
| Collect host, database, and backup status | pig context |
Run pig help <command> for command help. For automation, use pig -o json --help to inspect command capabilities, then select the relevant output and plan options.
Find more information
Press Ctrl with K (⌘ with K on macOS) to search the site. Press / for page actions. An AI assistant action sends the public page URL and a reading prompt to the selected service.
- Design Records: implementation decisions, trade-offs, and proposals.
- Release notes: changes and download files for each version.
- Extension catalog: extension descriptions and package information.
- GitHub Issues: report a problem or request a feature.
PIG is developed by Vonng and released under Apache 2.0. Pigsty provides PostgreSQL deployment, monitoring, backups, and high availability.
1 - Getting Started
This tutorial installs PostgreSQL 18 and pgvector, starts a local test instance, and enables the extension in a database.
Use a supported Linux test host with internet access and curl installed. You need root or sudo access. Run the commands in order.
Install PIG
In mainland China, use https://repo.pigsty.cc/pig instead. The installer selects the RPM or DEB package for your host. See Installation for other methods.
Check the host
Check the OS code, architecture, and detected PostgreSQL installations. This command also tests repository connectivity.
Add repositories
Add PGDG and Pigsty PostgreSQL repositories, then refresh package metadata:
For China mirrors, add --mirror to this command.
Install PostgreSQL and pgvector
Review the package manager’s transaction and confirm it.
pg18 selects the PostgreSQL 18 packages. vector selects pgvector. The -v 18 option selects the extension’s PostgreSQL major version.
Check the installed extension files:
Start a test instance
This tutorial uses /pg/data-demo and port 15432 to avoid the default cluster on port 5432. Use an unused directory and port.
Create an empty data directory owned by the postgres operating-system user:
Start the instance on port 15432:
Enable and test pgvector
Connect to the test instance:
PIG reads the instance’s connection information from the specified data directory. At the psql prompt, run:
The first query returns the installed pgvector version. The second returns a distance of approximately 5.196. Exit psql with \q.
CREATE EXTENSION enables an extension in the connected database. Repeat it in each database that needs pgvector.
Stop the test instance when you finish:
The data stays in /pg/data-demo. Run the start command again to reuse the instance. See PostgreSQL management for service configuration and other operations.
Find more extensions
Before installing another extension, use info to check its setup requirements and avail to check package availability.
Select packages and versions
To use another PostgreSQL major version, replace 18 in the commands above.
See extension installation for package groups, version selection, and existing installations.
Inspect and update
pig ext status -v 18 lists installed extension files. To list extensions enabled in a database, run \dx in psql.
See extension updates when you need to upgrade a package and its database objects.
2 - Introduction
PIG is a command-line tool for installing and managing PostgreSQL and its extensions. It maps extension names to RPM or DEB packages and uses apt, dnf, or yum to install them.
The catalog contains 603 extension entries. PIG selects package names for your PostgreSQL major version, operating system, and CPU architecture. It also provides commands for source builds, local PostgreSQL operations, backups, and Pigsty administration.
What you can do
| Task | Command | Reference |
|---|---|---|
| Find an extension and check package availability | pig ext list, pig ext avail | Extensions |
| Add PGDG and Pigsty repositories | pig repo add pgsql -u | Repositories |
| Install PostgreSQL 18 and pgvector | pig install -v 18 pg18 vector | Getting started |
| Build an extension package from source | pig build pkg NAME | Build |
| Start, inspect, or stop a local PostgreSQL instance | pig pg | PostgreSQL |
| Manage a Patroni cluster | pig pt | Patroni |
| Back up or restore an instance | pig pb, pig pitr | pgBackRest, PITR |
| Configure Pigsty and run its playbooks | pig sty, pig inventory, pig do | Pigsty |
Start with the tutorial to install PostgreSQL and enable your first extension.
How package installation works
For example, this command installs pgvector for PostgreSQL 18:
PIG resolves vector to pgvector_18 on EL or postgresql-18-pgvector on Debian and Ubuntu. The system package manager resolves dependencies and installs the files.
To enable the extension, connect to the intended database and run:
Some extensions also need a setting in shared_preload_libraries and a PostgreSQL restart. Use pig ext info NAME to check these requirements. See package and database operations for updates and removal.
PIG is needed only when you run its commands. PostgreSQL and installed extensions continue to work without it. You can also use the Pigsty repositories directly with apt or dnf.
Linux compatibility
The package repositories cover PostgreSQL 14–18 on these Linux releases. Each release has packages for x86_64 and aarch64.
| OS code | Distribution | Release |
|---|---|---|
el8 | RHEL, Rocky Linux, AlmaLinux | 8 |
el9 | RHEL, Rocky Linux, AlmaLinux | 9 |
el10 | RHEL, Rocky Linux, AlmaLinux | 10 |
d12 | Debian | 12 |
d13 | Debian | 13 |
u22 | Ubuntu | 22.04 LTS |
u24 | Ubuntu | 24.04 LTS |
u26 | Ubuntu | 26.04 LTS |
Package availability varies by extension and target. On the target host, run:
The 603 catalog entries include packaged SQL utilities and retained records for removed extensions. The website and CLI use this same catalog-entry count. Check the entry’s status and availability before selecting a package. EL 7 and Debian 11 are outside the current package matrix.
The macOS binary supports catalog queries and commands such as inventory editing. PostgreSQL package installation uses Linux package managers. See Installation for the binary downloads.
Choose a workflow
- Use an existing host: add repositories with
pig repo add pgsql -u, then install the required packages. - Configure all repositories on a new host: use
pig repo set. It backs up and replaces the existing repository definitions. - Build a package: prepare a build host and use the maintained specifications with
pig build. - Prepare an offline installation: collect packages with
pig ext import, index them withpig repo create, and archive them withpig repo cache. See offline repositories. - Write a script or agent workflow: inspect
pig -o json --helpand use the supported output and plan options in the command reference.
The Design Records explain the main implementation decisions. The release notes describe changes in each published version.
3 - Installation
Install PIG with the Linux installer, a system package, or a release archive. The current version is v1.10.0. The download page lists all release files.
Script installation
On Linux, run:
In mainland China, use:
The script detects the architecture, downloads the RPM or DEB package, and installs it with rpm or dpkg. Installation requires root or sudo access.
Check the installed version:
To select a published version, pass its version number:
Download release artifacts
Choose a file for your operating system and architecture on the download page or GitHub release.
| System | Format | Architecture names |
|---|---|---|
| EL | RPM | x86_64, aarch64 |
| Debian, Ubuntu | DEB | amd64, arm64 |
| Linux | tar.gz | amd64, arm64 |
| macOS | tar.gz | amd64 (Intel), arm64 (Apple Silicon) |
For a release archive, extract it and install the pig executable in a directory on your PATH. For example, on Apple Silicon:
The release includes SHA-256 checksums. Use sha256sum on Linux or shasum -a 256 on macOS to compare your downloaded file with its listed hash.
The macOS binary supports catalog queries, inventory editing, and other commands that do not need Linux package managers. Install PostgreSQL packages on a supported Linux host.
Repository installation
To manage PIG with the system package manager, add the Pigsty Infra repository. Choose the tab for your host:
These definitions disable signature checks for the Pigsty repository. For key handling and verification settings, see repository keys.
Update
On Linux, update the executable with:
Use -m for the China mirror or -v 1.10.0 to select that version. For an archive installation on macOS, download the new archive and replace the installed executable.
Refresh the extension catalog separately:
This updates catalog metadata, leaving installed packages unchanged.
Uninstall
Choose the command that matches your installation:
If you installed the archive elsewhere, remove that executable instead. PostgreSQL and its extensions continue to run without PIG.
Build from source
Install Git, Make, and the Go toolchain specified in the project’s go.mod. Build the current release:
make build produces ./pig for the current platform. The release workflow uses GoReleaser to produce RPM, DEB, and tar.gz files.
Continue with Getting started to install PostgreSQL and enable an extension.
4 - Release
The latest stable version is v1.10.0.
| Version | Date | Summary | GitHub |
|---|---|---|---|
| v1.10.0 | 2026-10-17 | 603 catalog entries, PostgreSQL target and recovery safety, faithful Inventory, automation fixes | v1.10.0 |
| v1.9.0 | 2026-10-06 | 600 catalog entries, Xray roles, repository keys, pgrx 0.19.3 | v1.9.0 |
| v1.8.1 | 2026-09-03 | CLI/repository safety, debug packages by default, pgrx 0.19.2 | v1.8.1 |
| 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.1 | 2026-02-14 | Path, symlink, and build migration fixes | v1.1.1 |
| 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.9.0 | 2025-12-28 | Rename sty deploy and expand sty conf options | v0.9.0 |
| v0.8.1 | 2025-12-27 | Restore llvmjit to the pgsql-full alias | v0.8.1 |
| 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.10.0
Pig v1.10.0 strengthens the correctness and safety of existing commands. It verifies PostgreSQL
targets before operations, preserves Inventory sources and YAML types, and makes repository,
extension, and automation results match the work actually performed. The bundled catalog grows
from 600 to 603 records. Embedded Pigsty remains 4.5.0; the default cargo-pgrx remains 0.19.3.
PostgreSQL targets and maintenance
- An explicit
-Dbindspsql,ps,kill,vacuum,analyze,freeze, andrepackto the selected instance, including--alldatabase enumeration. PIG validates the PID, data directory, port, socket, and process identity before starting the SQL client. Invalid, stale, copied, or uncertain runtime metadata causes failure instead of a fallback to another instance. - Without
-D, those SQL commands retain native client connection defaults.pg cloneandpg forkretain their own port options. Promotion timeline checks use the selected instance or its control data; an unresolved timeline is left unknown. - Plans and confirmation retry commands preserve the selected data directory, PostgreSQL version,
operating-system user, and maintenance options.
VACUUM FULLplans correctly require confirmation. - Maintenance operands are literal database names. Values containing
=or beginning withpostgres://orpostgresql://are rejected before planning or execution, without echoing the value. Spaces and non-ASCII names remain supported. Generated commands put names after--, so a database named--allcannot become a command option. vacuum,analyze, andfreeze --allvalidate the complete database list before maintenance begins. Use native clients when a connection string or a database name rejected by this boundary is required.
See pig pg for target selection and
maintenance commands for database-name rules.
Runtime state, recovery, and fork safety
- Permission failures, malformed PID metadata, and unavailable process identity are reported as
errors or unknown state. They cannot authorize forced initialization, restore, or fork replacement.
pg statusreturns130201(exit3) for permission failures and130808(exit1) for other runtime-probe failures. Plans report an unresolved precondition asunknown. - Declining PITR confirmation or reaching EOF returns
161001(exit7) before any service stop, restore, or startup. An unknown state cannot supply a PID for forced termination or count as successful startup. Post-restore SQL checks require a verified target. - Replacing a nonempty unmanaged fork requires valid ownership metadata with a matching explicit target path. Missing, damaged, or mismatched metadata cannot authorize deletion. Existing protections for running targets and source/destination relationships remain in force.
- Clone and fork path checks run as the selected database operating-system user when needed,
supporting private
0700data directories. An inaccessible or unresolved path cannot bypass validation. Managed orphan cleanup remains available through the managed fork name. - Files written as the database user use private sibling staging and exact-target replacement.
The new file has
0600permissions; directory or symlink targets are refused, and replacement does not overwrite the contents of another hard link to the old file.
The PITR reference explains the managed recovery workflow;
pig pb restore remains a separate restore primitive.
Inventory and Pigsty
sty deployanddopass the resolved Inventory path explicitly to Ansible. Flag and environment paths resolve from the caller’s working directory; quoted~/paths expand before resolution. A selected missing or invalid source does not silently fall back to another inventory.pg_users[].rolespreserves both role-name strings and structured grants, including grant state and optionaladmin,set, andinheritattributes.- Editing, serialization, and CMDB export retain strings that YAML consumers might otherwise interpret as numbers, dates, or timestamps. Existing timestamp scalars retain their original source representation. Independent PyYAML checks verify the emitted string types.
sty conf --proxyaccepts uppercase and lowercase HTTP, HTTPS, ALL, and NO proxy variables. Missing HTTP and HTTPS values both fall back to ALL_PROXY. Version completion observes dotted version boundaries, so a request for1.1cannot select1.10.
See Inventory source selection and pig sty.
Repositories and extensions
- Repository commands validate the complete operand list before changing files. Empty values,
empty comma-separated elements, and unsafe repository names fail before mutation.
Only truly argument-free
repo rmbacks up all repository files;repo rm allexpands thenode,pgsql, andinframodules. Removal results preserve the original request and distinguish missing targets from removed files.--updatealso refreshes the cache after a full backup. - Repository creation retains documentation RPMs. Debug package suppression continues to use
--nodbg; a-docsor-docname alone does not make a package a debug package. - Default extension lists, availability summaries, and refresh results count all catalog records,
including SQL utilities and retained lifecycle entries. The total describes catalog coverage,
not how many extensions can be installed on one host or enabled with
CREATE EXTENSION. - Text, JSON, and YAML share availability rules. On covered Linux platforms, package matrices take
precedence and a missing matrix cell means unavailable. Architecture aliases are normalized.
On macOS, the status describes declared PostgreSQL support without promising an RPM/DEB package.
ext list -vselects the version used to evaluate status; unavailable records remain listed. ext importreports failure if any requested package cannot be resolved or downloaded, while retaining successful downloads and reporting the completed and failed portions. APT virtual dependency markers are excluded from package download requests. Installed-library scanning also recognizes catalog entries without a control file.- The three new catalog records are
pg_icu_parser,pg_vectorsearch, andtextsearch_intl. Existing versions and platform metadata are refreshed as well. Usepig ext avail NAMEto inspect a target before installing.
Builds and automation
- Multi-version build dependency installation expands package names for every selected PostgreSQL major version and removes duplicates. Default build targets retain their metadata and local installation rules independently of package-matrix gaps.
- Debian/Ubuntu builds preserve the inherited
PATHorder and append the current user’s~/.cargo/binwhen present, preserving an explicitly selected toolchain. - Xray setup recognizes complete legacy service definitions, including marker-free macOS plists generated by the previous renderer. A comment alone cannot prove ownership; changed or foreign definitions still require explicit replacement. Matching reruns preserve a running service.
- JSON/YAML output and
PIG_NON_INTERACTIVE=1consistently disable prompt input and use non-interactive sudo in PIG-owned adapters. Explicit data-input channels remain available; native Patronictl forwarding retains its interaction and exit contract. - CMDB connection strings, legacy VMess credentials, and license keys are excluded from routine parameters and failure details. Explicit credential export and raw Inventory display retain their documented sensitive-output behavior.
- Exporter HTTP 4xx/5xx responses now fail with the numeric status and standard description,
without including response bodies or custom status text. Unsupported
pig updateplatforms fail explicitly. Command help and bilingual references are aligned with these behaviors. - Go dependencies and validation tools are refreshed. CI includes Linux permission and instance boundary acceptance plus independent YAML consumer checks.
See pig build, pig pe, and global command behavior.
Upgrade notes
Existing command names and flags remain available. Automation should handle the corrected failure
statuses for partial imports, HTTP errors, cancelled recovery, and indeterminate PostgreSQL state.
Scripts must supply valid repository operands, explicit confirmation where required, and literal
maintenance database names. When a name begins with -, place all options before -- and the name.
Upgrade with the installation instructions.
Release artifacts: v1.10.0
v1.9.0
Pig v1.9.0 adds one-command Xray client/server setup, automatic Pigsty repository-key
preparation, and a refreshed 600-entry extension catalog. The default cargo-pgrx
version is now 0.19.3; the embedded Pigsty version remains 4.5.0.
Xray clients and servers
pig build proxyinstalls or verifies Xray.pig build proxy clientconfigures a VLESS/REALITY/Vision HTTP/SOCKS client;pig build proxy serverconfigures a Linux server. Linux uses systemd; the macOS client uses a dedicated user LaunchAgent.- Client input accepts a standard VLESS URI,
--from FILE/-, or explicit connection flags. The first client listener is127.0.0.1:12345; the first direct server listener is0.0.0.0:443. Repeated setup preserves existing listeners and server credentials. - Matching configuration, ownership, permissions, and service state avoid rewrites and
restarts. Failed client connectivity checks restore prior managed files and service state.
Replacing a different client requires
--replace --yes;--planpreviews either role. server --export-only --host HOST --export -exports an existing connection without changing the deployment. File exports use mode0600; explicit stdout export requires text output. Ordinary results and plans omit credentials. The historical VMess positional form remains available through V2Ray.
Run the server command on the server, then transfer client.uri securely to the client and run
the client command there. See pig build for prerequisites and macOS setup.
Repository keys
repo add,repo set, andsty bootprepare the embedded Pigsty public key when selected repositories need it. Existing regular key files are reused; missing defaults are installed offline at/etc/pki/rpm-gpg/RPM-GPG-KEY-pigstyor/etc/apt/keyrings/pigsty.asc.- Implicit default-key failure emits a warning and falls back only for selected Pigsty
definitions. Default key references remain stable, including APT
signed-by. - Explicit signing-key references are mandatory: invalid or unavailable keys fail before
repository replacement or cache refresh. EL imports explicit references with
rpm --import. Selecting unrelated repositories does not prepare the Pigsty key.
See pig repo for signature-enforcement
defaults and the distinction between key preparation and metadata refresh.
Catalog and build defaults
- The embedded catalog contains 600 entries, adding 22 entries to the v1.8.1 snapshot.
New entries include
edtf_postgres,plphp,pg_lexo,pg_money,istore,colnames,pg_statkit,pgtelemetry,pg_rusage,pgexporter_ext,pg_statvfs, andlibx509pq. Package versions and platform-availability metadata are refreshed as well. - The catalog total includes retained lifecycle records. Installability depends on each
extension’s state and OS/architecture/PostgreSQL matrix. Use
pig ext avail NAMEto check a target. pig build pgrxdefaults tocargo-pgrx 0.19.3. An explicit-vand extension-specific catalog metadata continue to select another required version.- Platform debug packages remain enabled by default, as in v1.8.1. Use
--nodbgfor RPMdebuginfo/debugsourceand DEBdbgsymsuppression;-s|--symbolis a deprecated no-op.
Compatibility
No existing command or flag is removed. New Xray role commands use VLESS/REALITY/Vision; existing positional VMess commands retain their V2Ray behavior. Server setup checks the local listener and service. Configure the firewall, cloud security group, and any Nginx frontend for the chosen public port, then verify the connection from the client.
Release artifacts: v1.9.0
Verification
The verified v1.9.0 tag points to
9eb5488. The exact commit passed
full CI, including randomized tests,
command race regressions, vet, static analysis, vulnerability scanning, and a release snapshot.
The Release workflow produced eight
Linux/macOS archives and RPM/DEB packages. Published downloads were verified against SHA-256.
Checksums
| File | Checksum |
|---|---|
| pig-1.9.0-1.aarch64.rpm Linuxarm64SHA-256 | d0d80bd23a654308598f265ce4b4d4f78d6156c113ce6aa00f82bfc9519a180f |
| pig-1.9.0-1.x86_64.rpm Linuxamd64SHA-256 | e3b25640c9e528f2b883f7e5f4838640a8897857fa22dc1324aca69b72966a7c |
| pig-v1.9.0.darwin-amd64.tar.gz macOSamd64SHA-256 | d7eb266e1b8ab60d20ac582c6b0e3741b7e8516ce1a56df447c0285b3e5dcab9 |
| pig-v1.9.0.darwin-arm64.tar.gz macOSarm64SHA-256 | 096284577d0493ddba871b51e820654b358c7f4eb9c11175674a1d21b2718824 |
| pig-v1.9.0.linux-amd64.tar.gz Linuxamd64SHA-256 | a4b5ffca540bc4f924f86398bcad6cb7221ac7520b54b1d3fd32c9877d9cafd2 |
| pig-v1.9.0.linux-arm64.tar.gz Linuxarm64SHA-256 | ddfa80fbb34f6738dd68e0d04cd92355711330f6896cd650df7d71b012788def |
| pig_1.9.0-1_amd64.deb Linuxamd64SHA-256 | 3d955a24a8ff805ee2b6da6428e2b882f97104e2fb597785225269443071d93a |
| pig_1.9.0-1_arm64.deb Linuxarm64SHA-256 | c175b37552147e64590309801800826a0075ae8285ed78178c2adcaec3741471 |
v1.8.1
Pig v1.8.1 is a safety, correctness, and maintenance release on top of
v1.8.0. It hardens command initialization, privileged log access,
repository and build workflows, release integrity, and structured-output redaction. It also
refreshes the embedded extension catalog and moves the build toolchain to Go 1.27.1 and
cargo-pgrx 0.19.2. The embedded Pigsty version remains 4.5.0.
CLI safety and correctness
- Read-only and configuration-independent commands no longer require a writable
HOMEor create~/.pigas a side effect. Leaf commands preserve their declared initialization policy. pig pg log,pig pt log, andpig pb logpreserve arguments through sudo execution as the database OS user and reject unsafe log-file links.pig dovalidates Pigsty names and rejects reserved Ansible cluster targets before execution.- Native PostgreSQL role detection is bound to the selected instance rather than an unrelated local default.
- Structured results redact credentials, license material, and build-proxy identifiers while retaining truthful command failure.
Repository and build hardening
- Repository add and remove operations now fail when any requested operation fails, deduplicate module selections, and preserve replacement boundaries.
- Offline cache bundles reject unsafe paths, links, special files, and incomplete inputs; archive extraction remains rooted and fail-closed. The obsolete exported cache wrapper was removed after production moved to the structured result path.
- Build source and artifact validation rejects incomplete or unsafe inputs.
pig build proxyuses the package-provided service contract, treats its operands as optional, and keeps secret identifiers out of structured output. - Self-update verifies release checksums, and release tooling refuses dirty or mismatched-tag publication and immutable artifact replacement.
Toolchain and catalog
pig build extandpig build pkgkeep platform debug packages enabled by default; use--nodbgto omit them.-s|--symbolremains a deprecated compatibility no-op.Go is updated to
1.27.1; Logrus to1.10.2; GoReleaser to2.18.0; and golangci-lint to2.13.2.pig build pgrxnow installscargo-pgrx 0.19.2by default. Use-vwhen an extension requires an older pgrx line recorded in its catalog metadata.The embedded catalog is refreshed from the maintained pgext view. It adds
acdat 0.1.0, marks the supersededpgcontext_pgvectorentry removed, and updates package versions, repository ownership, PostgreSQL coverage, and availability matrices.
Verification
The release is built from source commit
1c6f524.
The exact commit passed the full CI workflow,
including randomized tests, command race regressions, vet, static analysis, dead-code detection,
vulnerability scanning, and a GoReleaser snapshot. The tag then passed the
Release workflow, which produced the
published RPM, DEB, macOS, and Linux artifacts.
Compatibility notes
- No CLI command or flag is removed in this release.
- Scripts that previously depended on read-only commands creating local configuration should create that state explicitly instead.
- The pgrx default changes to
0.19.2; extension-specific metadata remains authoritative when a build requires another pgrx version.
Checksums
| File | Checksum |
|---|---|
| pig-1.8.1-1.aarch64.rpm Linuxarm64SHA-256 | 4154b3e49cb499e57d7c7b1ab4ae5e45d03d5d0c2ffe26d6ade64e46db6923cf |
| pig-1.8.1-1.x86_64.rpm Linuxamd64SHA-256 | 35c398f409d9293b4f8c0cdf949b19c62d06016ec7e724472143d2327199869d |
| pig-v1.8.1.darwin-amd64.tar.gz macOSamd64SHA-256 | 6c08b6a698191b8b6494a0f60880fb17cafa535bad12d5c544333e4625048455 |
| pig-v1.8.1.darwin-arm64.tar.gz macOSarm64SHA-256 | 0fb6c86cc18a29aeb74e9d12e717c104087c6ecf5a43250dfcc71cd7681fb868 |
| pig-v1.8.1.linux-amd64.tar.gz Linuxamd64SHA-256 | 9219e87433ebd239e0773ae7417fdd08e97bb511312e6747542bf46b6b1bbf2b |
| pig-v1.8.1.linux-arm64.tar.gz Linuxarm64SHA-256 | b30924880f21126ece3afc77ca75794a0ceb77964cdfd8bc20da72d9d3273078 |
| pig_1.8.1-1_amd64.deb Linuxamd64SHA-256 | 6fc304501671921b18439223c630c7d4635b10ac75493d5c12a5987ff80c618e |
| pig_1.8.1-1_arm64.deb Linuxarm64SHA-256 | 1a70cd71f6c1f443812fe30535427891513c0ba03be219ac21f1a3d6fd450051 |
Release artifacts: v1.8.1
v1.8.0
Pig v1.8.0 updates native controller workflows from v1.7.0. Go implementations of pig sty boot and pig sty conf replace wrappers for the legacy bootstrap and configure shell scripts. The packaged PostgreSQL extension count remains 575. The embedded Pigsty version remains 4.5.0.
Highlights
pig sty bootcan elevate once through sudo. It verifies Ansible and its actual Python runtime. It supports explicit local packages, HTTP(S) URLs, trusted automatic offline packages, committed local repositories, and regional online repositories. It backs up repository configuration before replacement and restores it on failure. It attempts to repair localhost SSH and a missing~/pigsty, but repair is not guaranteed.pig sty confgenerates inventory natively from safe templates. It supports up to ten IP mappings, exact domain replacement, region and proxy settings, PostgreSQL-version selection, and random credentials. It validates the complete candidate, then writes it atomically with mode0600.- Bootstrap download and extraction no longer require
curl,wget,tar, orgzip. Offline operation uses onlypigsty-localand requires the/www -> /data/nginxlayout. - EL8 and newer consistently prefer DNF. Local RPM requirements resolve by provider capability. This release updates extension metadata and availability matrices, and moves the toolchain to Go
1.26.6.
Compatibility Notes
pig sty bootno longer runs<PIGSTY_HOME>/bootstrap. Automation that relied on script side effects must use the native command.- Removed
pig sty conf --raw.--conf MODEand positionalMODEare equivalent.--ipaccepts up to ten addresses. You cannot combine it 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 updates repository compatibility and the catalog from v1.6.2. It makes China-mirror selection explicit and preserves native DNF module filtering by default. It restores a simplified EL7 repository catalog. The bundled extension snapshot grows from 572 to 575. The embedded Pigsty version remains 4.5.0.
Highlights
-m|--mirrordirectly selects the bundledchinarepository definitions. PGDG, Rocky Linux, Debian, Ubuntu, Docker, and other regional routes use the maintained mirror list. This replaces the former PGDG proxy rewrite at runtime.- EL repository definitions no longer receive
module_hotfixes=1globally. Pigsty and PGDG repositories explicitly enable it when they need to override module streams. BaseOS, AppStream, EPEL, and other repositories retain native DNF module filtering. - EL7 retains a limited compatibility catalog. It includes archived CentOS 7 Base/Updates/Extras/SCLo and EPEL definitions for
x86_64, plus shared Pigsty and supported PGDG entries. EL7 YUM rendering removes the DNF-onlymodule_hotfixeskey. - If the catalog has no matching definitions, repository setup reports an unsupported platform. It no longer continues 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|--mirrornow explicitly selects the China region. It no longer rewrites the PGDG proxy. For a specific route, use--region=default|china|europe.- Custom EL repository definitions must set
meta.module_hotfixes: 1explicitly to override module streams. Ordinary OS repositories omit this setting. EL7 removes it. - EL7 is end-of-life and has only 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 adds features and updates the catalog from v1.6.1. Packaged extensions increase from 562 to 572. This release adds native Grafana dashboard schema v2 support and improves local repository generation. The embedded Pigsty version remains 4.5.0.
Highlights
pig sty grafanaaccepts legacy dashboard JSON and nativedashboard.grafana.app/v2Dashboard resources. It loads v2 dashboards through the Grafana resource API to preserve tabs and section variables across loading and dumping. Dumps preserve an existing v2 destination. New dumps use the legacy format by default.- When SOW is available,
pig repo createpreferssow create --pigsty --timeout 10m -- <dir>. It requires arepo_completemarker that is a regular file. On Linux, it can fall back tocreaterepo_c/dpkg-scanpackages. - Local repository creation works on macOS through SOW. On macOS, it defaults to the current directory 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.
- With SOW installed,
pig repo createprefers it over the legacy Linux generators. It checks for the completion marker before reporting success. - The catalog count does not guarantee package availability for every PostgreSQL / OS / architecture combination. Check the target host with
pig ext avail NAME.
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. It updates the bundled extension catalog and sets the embedded Pigsty version to 4.5.0. It adds no commands and changes no flags.
Highlights
- Regenerates the embedded
extension.csvfrom Pigsty package repositories. New installations use 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 root-level pig inventory group adds lossless editing and validation of pigsty.yml, plus an experimental PostgreSQL CMDB bridge. pig sty grafana adds native Grafana dashboard management. The packaged extension catalog grows to 562.
Highlights
pig ptbecomes a nativepatronictllauncher. All cluster commands (list,restart,switchover,failover,edit-config, …) forward directly with native flags, prompts, output, and exit codes. New patronictl features therefore work without a new pig release. Local helpersstatus,log,set, andservice/svcremain. New options are-c/--config-file,-d/--dcs-url, and-k/--insecure. Usepig pt -- …to pass arguments directly.- Adds the root-level
pig inventorycommand group (aliasinv):status/list/show/edit/validate/check/diff. Its lossless YAML engine preserves comments, formatting, key order, and anchors byte-for-byte.editvalidates before writing, then writes atomically. Invalid YAML cannot reach disk. - Adds experimental
pig inventory cmdbsubcommands:check/init/load/dump/enable/disable. They exchange inventory with the PostgreSQL Pigsty CMDB through a native driver. They use bounded timeouts and confirmation tied to a digest for destructive operations. - Adds
pig sty grafana(aliasgf) for native Grafana dashboard management over HTTP. Its commands areinfo/list/boot/load/init/dump/clean/lang/style. Removessty edit/validate/check/cmdb/dashboard/releaseto simplifypig sty. Usepig inventory,pig sty grafana, andpig sty list/getinstead. - Reliability improvements: repository, catalog, and download writes are atomic, preventing truncated files after interruption. Structured
-o json|yamloutput keeps only the result envelope on stdout and sends wrapped-tool output to stderr. More specific exit codes distinguish usage errors (2) from missing--yesconfirmation (7). Ansible list variables use JSON encoding. - Repository updates: MySQL moves to 8.4 LTS, with new Percona XtraBackup (
pxb84) and MySQL Tools repositories. Kubernetes moves to v1.36. LLVM APT coverage extends to Debian/Ubuntu 26. Percona TDE uses repo.percona.com directly. Removes thewiltondbrepository. - 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. - Aligns package aliases with Pigsty. Renames
kafkatokafka-stack. The Debian/Ubuntupostgresqlalias maps only topostgresql-$v. For the full development set, usepgsql/pgsql-full.
Compatibility Notes
- ⚠
pig pt failover <name>now treats the positional argument as the cluster, not the promotion candidate. Usepig pt failover CLUSTER --candidate MEMBER. Review failover automation before upgrading. pig ptuses native cluster-first positional arguments (restart CLUSTER [MEMBER]). Forwarded commands return native patronictl exit codes and manage their own confirmation prompts.-yno longer controls those prompts. They no longer support-o json; use native--format json.pig pt set K=Vand nativeshow-config/edit-configreplacepig pt config.- In structured output mode, wrapped-tool output goes to stderr. Stdout contains 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
- Adds mirror/proxy mode to repository, build, sty, update, and extension update workflows.
pig build rust -malso configures Cargo mirrors throughrsproxy.cn. - Adds explicit PostgreSQL 19 beta build options:
pig build repo --beta,pig build tool --beta, andpig build pgrx -b. PostgreSQL 18 and PG14-18 remain 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 updates PostgreSQL operations for daily DBA work. It adds local database clone and fork workflows. It clarifies the roles of pg, pt, pb, and pitr. It also improves previews, confirmation, and structured output for high-risk operations.
Highlights
pig pgfocuses on local PostgreSQL operations.pig pg clonemakes quick database-level copies.pig pg forkcreates temporary physical instance forks for local validation, recovery drills, and isolated experiments.- Recovery commands have clearer roles.
pig pitrcoordinates Patroni, PostgreSQL, and pgBackRest.pig pb restoreremains the low-level pgBackRest restore command. Restore commands require an explicit target. They provide more specific plans and guidance for steps after recovery. - Patroni operations use more consistent behavior. High-risk actions such as
pig pt restart,reinit,switchover, andfailoveruse Pig-managed confirmation and plan output. When a restart is required,pig pt config pgdirects operators topig pt restart --pending. - Structured output no longer confirms destructive commands. High-risk execution requires explicit
-y/--yes.--planandnext_actionsprovide more consistent workflows to preview an operation before execution. - Improves logs and status output for incident response. The
pg,pb, andptlog commands support common latest / tail / show / grep workflows. 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 version. EL9 ARM64 Patroni aliases now select noarch packages.
Compatibility Notes
- For destructive operations in automation, use
-y/--yes. Structured output mode no longer replaces human confirmation. pig pb restoreandpig pitrrequire exactly one explicit recovery target. For automatic promotion, use--target-action=promote.- Removed ambiguity in several short options. For log commands,
-o jsonselects a JSONL snapshot. It does not apply to 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. pig sty conf -v 19enables thebetarepository module if the template supports it. It warns if the template is not tuned for PG19 beta or cannot enable the beta repository automatically.- Fixes 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. - Updates authoritative source bundles for
pig build get. These include Cloudberry / OrioleDB build inputs and bundled artifacts for RDKit and OneSparse 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
Increases 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 engineering update moves from v1.2.0 to v1.3.0. It contains 15 commits across 74 changed files, with +1184 / -236 LOC.
It improves the reliability of the pig build pipeline and extends catalog and alias coverage. Total extensions increase 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 the PG major version from
pgmajorversionin spec files. Missing spec/control files 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 the PG major version from
- DEB build result semantics fixed (
pig build ext/pkg):- A successful build command exit code determines success. Artifact discovery is best-effort and can only produce warnings.
- 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:
- Updated the version to
v1.3.0, including av1.2.1transition commit. Changed the copyright year to 2026. Updated the README for 461 extensions and current alias documentation.
- Updated the version 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.
- Adds OS-level alias overrides (
ansible/bootstrap). Unknown distributions now fall back only to PGDG. - 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). - Unifies
sty conf/configurebehavior. The native implementation is the default, and--rawremains as a fallback. - 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.1
Fixes
- Preserve symlink semantics during build-tree migration and support cross-device moves.
- Handle a PostgreSQL log directory configured as the filesystem root without resolving files outside the intended directory.
- Allow
pig repo rmto remove repository modules whose names contain dots while retaining safe-path validation. - Accept safe relative symlinks when
pig sty initextracts a Pigsty release archive.
Checksums
| File | Checksum |
|---|---|
| pig-1.1.1-1.aarch64.rpm Linuxarm64SHA-256 | 22fe5e951f09e7cfa46ab22781199b3209792992940eb5615ace4928e41a7429 |
| pig-1.1.1-1.x86_64.rpm Linuxamd64SHA-256 | 7f5a10bbefdc39e5d66a7e688fa78c5ba566c8140458b9f4b1536ff0d7ed457a |
| pig-v1.1.1.darwin-amd64.tar.gz macOSamd64SHA-256 | b90aec9dc559df81c46d32575a8d231fa6d7eeb8b25f4d2e0b6076cc0a9c0e59 |
| pig-v1.1.1.darwin-arm64.tar.gz macOSarm64SHA-256 | 3063e3a72e68371a082b4e629d12aafda46d96eddc22976beb2049881854f4ea |
| pig-v1.1.1.linux-amd64.tar.gz Linuxamd64SHA-256 | 081ff8c81bf61108a35ca4cdc51007d4ddf1de8a041d8be087e58e7068e7e177 |
| pig-v1.1.1.linux-arm64.tar.gz Linuxarm64SHA-256 | 9a81e868699f92d73f8aeb7752206b6eaac8d42d1688089a1f543b12ee0d272d |
| pig_1.1.1-1_amd64.deb Linuxamd64SHA-256 | 85ce861cfbff846be2ba912ba8dfc766121dad14a59937387d9c5e26b0b6f541 |
| pig_1.1.1-1_arm64.deb Linuxarm64SHA-256 | 3a108f0544af4d1f98acee55c06c5b5af3b856e3be2b18767e6db0b8a1cc664f |
Release: https://github.com/pgsty/pig/releases/tag/v1.1.1
v1.1.0
This release upgrades the CLI architecture from v1.0.0 to v1.1.0, with 79 commits across 193 changed files. It extends pig from an interactive CLI to a CLI that agents can orchestrate.
Seven new extensions are added, bringing the total available extensions to 451.
New Features
- Adds a unified output framework for agents. Global
--outputsupportstext/yaml/json/json-pretty. A commonResultstructure provides stable status codes and machine-readable output forext/repo/pg/pt/pb/pitr/status/version/context. - Adds ANCS (Agent Native Command Schema) metadata, including
type/volatility/parallel/risk/confirm/os_user/costfields. In structured mode,helpoutputs a command capability tree. Agents can use it to identify capabilities and risks. - Adds the
pig context(pig ctx) environment snapshot command. One call collects host, PostgreSQL, Patroni, pgBackRest, and extension information for direct use in agent workflows. - Extends plan support beyond PITR with
pig ext add/rm --plan,pig pg stop/restart --plan, andpig pt switchover/failover --plan. These matchpig pitr --plan/--dry-runin a common, reviewable format. Plans show actions, scope, risks, and expected results. - Extends structured results with native
pgbackrest infoJSON. Unifies structured return DTOs across Patroni/PostgreSQL/PITR/Repo/Ext for automation compatibility. - Adds legacy structured wrappers for command groups such as
pg_exporter/pg_probe/do/sty. These retain existing interaction behavior while providing structured execution results and captured output. - 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 reliability fixes:
pig build get/pkg/extnow propagates errors and returns non-zero exit codes when downloads or builds fail. Fixes false DEB build failures caused by apg_vermismatch. - Repository/catalog update fixes: adds quiet mirror fallback for
ext/repo reload. Commandsrepo add/set/rmreturn the correct error status when cache updates fail. - Extension management fixes:
ext updatenow uses explicit targets, and status drift issues are fixed.ext importdownloads requested DEB resources to the specified repository directory. - Output/observability fixes: aligns structured-output exit codes with text mode. Improves 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 adds three command groups: pig pg for PostgreSQL, pig pt for Patroni, and pig pb for pgBackRest. It also adds a coordinated PITR command and improves extension availability displays.
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.9.0
Changes
- Rename
pig sty installtopig sty deployso the command name reflects that it runs the Pigsty deployment playbook. - Add the
-g,-p, and-ooptions topig sty conf, aligning it with the configure script available in this release. - Keep
llvmjitin thepgsql-fullpackage alias.
Checksums
| File | Checksum |
|---|---|
| pig-0.9.0-1.aarch64.rpm Linuxarm64SHA-256 | ea0c098d0829720b6e364d2f2a91328876962c7f0ae94eee7bdcde0bd43313fa |
| pig-0.9.0-1.x86_64.rpm Linuxamd64SHA-256 | 707f4e1fde76d3faa05165ac11e97969c22a8740c97ef84da52727d0328990cc |
| pig-v0.9.0.darwin-amd64.tar.gz macOSamd64SHA-256 | 56aeb61674ddfb64368e6f5535e06a38b76f62e3d6c9536a63be7df6babed93e |
| pig-v0.9.0.darwin-arm64.tar.gz macOSarm64SHA-256 | a213d16817d6124ffa83d93ad880a040598b6ed3fe23a74d43420c095ed43de4 |
| pig-v0.9.0.linux-amd64.tar.gz Linuxamd64SHA-256 | 6a1a1836217fa723ca42bc2276ecf1453cd2ee0acacddfc313164701b24a452f |
| pig-v0.9.0.linux-arm64.tar.gz Linuxarm64SHA-256 | 5e5728aa5922138c61c900a731f97cdc1b9653c14d7fe804b6753fb6f222b8b0 |
| pig_0.9.0-1_amd64.deb Linuxamd64SHA-256 | e80d2cb3ceb5fd58fc0262ab4b39b44e8dcccb7712151c73a41ba50cb510353b |
| pig_0.9.0-1_arm64.deb Linuxarm64SHA-256 | ecb504efffde8d696b765579332fc0b3304751fa8077c4c0394e7f3c44aa0fe2 |
Release: https://github.com/pgsty/pig/releases/tag/v0.9.0
v0.8.1
Fix
- Restore
llvmjitto thepgsql-fullpackage alias after it was removed in v0.8.0.
Checksums
| File | Checksum |
|---|---|
| pig-0.8.1-1.aarch64.rpm Linuxarm64SHA-256 | fd9291b15953e8e5f579de7e0256b88ca742e11fc0ed578bf181d2ce4cf5258c |
| pig-0.8.1-1.x86_64.rpm Linuxamd64SHA-256 | c2ec07d18eeae6ad831950da44d6bb797fad3ca4d0b1f7b0e82d715a22baedec |
| pig-v0.8.1.darwin-amd64.tar.gz macOSamd64SHA-256 | b07017d257089166377fb4deffe167c952ae1dcacb6203de26a11a89097dfc34 |
| pig-v0.8.1.darwin-arm64.tar.gz macOSarm64SHA-256 | 090889ba1447693e3ace0b18222f6852448738fc4baa4964a27acc87ce560501 |
| pig-v0.8.1.linux-amd64.tar.gz Linuxamd64SHA-256 | 64cfd28d98c41776c83949b2ffb3b789c66835ccb522a346ea1b53966e9f9544 |
| pig-v0.8.1.linux-arm64.tar.gz Linuxarm64SHA-256 | 6216612ab63c2c9006466834222bdbdcd9e7e8e112c52a6f17e26d0ebb24fbe4 |
| pig_0.8.1-1_amd64.deb Linuxamd64SHA-256 | 29a2109af6141fa990144f0ebcf3bbbe13030c75af6fb3c6bf89eb8da956d387 |
| pig_0.8.1-1_arm64.deb Linuxarm64SHA-256 | 7d8728658c942e57df259acd1da0d2655d9132ab7bffcc109527ed184784f882 |
Release: https://github.com/pgsty/pig/releases/tag/v0.8.1
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 priorities for EL repository definitions. Skips the Docker repository when it is 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
Uses the corrected 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 - Updates the PGDG repository URL. The
extrasdirectory moves to the 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 - Fixes the EL PGDG sysupdate aarch64 repository. The aarch64 repository is now 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
- New PGEXT.CLOUD extension catalog.
- Removes unnecessary sudo calls. Pig can now run inside Docker.
- Allow using
pg18,pg17arg format in pig ext link command - Adds the environment variable
PIG_NO_SUDOto prevent sudo use. - 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
- Updates many extensions to their 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>downloads source, prepares dependencies, and builds in one operation.pig 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 exthas more compact output. It can build RPM packages on EL without a build script.pig 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
- Adds a 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 PIG documentation website.
- 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
- Version output includes the 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
- Fixes OrioleDB on Debian/Ubuntu.
- 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
- Fixes pgvectorscale failures on Debian/Ubuntu with PG17.
- 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
- Updates the extension list to 407 available extensions.
- 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 - Fixes
pig ext scanmatching for several extensions.
Release: https://github.com/pgsty/pig/releases/tag/v0.4.0
v0.3.4
- Routine extension metadata update
- Uses the Aliyun EPEL mirror to replace the 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
This release introduced a PIG homepage alongside 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
New extensions
- pg_documentdb_core and FerretDB
- VectorChord-bm25 (vchord_bm25) 0.1.0
- pg_tracing 0.1.2
- pg_curl 2.4
- pgxicor 0.1.0
- pgsparql 1.0
- pgjq 0.1.0
- hashtypes 0.1.5
- db_migrator 1.0.0
- pg_cooldown 0.1
Extension updates
- citus 13.0.0 -> 13.0.1
- pg_mooncake 0.1.0 -> 0.1.1
- timescaledb 2.17.2 -> 2.18.1
- supautils 2.5.0 -> 2.6.0
- VectorChord 0.1.0 -> 0.2.0
- pg_bulkload 3.1.22 (+pg17)
- pg_store_plan 1.8 (+pg17)
- pg_search 0.14 -> 0.15.1
- pg_analytics 0.3.0 -> 0.3.2
- pgroonga 3.2.5 -> 4.0.0
- zhparser 2.2 -> 2.3
- pg_vectorize 0.20.0 -> 0.21.1
Release: https://github.com/pgsty/pig/releases/tag/v0.2.0
v0.1.4
New extensions
- pg_documentdb_core and FerretDB
- VectorChord-bm25 (vchord_bm25) 0.1.0
- pg_tracing 0.1.2
- pg_curl 2.4
- pgxicor 0.1.0
- pgsparql 1.0
- pgjq 0.1.0
- hashtypes 0.1.5
- db_migrator 1.0.0
- pg_cooldown 0.1
Extension updates
- citus 13.0.0 -> 13.0.1
- pg_mooncake 0.1.0 -> 0.1.1
- timescaledb 2.17.2 -> 2.18.1
- supautils 2.5.0 -> 2.6.0
- VectorChord 0.1.0 -> 0.2.0
- pg_bulkload 3.1.22 (+pg17)
- pg_store_plan 1.8 (+pg17)
- pg_search 0.14 -> 0.15.1
- pg_analytics 0.3.0 -> 0.3.2
- pgroonga 3.2.5 -> 4.0.0
- zhparser 2.2 -> 2.3
- pg_vectorize 0.20.0 -> 0.21.1
Release: https://github.com/pgsty/pig/releases/tag/v0.1.4
v0.1.3
Version v0.1.3 is a routine update with 390 available extensions.
Release: https://github.com/pgsty/pig/releases/tag/v0.1.3
v0.1.2
Includes 351 PostgreSQL extensions, including postgresql-anonymizer 2.0.
Release: https://github.com/pgsty/pig/releases/tag/v0.1.2
v0.1.1
Update Extension List
Release: https://github.com/pgsty/pig/releases/tag/v0.1.1
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
pig manages PostgreSQL packages, local database services, and Pigsty deployments. Choose a command below for your task. Use pig COMMAND --help to see the options supported by your installed program.
- 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
- 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 license: issue and verify Pigsty licenses
- pig status / update / version: inspect environment status, upgrade pig, and print version information
Global options
| Option | Purpose |
|---|---|
-h, --help | Show help |
-H, --home PATH | Select the Pigsty installation directory |
-i, --inventory PATH | Select the inventory |
-o, --output FORMAT | Output format: text (default), json, yaml, or json-pretty |
--debug | Enable debug logging |
--log-level LEVEL | Log level: debug, info (default), warn, error, fatal, or panic |
--log-path PATH | Write logs to a file; the default is the terminal |
PIG-owned results support structured output. Raw-content commands such as inventory show and passthrough commands such as pt list retain their native output. See the command reference for details.
Structured results keep diagnostics and wrapped-tool chatter on stderr. JSON/YAML output and
PIG_NON_INTERACTIVE=1 disable prompt input in PIG-owned command adapters and use sudo -n;
they do not supply destructive-operation confirmation. Pass --yes where required.
Documented data input, such as pig pg psql -f -, remains available. Native Patronictl
forwarding retains its own interaction and output contract and rejects PIG structured-output modes.
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.
pig do
Run Pigsty administration tasks through the corresponding Ansible playbooks. See
pig do for the command reference.
pig pe
Access PostgreSQL monitoring metrics exposed by pg_exporter. The default endpoint is
127.0.0.1:9630; see pig pe for endpoint and operation details.
pig license
pig license issue <name> delivers the newly issued license to its caller. Text output includes
the token; JSON/YAML preserve it in data.captured_output. Successful issuance is an explicit
credential-delivery operation, so that result must be stored as a credential. The signing key is
never included in arguments, parameters, or diagnostics returned in the result. Raw key-loading
errors are replaced with fixed messages. Parameter errors and safe signing-key failure reasons
remain available in text, JSON, and YAML. license status and license verify do not reveal tokens.
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
pig update uses the native package manager on supported Linux distributions. On macOS,
download the new archive and replace the executable as described in Installation.
If ~/.pig/config.yml has a syntax error, fix it before running commands that read configuration, such as pig status. pig version and the pig pe HTTP commands remain available because they do not read this file.
Design records
6 - pig repo
pig repo manages Linux package repositories. Use it to add or remove APT/YUM/DNF sources, refresh indexes, and create or extract offline bundles. repo create also supports macOS through SOW.
| 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 | Linux: sudo/root; macOS: current user |
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
On a host with working OS repositories, add the PostgreSQL repositories and refresh their indexes:
To use the China-region mirrors, add -m:
To replace the host’s repository configuration, use set. It backs up the existing definitions, adds node, infra, and pgsql, then refreshes the indexes:
Use pig repo info pgsql to inspect repository definitions. Use pig repo status to inspect the host’s current configuration.
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 | EL: pgdg-common, pgdg14-18; APT: pgdg |
node | Linux system repositories | base, updates, extras, epel, baseos, appstream… |
infra | Infrastructure component repository | pigsty-infra |
nginx | Nginx repository | nginx |
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 |
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 filters each module by the current operating system and architecture. Run pig repo list to see the available entries.
If the host already has working OS repositories, add pgsql for PGDG and Pigsty extension packages. infra supplies infrastructure tools and some PostgreSQL fork packages. all combines node, infra, and pgsql. Both repo add and repo set select all when no module is given.
repo add, repo set, and repo info accept comma-separated names and surrounding whitespace.
Explicit empty names, including an empty argument or node,, reject the whole request before
repository operations. An empty argument is not equivalent to omitting the arguments.
For repo add and repo set, module names may contain only ASCII letters, digits, underscores, and
hyphens. An unsafe name such as ../escape rejects the whole request before key installation or
repository changes. A syntactically valid but unknown module retains the existing behavior:
repo add adds valid modules and returns failure for unknown ones; repo set and
repo add --remove reject the whole request.
Repository Definitions
The full repository definition bundled with Pigsty is in cli/repo/assets/repo.yml.
Create ~/.pig/repo.yml to override the embedded catalog. Use the source file above as the format reference. repo reload updates this file, so save custom changes before a refresh.
--region selects a regional URL from baseurl. If that region is absent, PIG uses default. -m selects china, including the Pigsty China mirror and other mirrors defined in the catalog.
Trust and configuration ownership
repo add writes the selected module files and preserves other files. repo set and repo add --remove back up and replace the existing definitions. If Ansible or another tool manages these files, keep the definitions in that tool’s configuration so its next run preserves your changes.
Pigsty signing key
When a module includes pigsty-infra or pigsty-pgsql, PIG reuses the existing public-key file or installs its embedded key with mode 0644:
| Platform | Public-key path |
|---|---|
| EL | /etc/pki/rpm-gpg/RPM-GPG-KEY-pigsty |
| Debian / Ubuntu | /etc/apt/keyrings/pigsty.asc |
This step works offline. Selecting only other repositories, such as pgdg or node, does not prepare the Pigsty key.
Built-in repository definitions do not enforce package signatures by default: EL uses gpgcheck=0; Debian/Ubuntu uses trusted=yes. Ordinary repo add/set preserves these settings. pig sty boot enables Pigsty signature checks when key preparation succeeds. To require signatures, configure a trusted key and enable verification in the repository metadata.
If implicit key installation fails, the command warns and continues. The selected Pigsty definitions use trusted=yes, or gpgcheck=0 with repo_gpgcheck=0, and retain their default key reference. Structured results include the warning in data.warnings. APT may retain old indexes in this case; check the cache-update output.
An explicit key reference makes preparation mandatory:
- On Debian/Ubuntu,
signed-bynames existing regular keyring files by absolute path. Separate multiple paths with commas. - On EL,
gpgkeycontains paths or literal URLs, which PIG passes torpm --import. - PIG can install an explicitly referenced default Pigsty key from its embedded copy.
If preparation of an explicit key fails, repository configuration stops. Implicit installation prepares only the file and repository reference; explicit EL gpgkey also imports the key into RPM. See the design record for the rationale.
EL repositories retain DNF module filtering. Definitions with module_hotfixes=1, including Pigsty and PGDG, bypass module streams. PIG omits this key in EL7 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
Back up and remove existing repository definitions, write the selected modules, then refresh package metadata.
This is equivalent to repo add --remove --update. If you omit the modules, PIG uses all.
repo set supports the same --region and -m|--mirror options as repo add.
repo rm
With truly no operands, move all repository definitions to the existing backup directory.
Explicit module operands remove only those module files; all expands to node, pgsql, and
infra, and does not mean every file. Empty strings, whitespace-only operands, empty comma
items, and unsafe names fail before any repository or cache operation, even in a mixed list.
-u updates the cache after either a successful full backup or module removal. Backup and
restore behavior is unchanged.
Removing an already absent module remains successful. The summary reports how many module files
are now absent, without claiming that every request deleted an existing file. Custom module names
remain supported within the repository directory.
If a full backup finds no repository files, the summary reports that there is nothing to back up.
Structured results retain the original operands in requested_modules, including all and comma-separated
arguments; removed_repos lists the expanded modules and their individual outcomes.
| 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 (yum makecache on EL7) |
| Debian | apt-get 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, install SOW first. It runs without sudo, and the default target is the current directory.
On Linux, if SOW is absent, PIG uses createrepo_c on EL or dpkg-scanpackages from dpkg-dev on Debian/Ubuntu.
If SOW runs and fails, PIG returns the error. The 10m timeout limits the wait for SOW’s directory lock.
SOW’s --pigsty mode:
- Scans only top-level regular
.rpmand.debfiles—no recursion and no symlink following. - Removes DEB packages for
i386, and RPM/DEB packages namedpatroniwith upstream version3.0.4. - Generates RPM/DEB metadata and writes
repo_completelast. The marker contains SHA-256 hashes for remaining top-level packages, sorted by basename.
Documentation packages such as annobin-docs are retained unless another cleanup rule applies; a filename containing docs is not a reason to delete a package.
SOW preserves non-package files and directories. It stops if a package cannot be parsed or package coordinates conflict. The legacy backend uses different cleanup rules and records MD5 hashes in repo_complete. PIG checks that this file exists; it does not check its hashes. Use the list to verify package integrity before distributing an offline bundle.
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
An offline bundle must include pigsty and a regular pigsty/repo_complete marker. Missing
requested repositories are skipped and reported separately from the repositories actually included.
Symbolic links are rejected because the native boot extractor accepts only directories and regular
files. A failed cache leaves an existing output package unchanged.
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/
The command extracts into a staging directory, checks target paths, then moves the repositories into place. It moves additional repositories first and pigsty last.
- If a completed
pigsty/repo_completealready exists at the target, PIG reuses that repository. It does not inspect the archive or import its additional repositories. Structured output setsreused: true. - A conflicting target path stops extraction. After an interrupted run, inspect and move any conflicting directories before retrying.
- The archive must contain a regular
pigsty/repo_completefile. PIG checks its presence, not its contents.
repo reload
Download the latest repository catalog from the Pigsty repository sites.
The updated file is placed in ~/.pig/repo.yml.
7 - pig ext
pig ext searches the extension catalog and installs, updates, or removes PostgreSQL extension packages on the host. It also supports PostgreSQL server packages. After installing a package, apply the SQL and configuration required by the extension.
| Command | Description | Notes |
|---|---|---|
ext list | Search extensions | |
ext info | Show extension details | |
ext avail | Show extension availability matrix | |
ext status | Show host-visible extension files/packages | Does not query every database |
ext scan | Scan installed control/library files | Does not query every database |
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
This example uses a running PostgreSQL 18 instance. To install and start one, follow Getting Started.
Add the PostgreSQL repositories, inspect the extension, then install its package:
Enable the extension in the target database. For example:
See the extension list for other extensions.
If an extension requires preloading or other configuration, complete the steps from pig ext info NAME before enabling it.
Select a PostgreSQL installation
-v, --version 18: select a PostgreSQL major version.-p, --path /path/to/pg_config: select an installation by itspg_configpath.- Use one option at a time. When neither is supplied, PIG attempts local PostgreSQL detection. Set
-vexplicitly in automation.
The default PGDG paths are /usr/pgsql-18/bin/pg_config on EL and /usr/lib/postgresql/18/bin/pg_config on Debian/Ubuntu. The package manager resolves RPM/DEB dependencies. -y confirms package operations automatically.
Package and database operations
| Task | PIG operation | Database operation |
|---|---|---|
| Install | ext add NAME | Configure preloading if required, then run CREATE EXTENSION |
| Upgrade | ext update NAME | Follow the extension’s upgrade instructions and run ALTER EXTENSION ... UPDATE |
| Remove | ext rm NAME | Remove or migrate dependencies in affected databases before uninstalling the package |
| Inspect | ext status / ext scan inspect host files | Query pg_extension for enabled database extensions |
| Refresh catalog | ext reload updates extension metadata | None |
pg_available_extensions lists extensions available to the server. pg_extension lists extensions enabled in the current database.
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: select the PG version used to evaluate availability; unavailable entries remain in the list--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
Availability and text/JSON/YAML summaries use the same platform, architecture, and PostgreSQL
version. For platforms covered by a package matrix, that matrix takes precedence; a missing cell
is unavailable. Catalog entries without a matrix retain RPM/DEB metadata and platform-exception
fallbacks. amd64/x86_64 and arm64/aarch64 are equivalent. On macOS, this status describes
declared PostgreSQL version support, not the availability of an RPM/DEB package.
Catalog count
The website and CLI count every catalog record, including packaged SQL utilities such as pg_relation_sql and retained records for removed extensions. The bundled catalog currently contains 603 entries. This total does not mean that every entry supports CREATE EXTENSION or is available on every platform.
The unfiltered list includes every record. Its text row count and JSON/YAML data.count describe the rows returned; a search counts its matches, and --pkg counts leading package records. The global ext avail text summary uses the full catalog total. ext reload reports the number of records in the downloaded catalog through data.extension_count.
The counting decision explains this shared definition. 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 repo.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 extension files/packages visible to the selected PostgreSQL installation on this host.
Options:
-c|--contrib: include contrib extensions in the result
ext scan
Scan the selected PostgreSQL installation’s extension directories.
The command reads control files and related installation paths for the selected PostgreSQL installation.
It also matches shared-library names against catalog metadata, so a catalog entry without a
control file can still be reported as installed. This does not imply CREATE EXTENSION support.
ext add
Install one or more PostgreSQL extensions. Aliases for pig ext add include pig ext install, pig ext ins, and pig ext a. The top-level pig install command also accepts extension aliases and general OS packages.
Use these aliases to select a PostgreSQL package group:
| Alias | Packages |
|---|---|
pg18 | Server, client, contrib modules, and procedural languages |
pg18-server | Server and contrib modules |
pg18-client | Client tools |
pg18-devel | Development files |
pg18-basic | pg_repack, wal2json, and pgvector |
Replace 18 with the required major version. You can also use pgsql with -v 18.
To select a specific package version, use NAME=VERSION with a version available in the configured repository.
Options:
-v|--version: specify PG major version-y|--yes: auto-confirm installation--plan: preview the install plan without running package-manager commands
Successful installation only makes the extension files available on the host. Follow the extension’s ext info hints for preload, restart, and CREATE EXTENSION steps.
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
This removes an OS package, not database objects. Drop or migrate dependent extensions in every affected database before removing the shared files.
ext update
Update the named packages to the versions available from the configured repositories. With no arguments, the command makes no changes.
Options:
-v|--version: specify PG major version-y|--yes: auto-confirm update-m|--mirror: refresh the extension catalog from thepigsty.ccmirror before updating packages; package downloads still use the configured OS repositories
The command does not run SQL migrations. After the package upgrade, follow the extension’s release notes and run ALTER EXTENSION ... UPDATE in each database where appropriate.
ext import
Download extension packages into a local repository for offline installation.
Options:
-d|--repo: local repository directory (default:/www/pigsty)
If some names cannot be resolved, successfully resolved packages are still downloaded, but the
command exits with failure. Structured output preserves requested, resolved packages,
confirmed downloaded packages, and unresolved failed names. A native download failure can
also leave files in the destination; it does not imply rollback or a complete download.
On Debian/Ubuntu, virtual dependency markers such as <virtual-package> are excluded from
the package download list; real package dependencies remain eligible.
JSON/YAML output and PIG_NON_INTERACTIVE=1 use non-interactive sudo. If privilege escalation
requires a password, the command fails instead of waiting for input; configure suitable sudo access first.
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. Load the profile in your current shell:
ext reload
Refresh extension metadata.
The updated catalog is stored at ~/.pig/extension.csv.
8 - pig build
pig build downloads sources, installs dependencies, and produces RPM/DEB packages using Pigsty build recipes. Use it on an EL, Debian, or Ubuntu build host. Rust, pgrx, and the Xray client also support their respective macOS workflows.
| 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 | Current user |
build pgrx | Install and initialize pgrx | Current user |
build proxy | Set up Xray clients and servers | Linux: root; macOS client: regular user |
build get | Download source tarballs | |
build dep | Install extension build dependencies | Requires sudo or root |
build ext | Build extension packages | Current user |
build pkg | Complete pipeline: get, dep, ext | Requires sudo or root |
Quick Start
If the build host needs package repositories, run pig build repo. This backs up and replaces existing repository definitions.
Skip this step if suitable repositories are already configured.
Then install the build tools, download the recipes, and build an extension:
Packages are written under ~/ext/pkg/; RPM outputs may be in architecture subdirectories.
To run each build stage separately:
build pkg combines these three stages. It does not install the general build tools or download build recipes.
Build Infrastructure
Directory Layout
PIG build directories
- ~/ext/
- pkg/
- src/
- log/
- tmp/
- ~/rpmbuild/
- RPMS -> ~/ext/pkg
- SOURCES -> ~/ext/src
- SPECS/
- BUILD/
- BUILDROOT/
- SRPMS/
- ~/debbuild/
- DEBS -> ~/ext/pkg
- SOURCES -> ~/ext/src
- SPECS/
- BUILD/
~/ext/ is the real working directory: pkg stores built packages, src stores source tarballs, and log / tmp hold build logs and temporary files. The platform-specific trees link their output and source directories back into it.
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: 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 bundledchinarepository definitions
build tool
Install development tools and compilers.
Toolsets:
- Minimal (
mini): build tools and libraries, with PostgreSQL and PGDG packages removed from the install list. - Default /
full: Make, CMake, development libraries, packaging tools, and PostgreSQL build dependencies. EL selects PG14-18 server/devel packages; Debian/Ubuntu usespostgresql-allandpostgresql-server-dev-all. --beta: adds explicit PG19 beta server/devel packages.ministill excludes PostgreSQL packages.
build rust
Install the Rust toolchain required by Rust-based extensions.
PIG installs Rust through rustup for the current user, without an interactive prompt. If ~/.cargo/bin/cargo exists, it skips installation unless -y is set. -m uses rsproxy.cn for rustup and writes Cargo mirror configuration, including when Rust is already installed.
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
A matching macOS LaunchAgent generated by the older source without a management comment can
upgrade without --replace. Recognition compares the complete generated plist; a comment alone
does not grant ownership. Foreign or edited service files require --replace --yes. After the
one-time comment migration, identical execution leaves the service running without a restart.
This compatibility statement covers the verified old source format, not every released binary.
Set up Xray clients and servers for build environments with restricted internet access.
The x alias is retained. With no arguments, pig build proxy installs or verifies Xray only.
See the Xray design record for the design rationale.
Client
One command installs Xray if needed, writes the client configuration, starts its service, and checks
HTTPS through both HTTP and SOCKS. The first listener defaults to 127.0.0.1:12345, with HTTP
and SOCKS sharing that port. An omitted --listen preserves the listener of an existing supported
client. The protocol is VLESS over RAW/TCP, REALITY, and xtls-rprx-vision, with a Chrome fingerprint
and multiplexing disabled.
Choose one connection input: a positional URI, direct connection flags, or --from FILE/-.
client.uri is simply a text file containing one standard vless:// URI, with an optional trailing
newline; its name is arbitrary. --from - reads stdin. Do not mix input forms. --pqv supplies
ML-DSA-65 verification when enabled on the server. Unsupported transports, duplicate URI parameters,
and ambiguous inputs are rejected before setup.
On Linux, run setup as root or with sudo, with systemd running and a repository providing the
Pigsty xray package configured first, for example sudo pig repo add infra -u. Setup uses
/etc/xray.json with mode 0640 and ownership root:xray, the xray service account, and a PIG-owned
systemd drop-in. On macOS, run as your regular user with Homebrew available. Setup uses
~/.config/xray/pig-proxy.json with mode 0600 and its own com.pigsty.xray-proxy LaunchAgent.
For an existing server, pass its connection URI directly to client setup:
Repeated setup reuses matching configuration and service state. To replace a different client configuration, use --replace --yes. Use --plan to preview the operation.
After setup, PIG requests https://www.google.com/generate_204 through both HTTP and SOCKS and requires HTTP 204. If the checks fail, PIG restores the previous configuration and service state. Any installed package remains.
The generated shell file defines po, px, and pck. To enable proxy variables in the calling shell:
Server
Server setup supports Linux with the same package, root, and systemd requirements. Require the
advertised public --host and REALITY camouflage --target host:port. The first direct listener
defaults to 0.0.0.0:443; --port changes the advertised public port and first direct listener.
--listen sets an independent bind endpoint. The target must support TLS 1.3 and HTTP/2.
First setup generates a UUID, X25519 key pair, short ID, and ML-DSA-65 seed and verification key. SNI defaults to the --target hostname. Repeated setup preserves these credentials. If you omit --listen, it also preserves the listener; specify --listen to change it. Matching configuration does not restart the service. Conflicting targets or unsupported existing configurations produce an error.
Connection export options:
| Option | Purpose |
|---|---|
--export FILE | Write a client URI with mode 0600; identical content can be exported again, but different content is not overwritten |
--export - | Print the complete client URI on stdout and diagnostics on stderr |
--export-only | Read and export existing configuration without changing files or services; requires --export |
--plan | Preview setup |
Export requires text output. The URI contains client credentials, so pass it through a file or stdin. It does not contain the server’s private key or seed. When exporting an existing server, --host and --port specify the public endpoint the client reaches, not the backend listener.
After setup, test connectivity from a real client. Open the required firewall or cloud security-group rules. --proxy-protocol requires an existing trusted frontend and a loopback listener. PIG does not stop another service that occupies the port or remove an existing V2Ray installation.
Historical VMess form
The historical positional grammar keeps its V2Ray/VMess behavior and first client port 12345:
This Linux compatibility path still needs a repository providing vray, writes /etc/v2ray.json
and /etc/profile.d/proxy.sh, and restarts v2ray. It requires root or sudo; a failed HTTPS check
returns nonzero. The remote user ID is a credential and is redacted from ordinary results.
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: babelfish, agensgraph, orioledb, cloudberry, pgedge, pdu, pgdog, rdkit, onesparse, and libpgfeutils.
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.
For a list such as --pg 17,16, version-specific dependency names are expanded for every
selected major version and duplicates are removed before installation. The same dependency
step is used by build pkg.
build ext
Compile extensions and create installation packages.
For build ext and build pkg, omitting --pg retains version selection from extension
metadata and platform exceptions; Debian/Ubuntu also consider locally installed PG versions.
Package-matrix gaps do not remove build targets. An explicit --pg selects the requested versions.
Debian/Ubuntu builds preserve the inherited PATH order and append the current user’s
~/.cargo/bin when that directory exists, so an explicitly selected toolchain keeps precedence.
Debug packages are enabled by default. Compiled RPM builds normally add debuginfo and
debugsource packages, while Debhelper-based builds normally add a dbgsym package. Pure SQL,
architecture-independent, or recipe-specific builds may have no debug payload to split. A package
recipe can also make a narrower explicit choice; PIG does not rewrite spec files or debian/rules.
Options:
--pg: specify one or more PostgreSQL major versions.--nodbg: disable automaticdebuginfo/debugsourcepackages on RPM builds anddbgsympackages on DEB builds.
build pkg
Download sources, install dependencies, then build each requested package. A source-download failure stops that package. A dependency-install failure produces a warning and the build still runs, because the dependencies may already be present.
Options:
--pg: specify one or more PostgreSQL major versions.--nodbg: disable automaticdebuginfo/debugsourcepackages on RPM builds anddbgsympackages on DEB builds.-m|--mirror: prefer thepigsty.ccmirror when downloading source files.
Common Workflows
Build and install a local package
After preparing the environment in Quick Start, build for the target PostgreSQL version:
Select the package that matches the target PostgreSQL version and architecture, then install it with the system package manager. Replace these placeholder paths with the actual package path:
pig ext add NAME installs from configured repositories. Use a file path as shown above to install the package you just built.
Build a Rust extension
In a prepared build environment, install Rust and the pgrx version required by the recipe for the current user:
Add -m to build rust to use China mirrors. If the recipe requires a specific pgrx version, run pig build pgrx -v VERSION --pg 18. Install the local package as described above.
Build for multiple PostgreSQL versions
PIG produces packages for each major version. Each version needs matching development packages and recipe support.
Build for PostgreSQL 19 beta
Replace EXTENSION with one that supports the selected version. The beta version comes from PIG’s current embedded configuration.
Troubleshooting
| Problem | Action |
|---|---|
| Missing build tools | Run pig build tool; install any additional compiler required by the recipe |
| Missing extension dependencies | Run pig build dep NAME --pg MAJOR; check the reported packages and repositories |
| PostgreSQL headers not found | Run pig ext add pg18-devel, then select the matching target with --pg 18 |
| Wrong pgrx version | Run pig build pgrx -v VERSION --pg MAJOR with the version required by the recipe |
| Stale source archive | Run pig build get NAME -f; first check that the catalog’s source version matches the recipe |
Build logs are in ~/ext/log/. Build time depends on the recipe, CPU, memory, parallelism, and caches. PostGIS, pg_duckdb, and Rust extensions usually need more resources.
9 - pig sty
pig sty installs Pigsty, prepares the controller, generates configuration, and runs deployment playbooks. It also manages dashboards through the Grafana HTTP API.
| Command | Purpose |
|---|---|
sty init | Download and extract Pigsty into an installation directory |
sty boot | Install Ansible dependencies and prepare the controller |
sty conf | Generate and validate an inventory from a template |
sty deploy | Run the deployment playbook |
sty list / sty get | List or download Pigsty releases |
sty grafana | Manage Grafana dashboards, language, and theme; alias gf |
Quick Start
Run these commands on the controller:
deploy starts the playbook immediately and changes the hosts selected by the inventory. See the Pigsty installation guide for the full procedure.
boot also attempts to initialize a missing ~/pigsty directory. Run init first to select a version or path. Use pig inventory to edit and validate an existing configuration.
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--accept-eula: accept the Pigsty Pro EULA without an interactive prompt; applies to Pro releases
sty boot
Prepare Ansible and its Python dependencies, configure online or offline repositories, and check localhost SSH and the Pigsty directory.
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. JSON/YAML output and PIG_NON_INTERACTIVE=1 make sudo
non-interactive; if elevation requires a password, the command fails without waiting for input.
Bootstrap stages
- On Debian 12/13, check and attempt to repair the
en_US.UTF-8locale. - Check that Ansible runs and that its Python environment provides
yaml,jmespath, and eithercryptographyorOpenSSL. - Prepare the selected offline repository. If Ansible is unusable, install controller dependencies and check it again.
- Check helper tools, prepare key-based SSH to
127.0.0.1for the invoking administrator, and attempt to initialize a missing~/pigsty.
PIG prepares a selected or discovered offline repository even when Ansible already works. Use this command to stage offline packages on a 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, discovered, or existing 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. |
PIG selects a source as follows:
--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 complete
/www/pigstyrepository takes precedence over a selected package. If both exist, the existing 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 and installs the node and pigsty controller modules. It reuses or installs
Pigsty’s embedded signing key and enables signature checks when key preparation succeeds.
If implicit-key preparation fails, it records a warning and continues with the selected Pigsty
repositories’ signature checks disabled. With explicit gpgkey or signed-by metadata,
failure to prepare the referenced key is fatal; see pig repo.
Repository replacement and recovery
By default, PIG backs up existing definitions before writing new ones. If repository setup or package installation fails, it attempts to restore the backup and reports the result. --keep preserves existing definitions and allows a fallback to them if an online refresh fails.
Ansible installation or validation failure makes the command fail. Incomplete SSH, locale, or Pigsty-directory setup produces warnings.
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
-o json or -o yaml returns a pig.sty.boot/v2 result with Ansible state, mode, sources, repository recovery results, localhost SSH, Pigsty directory status, and warnings.
See Pigsty offline installation for the offline procedure.
sty conf
Generate an inventory from a template under <PIGSTY_HOME>/conf. The command edits the YAML configuration, validates the complete result, and writes the output atomically with mode 0600.
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 paths
Template names are relative to <PIGSTY_HOME>/conf. The .yml suffix is optional; for example, use ha/full. Use a relative name without ...
Relative output paths resolve under <PIGSTY_HOME>. Absolute paths are also accepted. The output must be a different file from the template and cannot be a symlink. A parsing, transformation, or validation error leaves the existing output unchanged.
Structural mutations
The command applies these changes to the template:
| Input | Configuration change |
|---|---|
--ip A,B,... | Replaces 10.10.10.10 through 10.10.10.19 with up to ten distinct addresses, in order. Replacements are simultaneous; other VIPs remain unchanged. |
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, using values already present in the template. |
--proxy | Reads HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, and NO_PROXY, each falling back to its lowercase spelling. Missing HTTP/HTTPS values fall back to ALL_PROXY. Writes non-empty values to all.vars.proxy_env and supplies a default no-proxy list 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 creates a duplicate key fails. PIG warns if a supplied address has no matching placeholder in the template.
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
PIG checks the operating system, package manager, controller resources, SSH, sudo, and Ansible. --port selects the SSH check port. --skip bypasses administrator SSH/sudo preflight and preserves placeholder IPs; other checks still run.
The output must pass inventory validation. If ansible-inventory is available, PIG also uses it to parse the result. Argument, template, and validation errors prevent writing. Issues that allow configuration to continue are reported as warnings.
Structured output
-o json or -o yaml returns pig.sty.configure/v1, including the template, output path, region, IPs, domain, SSH port, PostgreSQL versions, and warnings. Generated passwords are written only to the inventory; the result lists their identifiers.
See the Pigsty configuration guide for the procedure.
sty deploy
sty deploy uses the Inventory source already selected by configuration. -i and
PIGSTY_INVENTORY relative paths resolve from the invoking directory; quoted ~/ expands from
the user’s home. The selected absolute path is passed with -i, including the default source,
while Ansible runs in Pigsty home. A missing source fails without fallback. Deploy still
requires a regular file; dynamic source execution remains Ansible’s responsibility.
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.
The playbook starts immediately, without a confirmation prompt. Review the selected inventory before running it.
sty list
List available Pigsty versions.
A version prefix selects the highest matching stable version as the starting point, using the
same completion rule as sty get. Matching respects component boundaries (1.1 does not match
1.10). Exact versions, including prereleases, and latest keep their existing meaning.
sty get
Download the Pigsty source tarball.
sty grafana
pig sty grafana (alias gf) manages dashboards through the HTTP API. The optional PATH selects a Grafana root directory, one direct subdirectory, or one dashboard JSON file. The default is <PIGSTY_HOME>/files/grafana.
Select the operation scope
listshows all dashboards in the current organization.loadcreates or updates dashboards by UID from local files and preserves other remote dashboards.bootrenames the current organization to Pigsty, stars the existingpigstydashboard, and makes it the organization and current-user home.initloads the complete dashboard root, then runsboot. Useloadfor a single folder or file.dump -d DIRexports to a chosen directory.--dirand positionalPATHare mutually exclusive.clean PATHdeletes remote dashboards declared by that local path.clean --alldeletes every dashboard and folder in the current organization.styleacceptsdark,light, orauto.
Preview the deletion scope, then confirm it:
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) |
Choose --password or --password-file; they are mutually exclusive. Without either option, PIG uses GRAFANA_PASSWORD, then 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:
Each format uses its corresponding API:
- 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 are unsupported. To preserve v2 format during export, keep the existing local v2 file.
Design records
10 - pig inventory
pig inventory (alias pig inv) inspects, edits, and validates the Pigsty inventory, pigsty.yml. It also checks deployment prerequisites and exchanges configuration with PostgreSQL through the experimental cmdb commands.
When you edit a fragment, PIG preserves the YAML content and formatting outside that fragment. Before saving, it parses the complete file again. If parsing fails or another process has changed the original file, PIG keeps the original and reports an error.
| 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) |
Use global -i, --inventory to select the inventory or -H, --home to select the Pigsty directory. Without these options, PIG resolves the source from its configuration and the Pigsty directory. Commands support structured results with -o json or -o yaml, except show, which always prints the selected YAML verbatim.
Source selection
PIG selects the first configured source in this order. If a selected source is missing or invalid, PIG reports that problem instead of falling through to another inventory.
| Priority | Source | Base for a relative path |
|---|---|---|
| 1 | -i, --inventory PATH | Current working directory |
| 2 | PIGSTY_INVENTORY | Current working directory |
| 3 | inventory in ~/.pig/config.yml | Resolved Pigsty home |
| 4 | [defaults] inventory in the Pigsty home’s ansible.cfg | Directory containing ansible.cfg |
| 5 | pigsty.yml | Resolved Pigsty home |
PIG expands ~/ before resolving the path, including a quoted path in ansible.cfg.
pig inv status reports the selected source without executing it. Static Inventory operations
require a supported YAML source. pig do can forward a directory or executable inventory
to Ansible; pig sty deploy requires a regular file. Both pass the resolved
path explicitly to Ansible, so it cannot silently select a different default.
Quick Start
inv status / list / show
status inspects the source without executing a dynamic inventory. list shows groups, hosts, keys, and value types. show prints actual values, including any passwords in the selected configuration. Adding -o json does not change its YAML output.
Selectors
list / show / edit accept an optional selector that addresses one fragment:
inv edit
Open the selected fragment in $EDITOR. After you save and exit, PIG restores the indentation and newline style, parses the complete document, checks for concurrent changes, and replaces the original file atomically. If parsing fails, PIG keeps the temporary file so you can correct it.
| Option | Description |
|---|---|
--from | Replace the selected fragment from a regular file or stdin (-), skipping the editor |
The saved file belongs to the current user. PIG removes group and other permissions, usually producing mode 0600, and preserves stricter owner-only permissions. The structured result’s mode_tightened field reports this change.
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 ansible-inventory |
--timeout | Timeout for --ansible compatibility validation (default 10s) |
Validation follows Pigsty’s configuration rules, including requirements for admin_ip, the infra group, and host addresses. The file must contain one YAML document with no duplicate keys. These parsing rules also apply to show and edit.
pg_users[].roles accepts role names and objects containing name, optional
state (grant, revoke, absent), and nullable boolean admin, set, and inherit.
Editing, serialization, and CMDB YAML export preserve strings that look like YAML 1.1 scalars,
including "1:30", "010", dates, and timestamps supplied as strings. Necessary quotes prevent
downstream YAML consumers from changing their types. Existing unquoted or explicitly tagged timestamps
retain their source bytes and use the opaque unknown scalar kind; quote them when a string is intended.
show and explicit CMDB exports retain their raw-data contract.
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 |
--user and --port use explicit arguments or the defaults above. They do not infer effective SSH variables from the inventory. Combine profiles with commas, for example --profile ansible,ssh.
inv diff
Compare the active inventory with another file. The result lists added, removed, and changed declarations by path and value type, without configuration values:
inv cmdb (experimental)
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 (confirmation required over existing schemas; --plan previews) |
load | Replace all CMDB declaration rows from the static inventory (one transaction; confirmation required; --plan/--strict) |
dump | Export the CMDB as a static inventory file (--force to overwrite a differing target) |
enable | Switch the ansible.cfg inventory to the CMDB (inventory.sh) |
disable | Switch back to the static pigsty.yml (both support --plan) |
init runs cmdb.sql and replaces existing pigsty / pglog schemas. Back up data you need to retain before running it. load replaces all declaration rows in one transaction. Interactive mode asks you to confirm the target; use --yes for automation and structured output. Use --plan to inspect the operation first.
Design records
11 - pig do
pig do runs administration playbooks from the selected Pigsty directory. It uses the inventory to add clusters, create databases and users, install packages, or remove services.
Define the target configuration in the inventory first, then run the corresponding command. The commands invoke Ansible directly. This command group has no general --plan mode.
Inventory selection is shared with sty deploy. PIG passes the resolved
source to Ansible without interpreting it again relative to Pigsty home. Missing explicit,
environment, or default sources fail before playbook execution. Existing directory and executable
Inventory sources remain Ansible inputs; static Inventory commands do not execute them.
Command overview
| Command | Purpose | Required arguments |
|---|---|---|
pgsql-add | Add a PostgreSQL cluster or instances | cluster, optional IPs |
pgsql-rm | Remove a PostgreSQL cluster or instances | cluster, optional IPs |
pgsql-db | Apply a database declaration | cluster, database |
pgsql-user | Apply a user declaration | cluster, user |
pgsql-ext | Install extensions through Pigsty | cluster, optional extensions |
pgsql-hba | Refresh PostgreSQL HBA rules | cluster |
pgsql-svc | Refresh PostgreSQL service definitions | cluster |
pgmon-add / pgmon-rm | Add or remove a remote monitoring target | cluster |
node-add / node-rm | Add or remove selected nodes | one or more selectors |
node-repo | Configure repository modules on selected nodes | optional selector and modules |
node-pkg | Install or update packages on selected nodes | selector, optional packages |
repo-build | Rebuild the Pigsty infrastructure repository | none |
redis-add / redis-rm | Add or remove Redis clusters, nodes, or instances | selector, optional ports |
Run pig do COMMAND --help for the aliases and exact examples of one operation.
PostgreSQL operations
pgsql-db and pgsql-user apply existing pg_databases and pg_users declarations. They do not edit the inventory. pgsql-rm --uninstall also removes packages. Omit this option if the host still needs those packages.
Name rules
| Object | Accepted names |
|---|---|
| PostgreSQL cluster | Letters, digits, and hyphens; start with a letter or digit. root, all, and ungrouped are reserved. |
| PostgreSQL user | Up to 63 characters; start with a lowercase letter or _, then use lowercase letters, digits, _, @, ., or -. postgres is reserved. |
| Database | Up to 63 characters; start with a letter or _, then use letters, digits, _, @, ., or -. |
These rules apply to arguments that require a cluster, user, or database name. Selector arguments support the target-selection forms below.
Node and repository operations
Selectors may be cluster names, host names, IP addresses, or another selector form supported by the Pigsty playbook. Their meaning comes from the active Inventory.
With no selector, node-repo applies to every host targeted by node.yml. With no module, it uses the Inventory setting. Repository modules come from the installed Pigsty release, such as local,
infra, pgsql, node, and extra. Check that the required repositories are available to the
target nodes before installing packages.
Redis operations
redis-rm --uninstall also removes packages during node or cluster removal.
Configuration and output
pig do uses the global PIG options:
| Option | Purpose |
|---|---|
-H, --home | Select the Pigsty home directory |
-i, --inventory | Select the Pigsty Inventory |
-o, --output | Choose text, JSON, YAML, or pretty JSON result wrapping |
--log-level, --log-path | Configure PIG diagnostics |
Structured mode reports the requested operation and captured execution result. The underlying Ansible and playbook behavior is still determined by the installed Pigsty release.
See the Pigsty documentation for full playbook variables and procedures.
12 - pig postgres
pig postgres (alias pig pg) manages local PostgreSQL instances and databases.
Use it to initialize or control an instance, run SQL, maintain tables, and create database copies.
Use pig pt for Patroni cluster operations and pig pitr for recovery with pgBackRest.
Commands run as the PostgreSQL operating-system user, normally postgres.
Install PostgreSQL first. For a new data directory, make its parent writable by that user or
create an empty directory with the correct ownership before running pg init.
Command Overview
Instance control:
| 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 ... |
Database Maintenance:
| Command | Alias | Description | Notes |
|---|---|---|---|
pg vacuum | vac, vc | Vacuum tables | Runs SQL VACUUM |
pg analyze | ana, az | Analyze tables | Runs SQL ANALYZE |
pg freeze | Freeze vacuum | Runs SQL VACUUM (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 |
Connect to an instance
For a running instance at /pg/data, check its status and connect:
Use the instance’s actual data directory. In psql, run SQL commands, then type \q to exit.
To install PostgreSQL and create a test instance, follow Getting Started.
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 for instance operations | Data directory path |
--dbsu | -U | postgres | PostgreSQL operating-system user; $PIG_DBSU overrides the default |
Use pig pg svc ... to control the postgres systemd unit. Use the instance commands
(start, stop, and so on) to operate on -D with pg_ctl, defaulting to /pg/data.
An explicit empty or whitespace-only -D / --data is a parameter error; it does not select a default target.
When -D is explicitly supplied, psql, ps, kill, vacuum, analyze, freeze, and repack
connect to that directory’s instance, including database enumeration for --all. Before using its recorded
port and socket, PIG verifies that the PID is live and identifies a PostgreSQL process.
Missing, stale, invalid, or mismatched metadata and unknown process identity fail before a SQL
client runs, without falling back to another connection target.
Without -D, these SQL commands retain native client connection defaults and any PGHOST/PGPORT
visible to the client; PIG does not add host or port arguments or bind the connection to /pg/data.
To explicitly target a TCP-only instance, use the native client with connection options.
pg clone and pg fork retain their separate port options.
Plans, confirmation retries, and verification commands for promote, vacuum, and repack
preserve the selected data directory, PostgreSQL version, and operating-system user. This includes
an explicit -D /pg/data; omitting -D continues to preserve native SQL connection defaults.
VACUUM FULL plans report confirmation as required, matching execution.
Generated maintenance commands put the database name after --, so a name such as --all
cannot become an option when the command is copied and executed.
PIG_NON_INTERACTIVE=1 and JSON/YAML output disable prompt stdin and use non-interactive sudo.
Native passthrough retains its interaction contract; explicit data input such as psql -f -
remains available.
Version Detection Logic:
- If
-vspecified, use that version - Otherwise read from
PG_VERSIONfile in data directory - Otherwise use the default PostgreSQL installation found by PIG.
Service Control Commands
pg init
Initialize PostgreSQL data directory. Wraps initdb.
- Use an empty directory, or a path that the database operating-system user can create.
- Data checksums are enabled. Use
-Kto disable them. - Encoding is UTF8. PostgreSQL 17+ uses the built-in
C.UTF-8locale. Earlier versions use the systemC.UTF-8locale when available, otherwiseC. - An initialized directory requires
--force, which removes its existing data after confirmation. A running instance cannot be overwritten. If its running state cannot be verified, initialization fails before removal and reports the probe error instead of claiming that PostgreSQL is running. - Put extra
initdbarguments after--. To choose another locale or encoding, runinitdbdirectly.
Options:
| Option | Short | Default | Description |
|---|---|---|---|
--no-data-checksums | -K | false | Disable data checksums |
--force | -f | false | Remove an initialized directory and initialize it again |
--yes | -y | false | Skip overwrite confirmation when used with --force |
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 | Startup log; default /tmp/pig-pg-start.log |
--timeout | -t | Wait timeout: $PGCTLTIMEOUT, then 60 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 svc stop to stop the manager first, then check the PostgreSQL state.
Options:
| Option | Short | Default | Description |
|---|---|---|---|
--mode | -m | fast | Shutdown mode: smart/fast/immediate |
--timeout | -t | 60 | Wait timeout in seconds; $PGCTLTIMEOUT overrides the default |
--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 the selected instance’s state:
Text output includes pg_ctl status, a compact pg_controldata summary, processes owned by the
database operating-system user, and related services. The postgres row reflects the selected
instance’s process state. Service rows cover patroni, pgbouncer, vip-manager, and haproxy.
Structured output describes the selected instance, including its data directory, version, PID, port, and available control-file information.
A missing process or a PID independently identified as a different executable is stale.
EPERM alone never proves that PostgreSQL has stopped. If process identity cannot be established,
the state remains unknown and cannot authorize forced initialization or PITR restore.
Plans report an indeterminate running-state check as unknown, without a usable PID or a passed
precondition. pg status returns 130201 (exit 3) for permission failures and 130808
(exit 1) for other status-probe failures, such as invalid PID metadata or unavailable process identity.
These results have success: false; their partial data does not establish that PostgreSQL is stopped.
Stale PIDs no longer make PIG report an unrelated process as PostgreSQL; pg_ctl and PostgreSQL
retain their own lock-file checks and may still require operator cleanup after a crash.
A PID file copied from another directory does not identify the selected instance.
pg promote
Timeline reporting uses the selected instance’s port and socket. If its PID metadata cannot be resolved, PIG reads that directory’s control data or leaves the timeline unknown. This does not change promotion execution or its primary-role success check.
Promote a standby or a paused recovery instance to a writable primary.
Use --plan to inspect the action. Text mode requests confirmation; structured execution requires --yes.
Options:
| Option | Short | Description |
|---|---|---|
--timeout | -t | Wait timeout: $PGCTLTIMEOUT, then 60 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):
- Target process detection: Read the selected
postmaster.pid, then inspect only that postmaster’s process tree - Bound SQL query: Use the selected instance’s port/socket and verify
data_directorybefore trustingpg_is_in_recovery() - Data directory check: Check for
standby.signal,recovery.signal,recovery.conffiles
File-based role detection does not establish whether PostgreSQL is running. A stopped instance can still report its configured role, but a stale PID file never makes it appear alive. If the running-state probe fails, the command returns an error instead of reporting a role as verified.
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 |
With -D, PIG reads that directory’s postmaster.pid as the selected operating-system user.
It verifies the live process before connecting to the recorded port and Unix socket.
A stopped or uncertain target returns an error. Without -D, psql retains its native connection
defaults and any PGHOST/PGPORT visible to it.
For -o json or -o yaml, specify -c or -f; interactive psql uses text mode.
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 non-client background processes |
--cancel | -c | Cancel queries instead of terminating |
--watch | Repeat every N seconds | |
--plan | Preview execution plan without terminating connections |
--state accepts known connection states, including idle in transaction (quote values with spaces).
--query matches query text without case sensitivity. A positive --pid selects that process
and takes precedence over other filters. Without filters, the command selects other client sessions;
--all also includes non-client backends.
pg clone
Create a database copy in the same instance. The command terminates sessions on the source database
before copying, so schedule it when that interruption is acceptable. It uses CREATE DATABASE ... TEMPLATE;
PostgreSQL 15+ adds STRATEGY FILE_COPY. PostgreSQL 14 is also supported with its default copy strategy.
Options:
| Option | Short | Description |
|---|---|---|
--port | PostgreSQL port, default 5432 or $PG_PORT | |
--conn-db | Connection database: postgres, or 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 |
On PostgreSQL 18+ with file_copy_method=clone and a compatible filesystem, the copy can use
copy-on-write (CoW). Otherwise it uses an ordinary copy. Use pg fork to copy an entire instance.
Filesystem preflight runs as the selected database system user, including for a private 0700 data directory.
Text mode requests confirmation; structured execution requires --yes.
Database Maintenance Commands
The [dbname] operand of vacuum, analyze, freeze, and repack accepts a database name.
Values containing = or starting with postgres:// or postgresql:// are rejected as connection
strings before planning, confirmation, or execution; errors do not echo the value.
With --all, vacuum, analyze, and freeze validate the full database list before any maintenance runs.
Use the native client when you need a connection string. Spaces and non-ASCII database names remain supported.
For names beginning with -, put all options first and use -- before the name, for example
pig pg vacuum --full --plan -- --all previews the single database named --all.
pg vacuum
Run SQL VACUUM through psql. The default database is postgres.
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) |
--plan | Show the operation without executing it | |
--yes | -y | Skip VACUUM FULL confirmation |
For vacuum and freeze, combine --schema with --table to select a table.
To process a whole schema, use native vacuumdb --schema SCHEMA.
--full rewrites tables and needs an exclusive lock. Text mode asks for confirmation;
structured execution requires --yes.
pg analyze
Run SQL ANALYZE through psql to update planner statistics. The default database is postgres.
Options:
| Option | Short | Description |
|---|---|---|
--all | -a | Process all databases |
--schema | Specify schema | |
--table | -t | Specify table |
--verbose | -V | Verbose output |
pg freeze
Run SQL VACUUM (FREEZE) through psql to freeze old transaction IDs. The default database is postgres.
Options: Same as pg analyze.
pg repack
Rebuild tables with pg_repack. Install the executable and the extension in each target database.
The default database is postgres.
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 starting values for memory, parallelism, and WAL settings. PIG uses the PostgreSQL version, CPU count, memory, disk capacity, and selected workload profile. The storage formulas assume SSDs. The command prints recommendations; it does not edit configuration files.
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 includes a success message. Copy only the parameter assignments into your configuration; do not redirect the complete output into a PostgreSQL config file.
- For scripts, use
-o jsonand readdata.parameters. Review the values, apply them through your configuration workflow, then reload or restart PostgreSQL as required.
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.
- The target cannot be
/,/pg, source PGDATA, or a parent/child of source PGDATA. Symlinks are resolved before checking the source/destination relationship./pg/datafollows the same ownership, relationship, and runtime checks as other data directories. - Replacing a nonempty unmanaged target requires valid unmanaged
pg_forkmetadata infork.jsonwith an explicitly recordedtarget.datamatching the directory. An arbitrary directory withoutPG_VERSIONis not eligible for deletion. Missing, damaged, incomplete, or mismatched metadata is refused. An empty directory remains usable with--force. Managed forks must be replaced by name. A running or uncertain destination cannot be replaced. Forced removal by name still permits cleanup of a managed orphan under/pg/data-<name>. - Path validation resolves private directories as DBSU when the caller cannot traverse them; unresolved paths and source/destination aliases are refused.
- Unmanaged fork removal checks an inaccessible target as the selected DBSU. The target must be a real directory; a symlink or failed check still prevents removal.
- 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, orphan, or unknown. Unknown state sets runtime_unknown: true in structured output without claiming that the fork has started. Lifecycle operations fail without rewriting metadata in that state.
JSON and YAML put fork records in the result’s data array. Records include 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 |
If the log directory is not readable, PIG retries through sudo.
Use pg log -o json or pg log show -o json for JSONL snapshots.
Snapshots do not support YAML or json-pretty; tail, less, and grep use text output.
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 |
--follow | -f | false | Accepted for compatibility; tail always follows |
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) controls the postgres systemd unit used by Pigsty.
It requires that unit to exist. For distribution units such as postgresql-18 or
postgresql@18-main, use systemctl with the actual unit name.
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 |
Tools and privileges
PIG uses initdb to initialize data, pg_ctl to control instances, psql for SQL and maintenance,
pg_repack to rebuild tables, and system tools to read logs. Use those tools directly for options
that this command does not expose.
PostgreSQL commands run directly when you are the selected database operating-system user.
From root, PIG uses su; from another account, it uses sudo -H -u. Service management uses root privileges.
These commands target Linux; service management requires systemd.
Design records
13 - pig patroni
pig patroni (alias pig pt) runs the installed patronictl command.
Use it to inspect cluster members, change cluster configuration, and switch the primary.
PIG selects the configuration file and provides local service, status, and log commands.
Other commands use patronictl’s arguments, prompts, output, and exit codes.
Install Patroni and configure access to its cluster before running cluster operations.
Use pig pt COMMAND --help for native command help, or pig pt -- --help for patronictl root help.
Running pig pt alone shows PIG’s 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 (cluster name comes first) |
pig pt pause CLUSTER / pig pt resume CLUSTER | Enter / leave maintenance mode |
pig pt show-config CLUSTER / pig pt edit-config CLUSTER | Show / edit cluster dynamic configuration |
pig pt query -c 'select 1' | Native query (-c here is query’s own SQL option) |
Put the cluster name before member names. These commands use the installed patronictl interface.
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 | Shortcut for pt svc start |
pt stop | dn | Shortcut for pt svc stop |
pt log | l | View local Patroni logs (show / tail / grep) |
Use pig pt restart CLUSTER to restart PostgreSQL through Patroni.
Use pig pt svc restart to restart the local Patroni daemon.
Inspect a cluster
On a configured Patroni node, inspect the cluster members and dynamic configuration.
Replace pg-meta with your cluster name:
Use pig pt status to inspect the local service and pig pt log -f to follow its logs.
PIG options
These PIG 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 |
Use the full --dbsu option; pig pt has no -U shorthand.
Config-File Resolution
PIG selects the patronictl configuration file 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);- otherwise
/etc/patroni/patroni.yml; patronictl reports a missing file.
PIG uses an explicit path or environment path even if the file is missing or unreadable. It resolves relative paths before switching operating-system user. It checks the two conventional paths as the selected user. Service commands and native help do not need a configuration file.
Command dispatch and output
PIG handles the local commands listed above. It forwards any other command and every argument after that command to patronictl. Put PIG options before the native command:
Native commands keep interactive prompts, editor sessions, streamed output, and exit codes.
Use the native --format json option for JSON. PIG’s -o json and -o yaml cannot format
these commands and are rejected before the native command token.
Use pig pt -- COMMAND ... to forward a command whose name matches a local command.
The local set, status, and service commands support PIG structured output.
Log output has the formats described below.
pt set
pt set updates the cluster selected by the configuration file:
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 configuration diff and one confirmation:
--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 (including the values you supplied);- in structured output mode, execution requires an explicit
--yes; - 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 |
pt start / pt stop (aliases up / dn) call the same service actions. 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); -f, tail, and grep use text output. Log snapshots do not support YAML or json-pretty.
| 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 | Lines for show/tail; grep searches all lines unless -n is set |
--log-dir | auto | Log directory |
Migrating from v1.5.x
When upgrading from v1.5.x, update older scripts to use patronictl syntax:
| 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 confirmation) | 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) |
Requirements and privileges
Service commands require Linux and systemd. Log commands need readable Patroni log files.
PIG runs patronictl as the operating-system user selected by --dbsu, then $PIG_DBSU,
then postgres. It executes directly as that user, uses su from root, or uses sudo -H -u
from another account. Service management uses root privileges.
Design record
Let Patronictl Speak for Itself records why PIG stopped mirroring the upstream command tree and which local responsibilities remain.
14 - pig pe
Use pig pe to read metrics from a running pg_exporter
and reload its configuration. The full command name is pig pg_exporter.
Aliases are pe, pgexp, and pgexporter.
Select an exporter
The default endpoint is http://127.0.0.1:9630. Use these options to select another instance:
| Option | Default | Description |
|---|---|---|
--host | 127.0.0.1 | Host name or IPv4 address |
-p, --port | 9630 | HTTP port |
PIG uses HTTP and the standard /metrics, /stat, and /reload paths.
For HTTPS, authentication, client certificates, or a custom path, use an HTTP client such as curl.
pe get
Read /metrics. Print samples whose names start with pg_, plus their Prometheus HELP and TYPE lines.
To include process and runtime metrics that do not start with pg_, read the complete endpoint:
pe list
Read /metrics. Print one HELP line for each pg_ metric family in the response.
The list reflects the exporter’s current configuration.
pe stat
Read /stat and print its response. The response format depends on the installed pg_exporter version.
pe reload
After editing the exporter’s configuration, request a reload through /reload:
Output and errors
Use -o json or -o yaml for a PIG result that contains the command’s text output.
Prometheus metrics remain text inside that result.
Network errors, response-read errors, and HTTP 4xx/5xx responses return a nonzero exit code. HTTP error details contain the status code and standard description, without the response body. Successful responses retain the filtering or raw text behavior described above.
To install pg_exporter, use pig ext add pg-exporter. Configure and start the exporter before
using pig pe; these commands access its HTTP API.
15 - pig pgbackrest
pig pgbackrest (alias pig pb) creates backups, restores data, and manages pgBackRest stanzas.
It runs pgBackRest as the PostgreSQL operating-system user, selected by --dbsu or $PIG_DBSU
(default postgres).
Before the first backup, install pgBackRest and configure the stanza and repository in pgbackrest.conf.
A stanza groups the backup configuration for one PostgreSQL cluster.
In PostgreSQL, enable archive_mode and set archive_command to call pgBackRest.
Use pig pitr when recovery must also stop Patroni and PostgreSQL, then restart PostgreSQL.
Use pig pb restore when you manage those steps yourself.
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 and configuration |
Backup & Restore:
| Command | Alias | Description | Implementation |
|---|---|---|---|
pb backup | b | Create backup | pgbackrest backup |
pb restore | r | Restore backup files | 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 and its backups | pgbackrest stanza-delete |
Control Commands:
| Command | Alias | Description | Implementation |
|---|---|---|---|
pb check | ck | Check stanza configuration and WAL archiving | 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 |
Create the first backup
After configuring pgBackRest and WAL archiving, create the stanza and check the configuration:
If the check succeeds, create a full backup and inspect it:
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 | PostgreSQL operating-system user (default: $PIG_DBSU or postgres) |
Stanza Auto-Detection:
If -s is not specified, PIG 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. PIG checks that the local instance is a primary before running pgBackRest.
Options:
| Option | Short | Description |
|---|---|---|
--force | -f | Skip primary role check |
Backup Types:
| Type | Description |
|---|---|
| (empty) | Use pgBackRest configuration; by default, incremental, or full when no full backup exists |
| 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 |
A replica, stopped instance, or unknown role fails this check. Use --force only when you intend
to delegate role handling to your pgBackRest configuration. It skips the PIG check; pgBackRest still
applies its own backup requirements.
pb expire
Remove backups and WAL archives according to the configured retention policy.
Use an exact backup label with --set; this also expires backups that depend on that set.
WAL retention still applies during this operation. See the pgBackRest expire reference.
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 |
--plan runs a pgBackRest dry run. With structured output, the PIG plan includes the dry-run
output when it is available. Review that output to see the affected backups.
Retention Policy:
Retention policy is configured in pgbackrest.conf:
Restore Commands
pb restore
Restore backup files into the target data directory. PostgreSQL must be stopped.
Select exactly one recovery target: -d, -I, -t, --name, --lsn, or --xid.
A missing target returns an error; text mode also shows help.
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.
Set the target, data directory, stanza, repository, and config through PIG options.
PIG rejects native arguments that would override them, including --repoN-* and --recovery-option.
Pass other restore options after --, for example --delta, --tablespace-map, --link-map, or --link-all.
Use -- --delta to restore over an existing data directory with checksum-based file reuse.
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
For a standalone instance at /pg/data, inspect the plan, stop the instance, then restore:
For another path, pass the same -D to each command. Verify the recovered data before promotion.
When Patroni is active for the managed directory, pb restore refuses the operation;
use pig pitr.
Text mode asks for y or yes before restore. In scripts with -o json or -o yaml,
add --yes to execute, or use --plan to inspect the operation.
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 |
Deletion permanently removes the selected stanza’s backups. In text mode, enter y or yes
to confirm, or use --yes. Structured execution requires --yes.
When the configuration has several stanzas, select one with --stanza.
Control Commands
pb check
Check stanza configuration, repository access, and WAL archiving.
This command checks:
- WAL archive configuration correctness
- Repository accessibility
- Stanza configuration validity
check does not read every backup file to verify its contents. Use pgBackRest
verify when you need backup and archive checksum verification.
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 | Follow with pb log; pb log tail always follows |
Permission Handling:
If the current user does not have permission to read the log directory, the command automatically retries with sudo.
Paths and privileges
| Setting | Default |
|---|---|
| Configuration file | /etc/pgbackrest/pgbackrest.conf |
| Log directory | Configured log-path, then /pg/log/pgbackrest |
| Restore data directory | --data, configured pg1-path, $PGDATA, then /pg/data |
PIG runs pgBackRest directly when the current user is the selected database operating-system user.
From root, it uses su; from another account, it uses sudo -H -u.
The user must be able to read the configuration and access the data and repository paths.
These commands use Linux and Pigsty defaults. Set the configuration path and stanza explicitly
for other layouts. For pgBackRest operations without a PIG command, run pgbackrest directly.
Design record
PIG’s Operations CLI Safety Contract explains the boundary between
the low-level pb restore primitive and the orchestrated pig pitr workflow.
16 - pig pitr
Use pig pitr to restore a local PostgreSQL instance from pgBackRest backups.
For a managed restore, PIG stops services as needed and restores the data.
By default, it then starts PostgreSQL and leaves Patroni stopped for you to verify the recovered database.
Recovery replaces data in the target directory. Start with --plan to check the directory,
backup source, recovery target, and service actions.
Before recovery
You need an installed pgBackRest, a readable configuration file, a usable backup,
and the archived WAL needed to reach the target. The default config path is
/etc/pgbackrest/pgbackrest.conf. Select another file with -c and a stanza with -s.
Run the commands on the host that contains the target data directory. PIG runs PostgreSQL and
pgBackRest operations as --dbsu, then $PIG_DBSU, then postgres.
Service operations require root privileges, directly or through sudo.
| Task | pig pitr | pig pb restore |
|---|---|---|
| Stop Patroni for a managed restore | Automatic if active | Operator stops it |
| Stop PostgreSQL | Checks and stops it | Requires it to be stopped |
| Restore backup files | pgBackRest | pgBackRest |
| Start PostgreSQL | Automatic unless --no-restart | Operator starts it |
| Return the instance to Patroni | Operator verifies and resumes management | Operator handles it |
Use pig pb restore when you want to manage service shutdown and startup yourself.
Quick start
This example restores an existing managed data directory to a chosen time. Replace the timestamp with your recovery target:
--delta lets pgBackRest restore over an existing directory by comparing file checksums.
PIG asks for y or yes before recovery. Use --yes for execution without a prompt.
For a time, name, LSN, transaction ID, or immediate target, PostgreSQL normally pauses when it reaches the target. Inspect the data before promotion. See post-recovery actions.
Parameters
Recovery target
Choose exactly one target. Without a target, PIG returns an error and shows help in text mode.
| Option | Short | Description |
|---|---|---|
--default | -d | Recover to the end of available WAL |
--immediate | -I | Recover to the backup consistency point |
--time | -t | Recover to a timestamp |
--name | Recover to a named restore point | |
--lsn | Recover to an LSN, such as 0/7C82CB8 | |
--xid | Recover to a positive transaction ID |
--set selects a backup; it does not select a recovery target.
Backup and target options
| Option | Short | Description |
|---|---|---|
--set | -b | Backup label from pig pb info |
--target-action | Action at the target: pause, promote, or shutdown | |
--target-timeline | -T | Timeline: latest, current, a positive integer, or 0xHEX |
--exclusive | -X | Stop before a time, LSN, or transaction ID target |
Use --no-restart with --target-action=shutdown. Start PostgreSQL manually when you are ready
for WAL replay; it will shut down after reaching the target.
--target-action cannot be combined with --default. --exclusive requires --time, --lsn, or --xid.
Flow control
| Option | Short | Default | Description |
|---|---|---|---|
--no-restart | false | Leave PostgreSQL stopped after restoring files | |
--plan | false | Inspect the plan without changing data or services | |
--yes | -y | false | Skip confirmation |
--timeout | 120 | Startup and recovery wait timeout, in seconds | |
--force-stop | false | Allow immediate shutdown and process termination if fast shutdown fails |
Configuration
| Option | Short | Default or source |
|---|---|---|
--stanza | -s | First stanza in the config file; specify it when several exist |
--config | -c | /etc/pgbackrest/pgbackrest.conf |
--repo | -r | Repository selected by pgBackRest |
--dbsu | -U | PostgreSQL operating-system user: $PIG_DBSU, then postgres |
--data | -D | Target directory; configured pg1-path, then $PGDATA, then /pg/data |
Native restore options
Put extra pgBackRest arguments after --:
Use PIG flags for the recovery target, data directory, config, stanza, and repository.
Arguments that override these settings are rejected, including --repoN-* and --recovery-option.
Other restore options, such as --delta, --tablespace-map, --link-map, and --link-all, can be forwarded.
Time format
PIG fills in missing date or timezone fields using the local date and timezone:
| Format | Example | Interpretation |
|---|---|---|
| Full timestamp | 2025-01-01 12:00:00+08 | Explicit date, time, and timezone |
| No timezone | 2025-01-01 12:00:00 | Local timezone; a T separator also works |
| Date only | 2025-01-01 | Midnight on that date |
| Time only | 12:00:00 | That time today |
Use a full timestamp with timezone in scripts. Plans and suggested follow-up commands expand short forms to a full timestamp so that rerunning the command keeps the same target.
Managed directory and side restore
The managed directory comes from pg1-path in the selected stanza, then $PGDATA, then /pg/data.
It must already contain an initialized PostgreSQL instance. An explicit -D that resolves to this
same path is still a managed restore, including a symlink to it.
An explicit -D that resolves to a different path selects a side restore.
PIG leaves Patroni and the managed instance alone. The side directory must exist, belong to the
selected operating-system user, and be writable by that user. It can be empty.
The -D option selects only the data directory. If the backup contains tablespaces or external links, map them to separate paths.
Add pgBackRest’s --tablespace-map and --link-map options after -- in the restore command.
A side restore requires --no-restart. The restored configuration retains the original port;
start it manually with a free port:
pig pg psql -D reads the restored directory’s postmaster.pid to select its port and socket.
It returns an error if it cannot resolve that instance.
Execution flow
- Validate options, configuration, target directory, stanza health, and available backups.
If
--setis given, check that the backup label exists. - Show the operation and request confirmation, unless
--yesis given. - For a managed restore, stop an active Patroni service.
- Wait for PostgreSQL to stop, then retry fast shutdown if needed. Use
--force-stopto allow immediate shutdown and a final process-termination attempt. - Run
pgbackrest restore. - Start PostgreSQL unless
--no-restartis given. For--defaultor--target-action=promote, wait untilpg_is_in_recovery()is false. For other targets, verify recovery progress yourself. - Print commands for data verification and the remaining recovery steps.
Declining confirmation or reaching EOF returns CodePITRConfirmationRequired (161001, exit
status 7) before stopping Patroni or PostgreSQL, restoring data, or starting PostgreSQL.
An indeterminate PostgreSQL runtime state is an error, not proof that the instance is stopped. PIG will not restore over an unverified instance or use an unverified PID for forced termination. After restoration, an unknown runtime state cannot count as successful startup and prevents follow-up SQL checks against an unverified connection target.
--plan runs the prechecks and returns the planned actions. It needs access to the configuration,
data directory, and backup repository, but does not stop services or restore data.
More examples
Run one recovery command for the target you need:
Post-recovery actions
Connect to the restored instance. Use its actual data directory:
Check recovery state, then verify the tables and records you need:
If recovery is paused at the intended target and you want a writable primary, promote it:
For a Patroni-managed cluster, reconcile the restored instance with the cluster’s recovery plan, then resume Patroni with
pig pt svc start. Handle other members and application routing as part of that plan.
If a managed restore fails after stopping Patroni, Patroni stays stopped. The target directory can contain a partial restore. Inspect PostgreSQL and pgBackRest logs, fix the failure, and complete recovery before starting Patroni. A startup timeout also needs investigation; it does not undo the restored files.
Structured output
Use --plan -o json to inspect a structured plan. Use --yes -o json to execute without interaction.
YAML is also available.
Successful results include requested_data_dir, effective_data_dir, managed_data_dir, and
side_restore in data. Follow-up commands are in the result’s top-level next_actions field.
Design record
PIG’s Operations CLI Safety Contract explains the separate roles of
pig pb restore and pig pitr.