FBUPKEEP - Firebird server & database maintenance utility

FBUPKEEP is a Python library that provides a task executor engine and a command-line tool to execute tasks. Its primary purpose is to run maintenance tasks for Firebird ® servers and databases, but could be easily extended to run other tasks of various type.

Built-in tasks:

  • Logical (gbak) database backup and restore.
  • Database sweep.
  • Collection of database statistics (gstat).
  • Update index statistics in database.
  • Rebuild of user indices in database.
  • Removal of old files.

FBUPKEEP is designed to run on Python 3.5+, and uses FDB Firebird driver.

Installation

From PyPI:

pip install fbupkeep

Content

Usage Guide

Basics

FBUpkeep is a Python library that provides a task executor engine and a command-line tool to execute tasks. Its primary purpose is to run maintenance tasks for Firebird ® servers and databases, but could be easily extended to run other tasks of various type.

Tasks are simple Python classes inherited from Task and registered into fbupkeep_tasks entry point group (in setup.py). Tasks are parameterized by the configuration file (using standard configparser Python library module).

Tasks are managed and executed by TaskExecutor which is parametrized using the configuration file and options that are typically provided as argparse.Namespace.

Module fbupkeep.runner provides fbupkeep command-line utility to work with task executor.

Tasks are executed in named jobs (batch) that run one or more tasks in specified order on single taget (Firebird server or database). Each job could be configured to work with different target.

The fbupkeep script

The fbupkeep script is automatically created in the python scripts directory (it should be in your PATH by default) when you install the library, so you can use it directly.

usage:

fbupkeep [-h] [--version] [--create-config FILENAME]
              [--host HOST] [-u USER] [-p PASSWORD]
              [-c CONFIG] [-o DIR] [--dry-run]
              [-v] [-q] [-l {critical,fatal,error,warn,warning,info,debug,notset}]
              [--log-only]
              job_name
optional arguments:
-h, --help show this help message and exit
--version show program’s version number and exit
--create-config FILENAME
 Create configuration file for job and exit (default: None)
positional arguments:
job_name:Job name
Firebird server/database connection arguments:
--host HOST Server host (default: localhost)
-u USER, --user USER
 User name (default: sysdba)
-p PASSWORD, --password PASSWORD
 User password (default: masterkey)
run arguments:
-c CONFIG, --config CONFIG
 Configuration file (default: fbupkeep.cfg)
-o DIR, --output-dir DIR
 Force directory for log files and other output (default: ${here}/${job_name})
--dry-run Prepare execution but do not run tasks (default: False)
output arguments:
-v, --verbose Verbose output (default: False)
-q, --quiet No screen output (default: False)
-l {critical,fatal,error,warn,warning,info,debug,notset}, –log-level {critical,fatal,error,warn,warning,info,debug,notset}
Logging level (default: WARNING)
--log-only Suppress all screen output including error messages (default: False)
Configuration file

The fbupkeep script can’t work without configuration file. By default, fbupkeep uses the fbupkeep.cfg configuration file from current working directory, but you can specify other file by -c or –config command-line option.

Tip

fbupkeep provides –create-config option to create default configuration file for a job.

for example:

fbupkeep --create-config employee.cfg employee

will create file employee.cfg for job employee (i.e. contains section [upkeep_employee])

File structure

A configuration file consists of sections, each led by a [section] header, followed by key/value entries separated by = or : string. Section names are case sensitive but keys are not. Leading and trailing whitespace is removed from keys and values. Values can be omitted, in which case the key/value delimiter may also be left out. Values can also span multiple lines, as long as they are indented deeper than the first line of the value.

Important

FBUpkeep uses named jobs. Each job must have it’s own [upkeep_<jobname>] section with configuration for task executor and used tasks.

Individual tasks may use additional sections with their own conventions.

Tip

The convenient way is to use the database name as a job name. For example job name employee for employee database.

Configuration files may include comments, prefixed by # and ; characters. Comments may appear on their own on an otherwise empty line, possibly indented.

Important

The backslash is a special escape character in Python, so it must be doubled if you want to use backslash itself (for example in Windows path specifications).

