Skip to content

provider

Custom provider classes

Classes:

Attributes

BACKUP_PROVIDERS module-attribute

BACKUP_PROVIDERS = [CustomProvider]

Classes

CustomProvider

CustomProvider(
    container: Container,
    compression: CompressionAlgorithm | None = None,
)

Backup provider constructor

Parameters:

  • container

    (Container) –

    Container object

  • compression

    (CompressionAlgorithm | None, default: None ) –

    Compression algorithm

Methods:

Attributes:

Attributes

default_dump_binary class-attribute instance-attribute
default_dump_binary: str | None = None

Default dump binary

default_dump_args class-attribute instance-attribute
default_dump_args: str | None = None

Default dump binary arguments

default_restore_binary class-attribute instance-attribute
default_restore_binary: str | None = 'RESTORE_COMMAND'

Default restore binary

default_restore_args class-attribute instance-attribute
default_restore_args: str | None = ''

Default restore binary arguments

min_file_size class-attribute instance-attribute
min_file_size: int = 200

Maximum file size, used to validate the generated file

pattern class-attribute instance-attribute
pattern: str | None = None

Pattern which is checked in the dumped file

plain_file_extension class-attribute instance-attribute
plain_file_extension: str = '.sql'

File extenstion used for the dumped file

compression instance-attribute
compression: CompressionAlgorithm | None = compression

Compression algorithm

container instance-attribute
container: Container = container

Container object

name class-attribute instance-attribute
name = 'custom'
dump_binary class-attribute instance-attribute
dump_binary = None

Functions

dump
dump() -> str

Dump database

restore
restore(backup_file: Path) -> None

Restore database

is_backup_provider
is_backup_provider() -> bool

Checks if container supports a backup provider

validate_file
validate_file(file_path: Path) -> bool

Validate the generated file

trigger_webhook
trigger_webhook(
    message: str,
    address: str,
    code: int = 0,
    append: str = "",
) -> None

Trigger webhook.

Parameters:

  • message
    (str) –

    Message send to the webhook

  • address
    (str) –

    If not set taken from the label

  • code
    (int, default: 0 ) –

    Code which is sent to the webhook

  • append
    (str, default: '' ) –

    Path appended to address (can be used for fails)

trigger_error_webhook
trigger_error_webhook(
    message: str, address: str, code: int = 1
) -> None

Triggers an error on the webhook. code is appended to the address.

trigger_success_webhook
trigger_success_webhook(
    message: str, address: str, code: int = 0
) -> None

Triggers an success on the webhook.

get_dump_binary
get_dump_binary() -> str

Get the binary used to dump the backup.

get_dump_args
get_dump_args() -> str

Arguments for the dump binary.

get_restore_binary
get_restore_binary() -> str

Get the binary used to restore the backup.

get_restore_args
get_restore_args() -> str

Arguments for the restore binary.

get_container_env
get_container_env() -> dict[str, str | None]

Get environment variables from container.

binary_exists_in_container
binary_exists_in_container(binary_name: str) -> bool

Check if binary exists inside the container.

get_container_label
get_container_label(
    label: str, default: str | None = None
) -> str | None

Get labels for container.

get_service_name
get_service_name() -> str

Get service name (only if started with docker compose).