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 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 list
pig ext list vector -o json
pig help inventory edit
pig repo
Manage APT/YUM repositories for PostgreSQL packages. See pig repo for details.
pig repo list # list available repositoriespig repo info pgdg # show repository detailspig repo status # check current repository statuspig repo add pgdg pigsty -u # add repositoriespig repo rm old-repo # remove repositorypig repo update # update package cachepig repo create /www/pigsty # create local repositorypig repo cache # create offline packagepig repo boot # bootstrap from offline package
pig ext
Manage PostgreSQL extensions and kernel packages. See pig ext for details.
pig ext list duck # search extensionspig ext info pg_duckdb # extension detailspig ext status # show installed extensionspig ext add pg_duckdb -y # install extensionpig ext rm old_extension # remove extensionpig ext update pg_duckdb # update the named extension packagepig ext scan # scan installed extensionspig ext import pg_duckdb # download for offline usepig ext link 17# link PG version into PATHpig ext reload # refresh extension catalog
pig build
Build PostgreSQL extensions from source. See pig build for details.
# Environment setuppig build spec # initialize build specspig build repo # configure repositoriespig build repo --beta # configure repositories and add PostgreSQL 19 beta repopig build tool # install build toolspig build tool --beta # install build tools plus PG19 beta build packagespig build rust -y # force reinstall Rust (default does not reinstall)pig build rust -m # use China mirror mode and write Cargo mirror configpig build pgrx # install PGRX frameworkpig build pgrx -b # include PostgreSQL 19 beta pg_config during auto-detectionpig build proxy # install or verify Xraypig build proxy client --from ./client.uri
pig build proxy server --host proxy.example.com --target www.sraoss.co.jp:443 --export ./client.uri
# Build extensionspig build pkg citus # complete build pipeline = get + dep + extpig build get citus # download sourcepig build dep citus # install dependenciespig build ext citus # build package
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 install pg_duckdb # install extension and translate package namepig install pg18 # install PostgreSQL 18 kernel package grouppig install nginx htop vim # install multiple system packagespig install unknown-package -n # disable translation and use raw package namepig install pg18 --plan # preview installation planpig install vector -y # auto-confirm installation
pig sty
Install the Pigsty distribution. See pig sty for details.
pig sty init # install Pigsty to ~/pigstypig sty boot # install Ansible prerequisitespig sty conf -g # generate configuration with random passwordspig sty deploy # run deployment playbookpig sty list # list available Pigsty releasespig sty get 4.5.0 # download the embedded Pigsty releasepig sty grafana list # manage Grafana dashboards (info/list/boot/load/init/dump/clean/lang/style)
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 inventory status # inspect the active inventory sourcepig inventory list # list inventory topology and value kindspig inventory show # show verbatim inventory YAML (may contain secrets)pig inventory edit # edit the inventory (or one fragment) in $EDITORpig inventory validate # validate one complete static Pigsty inventorypig inventory check # check inventory and local controller readinesspig inventory diff other.yml # compare declarations without emitting valuespig inventory cmdb check # check the PostgreSQL CMDB (experimental)
pig do
Run Pigsty administration tasks through the corresponding Ansible playbooks. See
pig do for the command reference.
pig do pgsql-add <cls> [ip...]# add cluster or instancespig do pgsql-rm <cls> [ip...]# remove cluster or instancespig do pgsql-db <cls> <dbname> # create or update databasepig do pgsql-user <cls> <username> # create or update userpig do pgsql-ext <cls> [ext...]# install extensionspig do node-pkg <sel> [pkg...]# install node packages
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 pe list # list available metric typespig pe get # get all pg_ prefixed metricspig pe stat # show exporter statisticspig pe reload # reload pg_exporter configurationpig pe --host 127.0.0.1 -p 9630 get
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 context # text outputpig context -o json # JSON outputpig context -m postgres # only output PostgreSQL module (host included by default)pig context -m postgres,!host # exclude host module
pig pg
Manage the local PostgreSQL server. See pig pg for details.
pig pg init # initialize data directorypig pg start # start PostgreSQLpig pg stop # stop PostgreSQLpig pg status # check statuspig pg psql mydb # connect to databasepig pg ps # show current connectionspig pg vacuum mydb # vacuum databasepig pg tune -p olap # generate tuned parameterspig pg fork dev # create a local one-off physical forkpig pg fork list # list local forkspig pg log tail # tail logs in real time
pig pt
Run patronictl transparently to manage Patroni HA clusters. See pig pt for details.
pig pt list pg-meta # list cluster members (native passthrough)pig pt show-config pg-meta # show cluster dynamic config (native passthrough)pig pt setttl=60# local sugar: update Patroni/PG settingspig pt restart pg-test --pending # apply pending restarts (native passthrough)pig pt status # local: combined service and cluster statuspig pt log -f # local: tail logs in real time
pig pb
Manage pgBackRest backup and restore. See pig pb for details.
pig pb info # show backup informationpig pb ls # list all backupspig pb backup # create backuppig pb backup full # full backuppig pb restore -d # restore to latestpig pb restore -t "2025-01-01"# restore to a specific timepig pb log tail # tail logs in real time
pig pitr
Run orchestrated point-in-time recovery (PITR). See pig pitr for details.
pig pitr -d # recover to latest datapig pitr -t "2025-01-01 12:00:00+08"# recover to a specific timepig pitr -I # recover to backup consistency pointpig pitr -d --plan # show execution plan without runningpig pitr -d -y # skip confirmation for automation
Helper Commands
pig status # show current environment statuspig status -o json # structured status outputpig update # upgrade pig itself to the latest versionpig update -m # upgrade using the pigsty.cc mirrorpig update -v X.Y.Z # upgrade to a version published by the configured repositorypig version # show pig version informationpig version -o json # structured version output
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.