The DEFAULT section

The DEFAULT section is a special section. If configuration options is not found in specific section, its looked up in DEFAULT section, and if foud there, the value defined there is used.

On execution fbupkeep script automatically adds next options to the default section:

job_name = [job_name option value]
here = [current working directory]
host = [--host option value, default: localhost]
user = [--user option value, default: 'ISC_USER' env. variable or 'sysdba']
password = [--password option value, default: 'ISC_PASSWORD' env. variable or 'masterkey']
output_dir = [--output-dir option value, default: ${here}/${job_name}]
filename = ${job_name}-%Y%m%d

You can freely use these options for interpolation in your configuration.

If you define any from these options in default section, its value would be ignored (replaced by command-line option value).

Interpolation

Values can contain ${section:option} format strings which refer to other values. If the section: part is omitted, interpolation defaults to the current section (and possibly the default values from the special DEFAULT section). Interpolation can span multiple levels.

For example:

[My Section]
foodir: ${dir}/whatever
dir=frob
long: this value continues
   in the next line

would resolve the ${dir} to the value of dir (frob in this case). All reference expansions are done on demand.

Important

Values for some options (typically filenames) support datetime.datetime.strftime() format strings that is interpolated using batch (job) or task execution time. See comments in generated configuration file for details.

Job configuration

The configuration file created using –create-config option contains the [DEFAULT] and [upkeep_<jobname>] sections, and logging configuration. However, it could not be used without adjustments. If you’ll try to use it as is, you’ll get next error message:

Unexpected error: The configuration does not define a value for the required option 'tasks'

That’s because created configuration file is just a stub where all options and values are commented out. You must update the configuration and provide values for all options that are marked as [REQUIRED].

Important

All jobs must define tasks option with list of tasks to be executed. Tasks are executed in specified order.

You must define values for all options for executor and used tasks that are [REQUIRED] and their value is <UNDEFINED>. Do not forget to uncomment the line with option definition.

Tip

The –dry-run option is provided for convenience to check the configuration without actually running defined tasks. If you would also provide –verbose option, the fbupkeep also prints the configuration options and their values that would be used on execution.

Note

Some configuration options are used by more than one task.

Task executor uses next configuration options:

tasks:[REQUIRED] Which tasks should be executed for this job. Tasks are executed in specified order.
stop_on_error:Abort execution on any error (yes) or skip the failing task and continue running (no). [default: yes]
use_batch_time:Time used for filename interpolation, batch start time (yes) or task start time (no). [default: yes]
Sample configuration file

Next file was generated by:

fbupkeep --create-config example.cfg example

example.cfg:

; ===========================
; FBUPKEEP configuration file
; ===========================
;
; A configuration file consists of sections, each led by a [section] header, followed by
; key/value entries separated by = or : string. Section names are case sensitive but keys
; are not. Leading and trailing whitespace is removed from keys and values. Values can be
; omitted, in which case the key/value delimiter may also be left out. Values can also
; span multiple lines, as long as they are indented deeper than the first line of the value.
;
; Configuration files may include comments, prefixed by # and ; characters. Comments may
; appear on their own on an otherwise empty line, possibly indented.
;
; Values can contain ${section:option} format strings which refer to other values.
; If the section: part is omitted, interpolation defaults to the current section (and possibly
; the default values from the special DEFAULT section). Interpolation can span multiple levels.
;
; FBUPKEEP uses named jobs. Each job must have it's own [upkeep_<jobname>] section with
; configuration for task executor and used tasks.
;
; Individual tasks may use additional sections with their own conventions.
;
; Logging is configured in separate sections at the end of this file.
; For details see https://docs.python.org/3/howto/logging.html#configuring-logging and
; https://docs.python.org/3/library/logging.config.html#logging-config-fileformat
;

[DEFAULT]

