Skip to content

Commit

Permalink
Merge pull request #321 from holland-backup/devel
Browse files Browse the repository at this point in the history
Add splitsize
  • Loading branch information
soulen3 authored Mar 9, 2021
2 parents 274ea73 + 713c469 commit 9e01b05
Show file tree
Hide file tree
Showing 84 changed files with 422 additions and 319 deletions.
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
---
repos:
- repo: https://github.com/ambv/black
rev: stable
rev: 20.8b1
hooks:
- id: black
args: [--line-length=100]
- repo: git://github.com/pre-commit/mirrors-pylint
rev: v2.6.0
hooks:
- id: pylint
- repo: https://github.com/pycqa/isort
rev: 5.7.0
hooks:
- id: isort
args: ["--profile", "black"]
2 changes: 2 additions & 0 deletions config/backupsets/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ file-per-database = yes
#method = gzip
#inline = yes
#level = 1
#split = false
#splitsize = 1

#[mysql:client]
#defaults-extra-file = /root/.my.cnf
2 changes: 1 addition & 1 deletion contrib/holland-commvault/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import find_packages, setup

version = "1.2.3"
version = "1.2.4"

setup(
name="holland_commvault",
Expand Down
8 changes: 4 additions & 4 deletions holland/commands/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
"""

import logging
from subprocess import Popen, PIPE
from string import Template
from holland.core.command import Command
from subprocess import PIPE, Popen

# Commvault command entry point
from holland.core.backup import BackupRunner, BackupError
from holland.core.backup import BackupError, BackupRunner
from holland.core.command import Command
from holland.core.config import HOLLANDCFG, ConfigError
from holland.core.spool import SPOOL
from holland.core.util.fmt import format_bytes
from holland.core.util.path import disk_free, disk_capacity, getmount
from holland.core.util.lock import Lock, LockError
from holland.core.util.path import disk_capacity, disk_free, getmount

LOG = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions holland/commands/list_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
Define List Backup Command
"""

import sys
import re
import sys

from holland.core.command import Command
from holland.core.spool import SPOOL
from holland.core.plugin import load_backup_plugin
from holland.core.spool import SPOOL


class ListBackups(Command):
Expand Down
1 change: 1 addition & 0 deletions holland/commands/list_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import sys

from holland.core.command import Command
from holland.core.plugin import iter_plugins

Expand Down
12 changes: 6 additions & 6 deletions holland/commands/mk_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
Command support for generating backupset configs
"""

import logging
import os
import subprocess
import sys
import tempfile
import logging
import subprocess

from holland.core.command import Command
from holland.core.plugin import load_first_entrypoint, PluginLoadError
from holland.core.config import HOLLANDCFG
from holland.core.config.checks import VALIDATOR
from holland.core.plugin import PluginLoadError, load_first_entrypoint

try:
from holland.core.config.configobj import ConfigObj, flatten_errors, ParseError
from holland.core.config.configobj import ConfigObj, ParseError, flatten_errors
except BaseException:
from configobj import ConfigObj, flatten_errors, ParseError
from configobj import ConfigObj, ParseError, flatten_errors

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -148,7 +148,7 @@ def _cleanup_config(config, skip_comments=False):
# First flag any required parameters
for entry in flatten_errors(config, errors):
section_list, key, error = entry
section_name, = section_list
(section_name,) = section_list
if error is False:
config[section_name][key] = ""
config[section_name].comments[key].append("REQUIRED")
Expand Down
5 changes: 3 additions & 2 deletions holland/commands/purge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
Command to delete old backups
"""

import logging
import itertools
import logging

from holland.core.command import Command
from holland.core.config import HOLLANDCFG, ConfigError
from holland.core.spool import SPOOL, CONFIGSPEC
from holland.core.spool import CONFIGSPEC, SPOOL
from holland.core.util.fmt import format_bytes

LOG = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions holland/commands/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import logging

from holland.core.command import Command
from holland.core.plugin import load_first_entrypoint
from holland.core.spool import SPOOL
Expand Down
2 changes: 1 addition & 1 deletion holland/core/backup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
import from core
"""
from holland.core.backup.base import BackupError, BackupRunner, BackupPlugin
from holland.core.backup.base import BackupError, BackupPlugin, BackupRunner
9 changes: 5 additions & 4 deletions holland/core/backup/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
Define how backup plugins will be called
"""

import errno
import logging
import os
import sys
import time
import errno
import logging

from holland.core.plugin import PluginLoadError, load_backup_plugin
from holland.core.util.path import directory_size, disk_free
from holland.core.util.fmt import format_bytes, format_interval
from holland.core.spool import Backup
from holland.core.util.fmt import format_bytes, format_interval
from holland.core.util.path import directory_size, disk_free

MAX_SPOOL_RETRIES = 5

Expand Down
11 changes: 6 additions & 5 deletions holland/core/cmdshell.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
"""This file defines the default options available
and the entry point for holland command"""

import logging
import os
import sys
import logging

from pkg_resources import get_distribution
from holland.core.util.bootstrap import bootstrap
from holland.core.command import run, parse_sys, print_help

from holland.core.command import parse_sys, print_help, run
from holland.core.config.checks import is_logging_level
from holland.core.util.bootstrap import bootstrap

LOG = logging.getLogger(__name__)
HOLLAND_VERSION = get_distribution("holland").version

# main entrypoint for holland's cmdshell 'hl'
def main():
"""The main entrypoint for holland's cmdshell
"""
"""The main entrypoint for holland's cmdshell"""

if len(sys.argv) < 2:
print_help()
Expand Down
6 changes: 4 additions & 2 deletions holland/core/command/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
Setup functions to import commnad plugins
"""

import logging
import os
import sys
import logging

from holland.core.plugin import get_commands
from .command import Command, PARSER

from .command import PARSER, Command

__all__ = ["Command", "run", "PARSER"]

Expand Down
5 changes: 3 additions & 2 deletions holland/core/command/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
Pluggable command support
"""

import argparse
import logging
import os
import sys
import argparse
from argparse import RawTextHelpFormatter
import logging

from pkg_resources import get_distribution

LOG = logging.getLogger(__name__)
Expand Down
10 changes: 8 additions & 2 deletions holland/core/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
Module to read configuration files
"""

from configobj import ConfigObj, ParseError, ConfigObjError
from .config import HOLLANDCFG, setup_config, load_backupset_config, BaseConfig, ConfigError
from configobj import ConfigObj, ConfigObjError, ParseError

from .config import (
HOLLANDCFG,
BaseConfig,
ConfigError,
load_backupset_config,
setup_config,
)

__all__ = ["HOLLANDCFG", "setup_config", "load_backupset_config", "BaseConfig"]
2 changes: 2 additions & 0 deletions holland/core/config/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"""

import shlex

import validate
from validate import Validator

from holland.core.util.fmt import format_loglevel


Expand Down
7 changes: 4 additions & 3 deletions holland/core/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
Configuration API support
"""

import os
import logging
import os

from .checks import VALIDATOR

# get_extra_values was added in configobj 4.7. EL6 ships with 4.6
# Try to import this and remove get_extra_values if it doesn't work
Expand All @@ -12,7 +14,6 @@
except ImportError:
from configobj import ConfigObj, Section, flatten_errors

from .checks import VALIDATOR

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -66,7 +67,7 @@ def _canonicalize(section, key):
section.rename(key, str(key.replace("_", "-")))

def reload(self):
""" Reloads ConfigObj from filesystem, then recursively walks each
"""Reloads ConfigObj from filesystem, then recursively walks each
section.
"""
ConfigObj.reload(self)
Expand Down
11 changes: 6 additions & 5 deletions holland/core/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
import os
from email.parser import Parser
from email.policy import default

from pkg_resources import (
working_set,
Environment,
iter_entry_points,
find_distributions,
DistributionNotFound,
Environment,
VersionConflict,
find_distributions,
iter_entry_points,
working_set,
)

LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -42,7 +43,7 @@ def add_plugin_dir(plugin_dir):
for dist, error in list(errors.items()):
errmsg = None
if isinstance(error, DistributionNotFound):
req, = error.args
(req,) = error.args
errmsg = "%r not found" % req.project_name
elif isinstance(error, VersionConflict):
dist, req = error.args
Expand Down
25 changes: 11 additions & 14 deletions holland/core/spool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Utilities to manage spool directory
"""

import os
import time
import errno
import logging
import itertools
import logging
import os
import shutil
import time
from string import Template
from textwrap import dedent

Expand Down Expand Up @@ -360,23 +360,20 @@ def __str__(self):
"""
format plugin info
"""
return (
dedent(
"""
return dedent(
"""
Backup: %s
start-time: %s
stop-time: %s
estimated-size: %s
on-disk-size: %s
"""
).strip()
% (
self.name,
format_datetime(self.config.lookup("holland:backup.start-time")),
format_datetime(self.config.lookup("holland:backup.stop-time")),
format_bytes(self.config.lookup("holland:backup.estimated-size")),
format_bytes(self.config.lookup("holland:backup.on-disk-size")),
)
).strip() % (
self.name,
format_datetime(self.config.lookup("holland:backup.start-time")),
format_datetime(self.config.lookup("holland:backup.stop-time")),
format_bytes(self.config.lookup("holland:backup.estimated-size")),
format_bytes(self.config.lookup("holland:backup.on-disk-size")),
)

def __cmp__(self, other):
Expand Down
12 changes: 9 additions & 3 deletions holland/core/util/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
These functions should only be called when starting up a holland session.
They initialize things like logging and the config system.
"""
import logging
import os
import sys
import logging

from holland.core.config import HOLLANDCFG
from holland.core.config import setup_config as _setup_config
from holland.core.log import (
clear_root_handlers,
setup_console_logging,
setup_file_logging,
)
from holland.core.plugin import add_plugin_dir
from holland.core.config import HOLLANDCFG, setup_config as _setup_config
from holland.core.log import setup_console_logging, setup_file_logging, clear_root_handlers
from holland.core.spool import SPOOL

LOG = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions holland/core/util/fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Format day, byt, number, and log objects
"""

import math
import logging
from time import strftime, localtime
import math
from time import localtime, strftime


def format_interval(seconds):
Expand Down
Loading

0 comments on commit 9e01b05

Please sign in to comment.