1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
.\" Copyright (c) 2022, 2026 Stefan Kreutz <mail@skreutz.com>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.Dd $Mdocdate: April 15 2026 $
.Dt TEMP-POSTGRES 1
.Os
.Sh NAME
.Nm temp-postgres
.Nd temporary PostgreSQL server
.Sh SYNOPSIS
.Nm temp-postgres
.Op options
.Op Fl -
.Op Ar command
.Sh DESCRIPTION
The
.Nm
utility runs the PostgreSQL server off a temporary data directory.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl h , -help
Print help.
.It Fl d , -dbname Ar dbname
Database name.
Defaults to the name of the effective user.
.It Fl u , -username Ar username
PostgreSQL user name.
Defaults to the name of the effective user.
.El
.Pp
.Nm
can optionally execute a given
.Ar command
once the PostgreSQL server is ready.
If so,
.Nm
will pass the following environment variables to the
.Ar command :
.Bl -tag -width Ds
.It Ev PGHOST
Absolute path to the directory in which the UNIX domain socket file is stored.
.It Ev PGDATABASE
Database name.
.It Ev PGUSER
PostgreSQL user name.
.It Ev DATABASE_URI
Connection URI.
.It Ev DATABASE_URL
Connection URI.
.El
.Pp
See also the
.Lk https://www.postgresql.org/docs/current/libpq-envars.html "environment variables used by libpg" ,
and the
.Lk https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS "connection URI scheme understood by libpg" .
.Sh EXIT STATUS
.Ex -std temp-postgres
.Sh EXAMPLES
Create and serve a temporary database:
.Bd -literal -offset indent
$ temp-postgres
.Ed
.Pp
Specify a database name, and PostgreSQL user name:
.Bd -literal -offset indent
$ temp-postgres --dbname myproject --username alex
.Ed
.Pp
Wrap the
.Xr psql 1
command to connect to the temporary database once the server is ready:
.Bd -literal -offset indent
$ temp-postgres -- psql
.Ed
.Sh SEE ALSO
.Xr postgres 1 ,
.Xr psql 1
.Sh AUTHORS
.An Stefan Kreutz Aq Mt mail@skreutz.com
|