Configuration generator
pgmoneta-config is a standalone command line tool for generating and managing pgmoneta configuration files. It works directly on the configuration file without requiring a running pgmoneta instance.
Usage
pgmoneta-config
Configuration utility for pgmoneta
Usage:
pgmoneta-config [ -o FILE ] [ COMMAND ]
Options:
-o, --output FILE Set the output file path for the init command (default: ./pgmoneta.conf)
-q, --quiet Generate default options without prompts (for init)
-F, --force Force overwrite if the output file already exists
-V, --version Display version information
-?, --help Display help
Commands:
init Generate a pgmoneta.conf file interactively
get <file> <section> <key> Get a configuration value
set <file> <section> <key> <val> Set a configuration value
del <file> <section> [key] Delete a section or a key
ls <file> [section] List sections or keysinit
Generate a new pgmoneta.conf configuration file interactively. The user will be prompted for required values such as host, base directory, compression, logging, and PostgreSQL server connection details.
Command
pgmoneta-config initQuiet mode
Use the -q flag to generate a template with default values without prompts.
pgmoneta-config -q initOutput path
Use -o to set the output file path.
pgmoneta-config -o /etc/pgmoneta/pgmoneta.conf initForce overwrite
If the output file already exists, use -F to force overwrite.
pgmoneta-config -q -F -o /etc/pgmoneta/pgmoneta.conf initGenerated file
The generated configuration file contains a [pgmoneta] section with the main settings and one or more server sections with PostgreSQL connection details.
Example output
[pgmoneta]
host = *
metrics = 5001
base_dir = /home/pgmoneta/backup
compression = zstd
retention = 7
log_type = file
log_level = info
log_path = /tmp/pgmoneta.log
unix_socket_dir = /tmp/
[primary]
host = localhost
port = 5432
user = repl
wal_slot = replget
Get a configuration value from a file.
Command
pgmoneta-config get <file> <section> <key>Example
pgmoneta-config get pgmoneta.conf pgmoneta compressionset
Set a configuration value in a file. Creates the section and key if they do not exist. Preserves existing comments and formatting.
Command
pgmoneta-config set <file> <section> <key> <value>Example
pgmoneta-config set pgmoneta.conf pgmoneta compression lz4Adding a new server section
pgmoneta-config set pgmoneta.conf replica host 192.168.1.10
pgmoneta-config set pgmoneta.conf replica port 5432
pgmoneta-config set pgmoneta.conf replica user repldel
Delete a specific key from a section, or delete an entire section.
Command
pgmoneta-config del <file> <section> [key]Delete a key
pgmoneta-config del pgmoneta.conf pgmoneta compressionDelete an entire section
pgmoneta-config del pgmoneta.conf replicals
List all sections within a configuration file, or list all keys within a specific section.
Command
pgmoneta-config ls <file> [section]List all sections
pgmoneta-config ls pgmoneta.confList keys in a section
pgmoneta-config ls pgmoneta.conf pgmonetaSafety features
Atomic writes
All write operations use atomic file replacement. Changes are first written to a temporary file, flushed to disk with fsync, and then atomically renamed over the target file.
File permissions
Generated and modified configuration files are set to 0600 permissions to protect sensitive credentials.
Comparison with pgmoneta-cli conf
pgmoneta-cli conf set/get manages the live runtime configuration of a running pgmoneta daemon over the management socket.
pgmoneta-config set/get manages the configuration file on disk without requiring a running daemon. This is useful for initial setup, provisioning, and offline editing.