; ==========================
; Section for default values
; ==========================
;
; On execution FBUPKEEP automatically adds next options to the default section:
; job_name = [job_name option value]
; here = [current working directory]
; host = [--host option value, default: localhost]
; user = [--user option value, default: 'ISC_USER' or 'sysdba']
; password = [--password option value, default: 'ISC_PASSWORD' or 'masterkey']
; output_dir = [--output-dir option value, default: ${here}/${job_name}]
; filename = ${job_name}-%Y%m%d
;
; You can freely use these options for interpolation in your configuration.
;
; If you define any from these options in default section, its value would be ignored
; (replaced by command-line option value).

[upkeep_example]

; ===============================
; Configuration for 'example' job
; ===============================

; ---------------------------
; Task executor configuration
; ---------------------------
; tasks
; -----
;
; data type: list
;
; [REQUIRED] Which tasks should be executed for this job.
; Tasks are executed in specified order.
;
; Installed tasks:
;   gbak = Create logical (gbak) database backup.
;   gbak_restore = Restore database from logical (gbak) backup.
;   gstat = Save gstat statistics to file.
;   idx_rebuild = Rebuild all user indices in database.
;   idx_recompute = Recompute statistics of all database indices.
;   remove_old = Remove old files.
;   sweep = Perform database sweep operation.
;
;tasks = <UNDEFINED>

; stop_on_error
; -------------
;
; data type: bool
;
; [optional] Abort execution on any error (yes) or skip the failing task and continue running (no).
;
;stop_on_error = yes

; use_batch_time
; --------------
;
; data type: bool
;
; [optional] Time used for filename interpolation, batch start time (yes) or task start time (no).
;
;use_batch_time = yes

; ------------------------------
; Options used by multiple tasks
; ------------------------------

; database
; --------
;
; data type: str
;
; [REQUIRED] Database specification (path or alias)
;
; Used by tasks: gbak, gbak_restore, gstat, idx_rebuild, idx_recompute, sweep
;
;database = <UNDEFINED>

; host
; ----
;
; data type: str
;
; [optional] Firebird server host
;
; Used by tasks: gbak, gbak_restore, gstat, idx_rebuild, idx_recompute, sweep
;
;host = <UNDEFINED>

; user
; ----
;
; data type: str
;
; [REQUIRED] User name to access Firebird service manager
;
; Used by tasks: gbak, gbak_restore, gstat, idx_rebuild, idx_recompute, sweep
;
;user = SYSDBA

; password
; --------
;
; data type: str
;
; [REQUIRED] Password to access Firebird service manager
;
; Used by tasks: gbak, gbak_restore, gstat, idx_rebuild, idx_recompute, sweep
;
;password = masterkey

; gbak_dir
; --------
;
; data type: str
;
; [REQUIRED] Directory for backup files
;
; Used by tasks: gbak, gbak_restore
;
;gbak_dir = <UNDEFINED>, proposed value: ${output_dir}/backup

; gbak_filename
; -------------
;
; data type: str
;
; [REQUIRED] Backup filename template (supports strftime directives)
;
; Used by tasks: gbak, gbak_restore
;
;gbak_filename = <UNDEFINED>, proposed value: ${filename}.fbk

; -----------
; Task 'gbak'
; -----------

; gbak_gc
; -------
;
; data type: bool
;
; [optional] Whether backup should perform garbage collection
;
;gbak_gc = yes

; gbak_logname
; ------------
;
; data type: str
;
; [optional] Backup log filename template (supports strftime directives)
; If not specified, backup log is not created.
;
;gbak_logname = <UNDEFINED>

; -------------------
; Task 'gbak_restore'
; -------------------

; gbak_restore_dir
; ----------------
;
; data type: str
;
; [REQUIRED] Directory for restored databases
;
;gbak_restore_dir = <UNDEFINED>, proposed value: ${output_dir}/restore

; gbak_restore_filename
; ---------------------
;
; data type: str
;
; [REQUIRED] Restored database filename template (supports strftime directives)
;
;gbak_restore_filename = <UNDEFINED>, proposed value: ${filename}.fdb

; gbak_restore_logname
; --------------------
;
; data type: str
;
; [optional] Restore log filename template (supports strftime directives)
; If not specified, restore log is not created.
;
;gbak_restore_logname = <UNDEFINED>

; ------------
; Task 'gstat'
; ------------

