Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bnnanet/pg-essentials
Utilities for managing PostgreSQL databases, including multi-tenant scenarios.
https://github.com/bnnanet/pg-essentials
Last synced: about 2 months ago
JSON representation
Utilities for managing PostgreSQL databases, including multi-tenant scenarios.
- Host: GitHub
- URL: https://github.com/bnnanet/pg-essentials
- Owner: bnnanet
- License: mpl-2.0
- Created: 2024-09-15T02:29:22.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-11-10T04:07:25.000Z (about 2 months ago)
- Last Synced: 2024-11-10T05:17:12.576Z (about 2 months ago)
- Language: Shell
- Size: 41 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pg-essentials
Utilities for managing PostgreSQL databases, including multi-tenant scenarios.
# Table of Contents
- psql-example-connect
- pg-build-linux
- pg-build-macos
- pg-install
- pg-register-service
- pg-addgroup
- pg-adduser
- psql-store-credential
- pg-passwd
- psql-backup## psql-example-connect
Copy, paste, & season to taste! \
(basically just an alias for connecting to a specific db)## pg-build
Statically\* compiles postgres for linux or macos.
```text
pg-build v1.0.0 - builds a portable, relocatable postgres from sourceUSAGE
postgres-buildEXAMPLE
postgres-build 'custom' 17.0
```\* it's not really _static_, but rather _bundled_ or _vendored_ - the dependencies are included in the `./lib/` folder.
## pg-install
```text
pg-install v1.0.0 - installs postgres via apt-get or apkUSAGE
pg-installEXAMPLE
pg-install 16
```## pg-register-service
```text
pg-register-service v1.0.0 - register a postgres daemon for the current userUSAGE
pg-register-service [operating-system-user]EXAMPLE
pg-register-service 5432 app
```## pg-addgroup
```text
pg-addgroup v1.0.0 - add a group role to hba for remote users with samename dbsUSAGE
pg-addgroup [hostssl|host|etc] [group-name] [pg-port]EXAMPLE
pg-addgroup hostssl remote_users 5432NOTE
use 'host' rather than 'hostssl' if you terminate postgres' tls via proxy
```## pg-adduser
```text
pg-adduser v1.0.0 - adds a remote user (and db of the same name) to a group roleUSAGE
pg-adduser [port] [group-name]EXAMPLE
pg-adduser 'foobar' 5432 'remote_users'NOTES
- usernames consist of a prefix + random hex string
- each username has exactly 1 database of exactly the same name
- passwords are random base58 (url-safe) strings
```## psql-store-credential
```text
psql-store-credential v1.0.0 - stores a credential in ~/.pgpassUSAGE
[space] pg-addpass [pg-url]EXAMPLES
Prompt for PG_URL string
pg-addpass
Prefix with space and give PG_URL string
pg-addpass 'postgress://user:pass@host:port/db?sslmode=verify-full'
Parse PG_URL from .env file
cat .env | grep PG_URL | cut -d'=' -f2- | pg-addpassNOTES
- query parameters will be *ignored* (ex: ?sslmode=)
- passwords with ':' or '@' will not be parsed correctly
(you may be able to enter them into ~/.pgpass manually)WARNING
remember to clear this command from your shell history if
you don't want the password to be saved there
(some shells omit commands if you prefix them with a space)
```## pg-passwd
```text
pg-passwd v1.0.0 - reset a user's passwordUSAGE
pg-passwd [port]EXAMPLE
pg-passwd foobar-xxxxxx 5432
```## psql-backup
```text
psql-backup v1.0.0 - creates portable (across instances) SQL schema & data backupsUSAGE
psql-backup [host] [port] [dbname]EXAMPLE
psql-backup 'foobar-xxxxxx' 'pg-1.example.com' 5432 'foobar-xxxxxx'NOTES
- the username and database name should typically be the same
```# Copying
Copyright (c) 2024 AJ ONeal \
Licensed under the MPL-2.0