Skip to content

Commit

Permalink
Merge pull request #346 from holland-backup/devel
Browse files Browse the repository at this point in the history
Allow pg_basedump to expand backup_directory/backupdir
  • Loading branch information
ed-velez authored Dec 2, 2021
2 parents 1745ba5 + 93b5e43 commit 77dcfe9
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 38 deletions.
2 changes: 1 addition & 1 deletion contrib/holland-commvault/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland_commvault",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.example/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.example",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.mariabackup/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.mariabackup",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.mongodump/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.mongodump",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.mysql_lvm/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.mysql_lvm",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.mysqldump/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.mysqldump",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

# Python stdlib
import os
import shlex
import subprocess
import tempfile

Expand All @@ -21,6 +20,7 @@

# Holland general compression functions
from holland.lib.compression import open_stream
from holland.lib.util import parse_arguments

LOG = logging.getLogger(__name__)
VER = None
Expand Down Expand Up @@ -193,15 +193,6 @@ def pgauth2args(config):
return args


def pg_extra_options(config):
""" Returns extra cli options based on pg_basebackup config """
args = []
additional_options = config["pg-basebackup"]["additional-options"]
if additional_options:
args += shlex.split(additional_options)
return args


def generate_pgpassfile(backup_directory, password):
""" Creates a pgpass file from a given password """
fileobj = open(os.path.join(backup_directory, "pgpass"), "w")
Expand All @@ -222,7 +213,11 @@ def backup_pgsql(backup_directory, config):
:raises: OSError, PgError on error
"""
connection_params = pgauth2args(config)
extra_options = pg_extra_options(config)
extra_options = parse_arguments(
config["pg-basebackup"]["additional-options"],
backup_directory=backup_directory,
backupdir=backup_directory,
)
out_format = config["pg-basebackup"]["format"]
method = config["pg-basebackup"]["wal-method"]

Expand Down Expand Up @@ -268,16 +263,19 @@ def backup_pgsql(backup_directory, config):
def dry_run(config):
""" Logs what pg_basebackup command would be run """
args = pgauth2args(config)

cmd = [
"pg_basebackup",
"-F",
config["pg-basebackup"]["format"],
"-D",
"-",
"-X",
config["pg-basebackup"]["wal-method"],
] + args
cmd = (
[
"pg_basebackup",
"-F",
config["pg-basebackup"]["format"],
"-D",
"-",
"-X",
config["pg-basebackup"]["wal-method"],
]
+ args
+ config["pg-basebackup"]["additional-options"]
)

LOG.info("pg_dumpall -g")
LOG.info(subprocess.list2cmdline(cmd))
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
format = option('tar','plain',default='tar')
wal-method = option('none','fetch','stream',default='fetch')
checkpoint = option('none','fast','spread',default='fast')
additional-options = string(default=None)
additional-options = force_list(default=list())
[pgauth]
username = string(default=None)
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.pg_basebackup/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.pg_basebackup",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.pgdump/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.pgdump",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.random/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.random",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.sqlite/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.sqlite",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.tar/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.tar",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.backup.xtrabackup/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.backup.xtrabackup",
Expand Down
16 changes: 16 additions & 0 deletions plugins/holland.lib.common/holland/lib/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Helpful functions
"""

from string import Template


def parse_arguments(arguments, **kwargs):
"""Replace varibles with values"""
if not arguments:
return arguments
if isinstance(arguments, list):
arguments = " ".join(arguments)
ret = Template(arguments).safe_substitute(**kwargs)
ret = ret.split(" ")
return ret
2 changes: 1 addition & 1 deletion plugins/holland.lib.common/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.lib.common",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.lib.lvm/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland.lib.lvm",
Expand Down
2 changes: 1 addition & 1 deletion plugins/holland.lib.mysql/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"


setup(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

version = "1.2.8"
version = "1.2.9"

setup(
name="holland",
Expand Down

0 comments on commit 77dcfe9

Please sign in to comment.