; gstat_dir
; ---------
;
; data type: str
;
; [REQUIRED] Directory for output files
;
;gstat_dir = <UNDEFINED>, proposed value: ${output_dir}/gstat

; gstat_filename
; --------------
;
; data type: str
;
; [REQUIRED] Base filename template (supports strftime directives)
;
;gstat_filename = <UNDEFINED>, proposed value: ${filename}.gstat

; ------------------
; Task 'idx_rebuild'
; ------------------

; This task has no private options (not shared with other tasks).

; --------------------
; Task 'idx_recompute'
; --------------------

; This task has no private options (not shared with other tasks).

; -----------------
; Task 'remove_old'
; -----------------

; remove_old_from
; ---------------
;
; data type: list
;
; [REQUIRED] Comma separated list of configuration
; section names. Files are removed according to configuration sections.
; Each section must have next options:
;   path: Directory for processing
;   files_expire_after: Number of days to keep files, older files could be removed
;
; Optional options:
;   pattern: Filename pattern (supports Unix shell-style wildcards), [default: *]
;   recursive: yes/no, [default:no]
;
;remove_old_from = <UNDEFINED>

; ------------
; Task 'sweep'
; ------------

; This task has no private options (not shared with other tasks).

; =====================
; Logging configuration
; =====================
;
; For details see https://docs.python.org/3/howto/logging.html#configuring-logging and
; https://docs.python.org/3/library/logging.config.html#logging-config-fileformat

[loggers]
keys=root

[handlers]
keys=root_handler

[formatters]
keys=root_formatter

[logger_root]
level=NOTSET
handlers=root_handler

[handler_root_handler]
; This sends logging output to file in current working directory
class=FileHandler
args=('fbupkeep.log', 'a')
;
; This sends logging output to STDERR
;class=StreamHandler
;args=(sys.stderr,)
;
formatter=root_formatter

[formatter_root_formatter]
format=%(asctime)s %(levelname)s: %(message)s
Logging

The fbupkeep library uses logging Python library module. By default, the logging level is set to WARNING, messages are stored in fbupkeep.log file in current working directory, and have <timestamp> <level>: <message> format.

For details how to change logging configuration see https://docs.python.org/3/howto/logging.html#configuring-logging and https://docs.python.org/3/library/logging.config.html#logging-config-fileformat

Standard tasks
gbak

Task that creates logical backup of the database.

Important

This tasks never overwrites backup and log files. In case that output filename already exists in output directory, it’s renamed to filename.<number> (starting from 1) that does not exists yet.

Configuration options:

database:[REQUIRED] Database specification (path or alias)
gbak_dir:[REQUIRED] Directory for backup files
gbak_filename:[REQUIRED] Backup filename template (supports strftime directives)
gbak_gc:Whether backup should perform garbage collection (yes/no)
gbak_logname:Backup log filename template (supports strftime directives). If not specified, the backup log is not created.
host:Firebird server host
user:User name to access Firebird service manager
password:Password to access Firebird service manager

Example:

[upkeep_mydatabase]
; This configuration stores backup as mydatabase-YYYYMMDD.fbk file in d:\mydatabase\backup
; directory along with backup logs. Because we plan to run sweep before backup, it's not
; necessary to perform garbage collection.
;
output_dir = d:\\mydatabase
database = C:\\Data\\mydatabase.fdb
gbak_dir = ${output_dir}\\backup
gbak_filename = ${filename}.fbk
gbak_logname = ${filename}.log
gbak_gc = no
gbak_restore

Task that restores database from logical backup. This task is intended to run after gbak task to verify that database could be successfully restored.

Important

This tasks never overwrites database and log files. In case that output filename already exists in output directory, it’s renamed to filename.<number> (starting from 1) that does not exists yet.

Note

The restored database is not deleted. You can use remove_old task to delete it.

Important

When you use time-interpolated filenames for backups, make sure that gbak and gbak_restore tasks use the same timetamp (see use_batch_time option) or other means to ensure that backup file used by gbak_restore exists.

Configuration options:

