Skip to content

Commit

Permalink
Fixed #79: added DATABASES_OPTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed May 2, 2024
1 parent e8684a5 commit be72dcd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ENV BACKUP_HOUR=3
ENV BACKUP_MINUTE=12
# No database to backup in default
ENV DATABASES=""
# options to pass to the database hook
ENV DATABASES_OPTIONS=""
# Retry paramaeters when setup a new repo
ENV MAX_BORGMATIC_RETRY="10"
ENV WAIT_BEFORE_BORGMATIC_RETRY="30"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Other parameters can be configured via Docker environment variables:
- `KEEP_YEARLY`: keep last archive of this many latest years (default: `1`)
- Databases backup:
- `DATABASES`: DSNs of the database to backup.
- `DATABASES_OPTIONS`: Options passed to all databases hookd. eg: `--ignore-table=wp1.too_large_table`

Database DSN should be in the form: `type://user:password@host:port/dbname`. It only supports `mysql`, `postgresql` and `mongodb`. `dbname` can be `all` to backup all databases of that host/connexion.

Expand Down
22 changes: 18 additions & 4 deletions bin/init_borgbase_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def write_config(
keep_monthly,
keep_yearly,
databases,
databases_options,
cross_fs_glob,
):

Expand Down Expand Up @@ -177,14 +178,23 @@ def write_config(
FILE,
"mysql",
databases_mysql,
"--single-transaction --quick --lock-tables=false "
"--max-allowed-packet=128M",
options=(
"--single-transaction --quick --lock-tables=false "
+ "--max-allowed-packet=128M "
+ databases_options
),
)
if databases_postgresql:
write_config_databases(FILE, "postgresql", databases_postgresql)
write_config_databases(
FILE, "postgresql", databases_postgresql, options=databases_options
)
if databases_mongodb:
write_config_databases(
FILE, "mongodb", databases_mongodb, authentication_database="admin"
FILE,
"mongodb",
databases_mongodb,
options=databases_options,
authentication_database="admin",
)


Expand All @@ -201,6 +211,7 @@ def main(
quota,
alert,
databases,
databases_options,
cross_fs_glob,
max_retry,
initial_delay_retry,
Expand Down Expand Up @@ -235,6 +246,7 @@ def main(
keep_monthly,
keep_yearly,
databases,
databases_options,
cross_fs_glob,
)

Expand Down Expand Up @@ -276,6 +288,7 @@ def main(
KNOWN_HOSTS_FILE = os.environ.get("KNOWN_HOSTS_FILE")

DATABASES = os.environ.get("DATABASES")
DATABASES_OPTIONS = os.environ.get("DATABASES_OPTIONS", "")
CROSS_FS_GLOB = os.environ.get("CROSS_FS_GLOB")

KEEP_WITHIN = os.environ.get("KEEP_WITHIN")
Expand Down Expand Up @@ -314,6 +327,7 @@ def main(
QUOTA,
ALERT,
list(map(urlparse, DATABASES.split(DB_SEPARATOR))) if DATABASES else [],
DATABASES_OPTIONS,
bool(CROSS_FS_GLOB),
MAX_BORGMATIC_RETRY,
WAIT_BEFORE_BORGMATIC_RETRY,
Expand Down

0 comments on commit be72dcd

Please sign in to comment.