mentat.module.backup module¶
This Mentat module is a script providing PostgreSQL database backup functions and features.
This script is implemented using the pyzenkit.zenscript
framework and
so it provides all of its core features. See the documentation for more in-depth
details.
Usage examples¶
# Display help message and exit.
mentat-backup.py --help
# Run in debug mode (enable output of debugging information to terminal).
mentat-backup.py --debug
# Run with increased logging level.
mentat-backup.py --log-level debug
Available script commands¶
backup
(default)Perform backup of data of all configured collections within configured time interval thresholds.
remote-mount
Mount the remote backup storage to local mount point and exit.
remote-unmount
Unmount the remote backup storage from local mount point and exit.
status
Determine the status of backup files on the remote storage.
Custom configuration¶
Custom command line options¶
--no-upload
Do not upload the backup file to remote storage (flag).
Type:
boolean
, default:False
--mount-point dir-name
Name of the mount point directory.
Type:
string
, default:/media/du-store
--temp-dir dir-name
Name of the log file.
Type:
string
, default:/var/tmp
--backup-dir dir-name
Name of the log file.
Type:
string
, default:/var/mentat/backups
--remote-host user@host.domain.org
SSH connection string for the remote host to which to sychronize backups.
Type:
string
, default:None
--remote-dir dir-name
Directory path on the remote host to which to sychronize backups.
Type:
string
, default:None
Backup script requirements¶
To enable backup synchronization to remote machine, SSH access without password
must be configured and accessible for the mentat
system user. Additionally,
the sshfs
package must be installed on local machine.
Backup structure¶
This script produces .tar.gz
compressed archives for each run. Each archive
contains backups for following databases:
- main database
This database us backupped using native
pg_dump
command and may be restored with itspg_restore
counterpart.Resources: https://www.postgresql.org/docs/current/static/backup-dump.html
- event database
This database is backupped only selectively using
psql
utility. This constraint is due to the possibly huge size of the whole database, to instead the incremental approach is used.
-
class
mentat.module.backup.
MentatBackupScript
[source]¶ Bases:
mentat.script.base.MentatBaseScript
Implementation of Mentat module (script) providing database backup functions and features.
-
CONFIG_BACKUP_DIR
= 'backup_dir'¶
-
CONFIG_MOUNT_POINT
= 'mount_point'¶
-
CONFIG_NO_UPLOAD
= 'no_upload'¶
-
CONFIG_REMOTE_DIR
= 'remote_dir'¶
-
CONFIG_REMOTE_HOST
= 'remote_host'¶
-
CONFIG_TEMP_DIR
= 'temp_dir'¶
-
cbk_command_backup
()[source]¶ Implementation of backup command (default).
Perform backup of data of all configured collections within configured time interval thresholds.
-
cbk_command_remote_mount
()[source]¶ Implementation of the remote-mount command.
Mount the remote backup storage to local mount point and exit.
-
cbk_command_remote_unmount
()[source]¶ Implementation of the remote-unmount command.
Unmount the remote backup storage from local mount point and exit.
-