database:[REQUIRED] Database specification (path or alias)
gbak_dir:[REQUIRED] Directory for backup files
gbak_filename:[REQUIRED] Backup filename template (supports strftime directives)
gbak_restore_dir:
 [REQUIRED] Directory for restored databases
gbak_restore_filename:
 [REQUIRED] Restored database filename template (supports strftime directives)
gbak_restore_logname:
 Restore log filename template (supports strftime directives). If not specified, the restore log is not created.
host:Firebird server host
user:User name to access Firebird service manager
password:Password to access Firebird service manager

Example:

[upkeep_mydatabase]
; This configuration uses backup in mydatabase-YYYYMMDD.fbk file in d:\mydatabase\backup
; directory, and creates database mydatabase-YYYYMMDD.fdb file in d:\mydatabase\restore
; directory along with restore log.
;
output_dir = d:\\mydatabase
gbak_dir = ${output_dir}\\backup
gbak_filename = ${filename}.fbk
gbak_restore_dir = ${output_dir}\\restore
gbak_restore_filename = ${filename}.fdb
gbak_restore_logname = ${filename}.log
sweep

Task that performs database sweep operation.

Configuration options:

database:[REQUIRED] Database specification (path or alias)
host:Firebird server host
user:User name to access Firebird service manager
password:Password to access Firebird service manager

Example:

[upkeep_mydatabase]
;
database = C:\\Data\\mydatabase.fdb
gstat

Task that collects gstat database statistics.

Important

This tasks never overwrites output files. In case that output filename already exists in output directory, it’s renamed to filename.<number> (starting from 1) that does not exists yet.

Configuration options:

database:[REQUIRED] Database specification (path or alias)
gstat_dir:[REQUIRED] Directory for output files
gstat_filename:[REQUIRED] Base filename template (supports strftime directives)
host:Firebird server host
user:User name to access Firebird service manager
password:Password to access Firebird service manager

Example:

[upkeep_mydatabase]
; This configuration stores database statistics as mydatabase-YYYYMMDD.gstat file in
; d:\mydatabase\gstat directory.
;
output_dir = d:\\mydatabase
database = C:\\Data\\mydatabase.fdb
gstat_dir = ${output_dir}\\gstat
gstat_filename = ${filename}.gstat
idx_recompute

Task that recomputes statistics for all database indices.

Configuration options:

database:[REQUIRED] Database specification (path or alias)
host:Firebird server host
user:User name to access Firebird service manager
password:Password to access Firebird service manager

Note

Verbose mode logs & prints each recomputed index.

Example:

[upkeep_mydatabase]
;
database = C:\\Data\\mydatabase.fdb
idx_rebuild

Task that rebuilds all user (i.e. not system) indices.

Configuration options:

database:[REQUIRED] Database specification (path or alias)
host:Firebird server host
user:User name to access Firebird service manager
password:Password to access Firebird service manager

Example:

[upkeep_mydatabase]
;
database = C:\\Data\\mydatabase.fdb

Note

Verbose mode logs & prints each rebuilt index.

remove_old

Task that removes old files.

Configuration options:

remove_old_from:
 List of comma-separated section names.

Each listed section must/can define next options:

path:[REQUIRED] Directory for processing
files_expire_after:
 [REQUIRED] Number of days to keep files, older files could be removed
pattern:Filename pattern (supports Unix shell-style wildcards)
recursive:Process path recursively (yes/no)

Note

Logs & prints each file removed.

Example:

[upkeep_mydatabase]
; Next configuration removes old backups, and database file restored in this job run.
;
remove_old_from = mydatabase_old_backup, mydatabase_old_restore
; Next options are used by gbak and gbak_restore
gbak_dir = ${output_dir}\\backup
gbak_restore_dir = ${output_dir}\\restore
gbak_restore_filename = ${filename}.fdb

[mydatabase_old_backup]
; Remove backups (but keep other files in backup directory) older than 14 days
path = ${upkeep_mydatabase:gbak_dir}
files_expire_after = 14
pattern = *.fbk
recursive = no

