Skip to content

Getting started with pgs3

Install pgs3, launch a local S3 endpoint inside PostgreSQL, and walk through uploading, overwriting, deleting, and recovering an earlier version with mc (MinIO Client) in three minutes.

1. Install pgs3

Install the pgs3 package on a Linux PostgreSQL 17–19 server (PG16 is best effort; see Downloads for platform availability):

pig repo add pgsql -u
pig ext add pgs3

Need to build from source or spin up a test container instead? See Build from source or Docker.

2. Enable the extension and start the endpoint

Connect to your database as an administrator, create an unprivileged tenant role with an S3 key pair, and start the HTTP worker pool:

CREATE EXTENSION IF NOT EXISTS pgs3;

CREATE ROLE pgs3_demo NOLOGIN NOINHERIT
    NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS;

SELECT pgs3.create_credential('PGS3DEMOKEY01', 'change-me-in-production-secret', 'pgs3_demo');
SELECT pgs3.start();

Confirm that the HTTP workers are listening on 127.0.0.1:9000:

SELECT worker_kind, status, listen_addr, port
FROM pgs3.worker_state
ORDER BY worker_kind;
 worker_kind | status  | listen_addr | port
-------------+---------+-------------+------
 gc          | running |             |
 http        | running | 127.0.0.1   | 9000
 http        | running | 127.0.0.1   | 9000
 launcher    | running |             |

pgs3.start() starts a dynamic pool for the current database without editing postgresql.conf. For persistent endpoints that boot with PostgreSQL, see Automatic startup.

3. Upload, version, and recover with mc

Using the MinIO Client (mc, packaged as mcli on some Linux distributions), register the local endpoint with SigV4 and path-style addressing (--path on):

  1. Add the alias and create a bucket:

    mc alias set pgs3 http://127.0.0.1:9000 PGS3DEMOKEY01 change-me-in-production-secret --api S3v4 --path on
    mc mb pgs3/demo
  2. Upload a file and read it back:

    printf 'v1: hello pgs3\n' > hello.txt
    mc cp hello.txt pgs3/demo/notes/hello.txt
    mc cat pgs3/demo/notes/hello.txt
    v1: hello pgs3
  3. Overwrite the object and delete it—pgs3 keeps versioning permanently enabled, so an ordinary delete writes a delete marker instead of losing history:

    printf 'v2: updated\n' > hello.txt
    mc cp hello.txt pgs3/demo/notes/hello.txt
    mc rm pgs3/demo/notes/hello.txt
    mc ls --versions pgs3/demo/notes/hello.txt
    [2026-12-01 04:01:12 UTC]     0B 3 DEL v3 notes/hello.txt
    [2026-12-01 04:01:08 UTC]    12B 2 PUT v2 notes/hello.txt
    [2026-12-01 04:01:02 UTC]    15B 1 PUT v1 notes/hello.txt
  4. Recover the first revision by its version ID (1):

    mc cat --version-id 1 pgs3/demo/notes/hello.txt
    v1: hello pgs3

4. Clean up

When you are done testing, stop the worker pool and remove the local alias:

psql -c 'SELECT pgs3.stop()'
mc alias rm pgs3
rm -f hello.txt

Next steps