# 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.

---

LLMS index: [llms.txt](/llms.txt)

---

## 1. Install pgs3 {#packages}

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

```bash
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](/docs/pgs3/operations/#source).

## 2. Enable the extension and start the endpoint {#start}

<a id="manual"></a>
<a id="automatic"></a>

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

```sql
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`:

```sql
SELECT worker_kind, status, listen_addr, port
FROM pgs3.worker_state
ORDER BY worker_kind;
```

```text
 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](/docs/pgs3/operations/#automatic).

## 3. Upload, version, and recover with mc {#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:

   ```bash
   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:

   ```bash
   printf 'v1: hello pgs3\n' > hello.txt
   mc cp hello.txt pgs3/demo/notes/hello.txt
   mc cat pgs3/demo/notes/hello.txt
   ```

   ```text
   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:

   ```bash
   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
   ```

   ```text
   [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`):

   ```bash
   mc cat --version-id 1 pgs3/demo/notes/hello.txt
   ```

   ```text
   v1: hello pgs3
   ```
{.steps}

## 4. Clean up {#cleanup}

<a id="upgrade"></a>

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

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

## Next steps {#next}

- [Connect S3 clients](/docs/pgs3/clients/) — Full recipes for `mc`, `rclone`, Python (`boto3`), DuckDB (`httpfs`), and `s3fs`.
- [SQL, versioning, and tenants](/docs/pgs3/workflows/) — Commit objects in SQL transactions, restore versions, fork buckets, and isolate multiple tenants.
- [Deploy and operate](/docs/pgs3/operations/) — Automatic startup, Nginx TLS proxy, backups, upgrades, and source/container builds.
- [Performance and limits](/docs/pgs3/performance/) — Benchmark charts against MinIO and hard operational boundaries.

---

Backlinks:

- [S3 clients](/docs/pgs3/clients/)
- [Package downloads](/download/)