[mydatabase_old_restore]
; Remove database previously restored by gbak_restore (if any)
path = ${upkeep_mydatabase:gbak_restore_dir}
; Make sure that we will pass the expiration test
files_expire_after = -2
; We want to remove exactly this database file restored previously by gbak_restore
pattern = ${upkeep_mydatabase:gbak_restore_filename}
recursive = no

FBUPKEEP Reference

Main module namespace
Constants
__version__:Current module version, string.
fbupkeep.base

Firebird Upkeep utility - Base classes and other definitions

Exceptions
exception fbupkeep.base.Error

Bases: Exception

Base exception for this module.

exception fbupkeep.base.StopError

Bases: fbupkeep.base.Error

Error that should stop furter processing.

Functions
fbupkeep.base.has_option(namespace, name: str)

Returns True if argparse.Namespace has an option.

Classes
ConfigOption
class fbupkeep.base.ConfigOption(name: str, datatype: Any, description: str, required: bool = False, default: Any = None, proposal: Any = None)

Bases: object

Task configuration option.

Attributes:
name:Option name.
datatype:Option datatype [str, int, float, bool or list].
description:Option description. Can span multiple lines.
required:True if option must have a value.
default:Default value.
proposal:Text with proposed configuration entry (if it’s different from default).
value:Current option value.
configure(config: configparser.ConfigParser, section: str) → None

Update option value from configuration.

Arguments:
config:ConfigParser instance with configuration values.
section:Name of ConfigParser section that should be used to get new configuration values.
get_config() → List[T]

Return list of text lines suitable for use in configuration file.

Each line starts comment marker ; and ends with newline. Last line is options definition.

get_printout() → str

Return option printout in ‘name = value’ format.

validate() → None

Checks whether required option has value other than None.

Raises:
Error:When required option does not have a value.
TaskConfig
class fbupkeep.base.TaskConfig(name: str = 'main')

Bases: object

Task configuration options.

Attributes:
name:Name associated with Task Configuration [default: ‘main’].
add(option: fbupkeep.base.ConfigOption) → None

Add configuration option.

add_option(name: str, datatype: Any, description: str, required: bool = False, default: bool = None, proposal: bool = False) → None

Add new configuration option.

configure(config: configparser.ConfigParser, section: str) → None

Update configuration.

Arguments:
config:ConfigParser instance with configuration values.
section:Name of ConfigParser section that should be used to get new configuration values.
get_option(name: str) → fbupkeep.base.ConfigOption

Return ConfigOption with specified name or None.

get_printout() → List[str]

Return list of text lines with printout of current configuration

has_option(name: str) → bool

Return True if option with specified name is defined.

validate() → None

Checks whether all required options have value other than None.

Raises:
Error:When required option does not have a value.
options

Options dictionary (name,ConfigOption).

LoggedObject
class fbupkeep.base.LoggedObject

Bases: object

Object with logging support.

Attributes:
logger:logging.Logger instance.
mute:If True, only errors and exceptions are printed (to stderr).
log_only:If True, all console output is suppressed.
error(message: str) → None

Log ERROR message and print it to stderr if not suppressed.

exception(message: str) → None

Log ERROR message with exception information and print it to stderr if not suppressed.

info(message: str = '', end: str = '\n') → None

Log INFO message (if present) and print the message to stdout if not suppressed.

print(message: str = '') → None

Print the message to stdout if not suppressed.

logger

Logger instance

Task
class fbupkeep.base.Task(executor)

Bases: fbupkeep.base.LoggedObject

Base task.

Attributes:
executor:TaskExecutor that owns this Task instance.
name:Task name [default: “Task”].
description:Short task description [default: None]. Should NOT span multiple lines.
config:TaskConfig instance.
verbose:Verbose output flag [default: False].
report:List of text lines with execution report [default: Empty list].
errors:List of text lines with execution errors [default: Empty list].
timestamp:Timestamp used for filename interpolation.
start:Timestamp when task execution started (set by executor) [default: None].
stop:Timestamp when task execution ended (set by executor) [default: None].
configure(config: configparser.ConfigParser, options: argparse.Namespace) → List[fbupkeep.base.TaskConfig]

Task configuration.

Returns:
List of TaskConfig instances used by task.

Updates the config attribute from upkeep_<options.job_name> config section. Validates the config.

