This chapter covers several topics associated with managing a PostgreSQL database system, including starting
and stopping the PostgreSQL backend, initializing the filesystem, and the creation, removal, and maintenance of individual
databases. There is also a section devoted to the topic of backing up and restoring data from a database.
In this section we cover two options provided with PostgreSQL that are used to start and stop PostgreSQL. The first is
a general purpose application called
pg_ctl
, which should function identically on any machine,
regardless of the system. This script is intended to be run by the system user (e.g., the user who owns the data directory)
configured to execute the
postmaster
backend.
The second script provided is the
SysV
-style script, found in the
contrib/start-scripts
subdirectory within the PostgreSQL source path. The installation of the
SysV
script is discussed in Chapter 2. By default this script is
named
linux
, as it is intended for a Linux system's start-script directory, though in the installation instructions
it is renamed to a script called
postgresql
in the system's service start-up directory (e.g.,
/etc/rc.d/init.d
).
The main functional difference between
pg_ctl
and the SysV-style service script is that
pg_ctl
is intended to be used by the user who runs the
postmaster
backend
(e.g.,
postgres
), whereas the service script is intended to be run by the
root
user.
The service script is not strictly Linux-specific, and should be compatible with most systems based on SysV start-up
scripts. However, if you are not running Linux, you may prefer to stick with the
pg_ctl
script.