run() → None

Task execution. Default implementation does nothing.

TaskExecutor
class fbupkeep.base.TaskExecutor

Bases: fbupkeep.base.LoggedObject

Task executor.

Attributes:
config:TaskConfig instance.
verbose:Verbose output flag [default: False].
tasks:List of Task instances with all installed tasks.
get_task(name: str) → fbupkeep.base.Task

Return task with specified name or None.

load_tasks() → None

Load all registered tasks.

run(config: configparser.ConfigParser, options: argparse.Namespace) → None

Run tasks.

Recognized argument options:
log_only:Suppress all screen output.
quiet:Suppress informational screen output, errors are still print out to stderr.
verbose:Additional informational screen output.
dry_run:Prepare execution but do not run tasks. Print used configuration as verbose output.
write_default_config(cfg_file: TextIO) → None

Write default configuration for all known tasks into file.

Arguments:
cfg_file:Openned file-like object.
fbupkeep.tasks

Firebird Upkeep utility - Standard tasks

Classes
TaskGstat
class fbupkeep.tasks.TaskGstat(executor)

Bases: fbupkeep.base.Task

Task that collects gstat database statistics.

run() → None

Task execution.

TaskGbak
class fbupkeep.tasks.TaskGbak(executor)

Bases: fbupkeep.base.Task

Task that creates logical (gbak) database backup.

run() → None

Task execution.

TaskGbakRestore
class fbupkeep.tasks.TaskGbakRestore(executor)

Bases: fbupkeep.base.Task

Task that restores database from logical (gbak) backup file.

run() → None

Task execution.

TaskSweep
class fbupkeep.tasks.TaskSweep(executor)

Bases: fbupkeep.base.Task

Task that performs database sweep.

run() → None

Task execution.

TaskIndexRecompute
class fbupkeep.tasks.TaskIndexRecompute(executor)

Bases: fbupkeep.base.Task

Task that recomputes statistics for all database indices.

run() → None

Task execution.

TaskIndexRebuild
class fbupkeep.tasks.TaskIndexRebuild(executor)

Bases: fbupkeep.base.Task

Task that rebuilds all user (i.e. not system) indices.

run() → None

Task execution.

TaskRemoveOld
class fbupkeep.tasks.TaskRemoveOld(executor)

Bases: fbupkeep.base.Task

Task that removes old files.

configure(config: configparser.ConfigParser, options: argparse.Namespace) → None

Task configuration.

run() → None

Task execution.

fbupkeep.runner

Firebird Upkeep utility

usage:

fbupkeep [-h] [--version] [--create-config FILENAME] 
              [--host HOST] [-u USER] [-p PASSWORD] 
              [-c CONFIG] [-o DIR] [--dry-run] 
              [-v] [-q] [-l {critical,fatal,error,warn,warning,info,debug,notset}]
              [--log-only]
              job_name
optional arguments:
-h, --help show this help message and exit
--version show program’s version number and exit
--create-config FILENAME
 Create configuration file for job and exit (default: None)
positional arguments:
job_name Job name
Firebird server/database connection arguments:
--host HOST Server host (default: localhost)
-u USER, --user USER
 User name (default: sysdba)
-p PASSWORD, --password PASSWORD
 User password (default: masterkey)
run arguments:
-c CONFIG, --config CONFIG
 Configuration file (default: fbupkeep.cfg)
-o DIR, --output-dir DIR
 Force directory for log files and other output (default: ${here}/${job_name})
--dry-run Prepare execution but do not run tasks (default: False)
output arguments:
-v, --verbose Verbose output (default: False)
-q, --quiet No screen output (default: False)
-l {critical,fatal,error,warn,warning,info,debug,notset}, –log-level {critical,fatal,error,warn,warning,info,debug,notset}
Logging level (default: WARNING)
--log-only Suppress all screen output including error messages (default: False)
fbupkeep.runner.main()

Main function for fbupkeep script.

Changelog

Version 1.0

Initial release.

License

MIT License

Copyright (c) 2018 Firebird Project (www.firebirdsql.org)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Indices and tables