mirror of
https://projects.torsion.org/witten/borgmatic.git
synced 2025-04-10 15:37:33 +00:00
Remove the "dump_data_sources" command hook, as it doesn't really solve the use case and works differently than all the other command hooks (#790).
This commit is contained in:
parent
624a7de622
commit
c2409d9968
22 changed files with 428 additions and 857 deletions
borgmatic
config
hooks
docs/how-to
tests/unit/hooks
|
@ -959,7 +959,6 @@ properties:
|
|||
- repository
|
||||
- configuration
|
||||
- everything
|
||||
- dump_data_sources
|
||||
description: |
|
||||
Name for the point in borgmatic's execution that
|
||||
the commands should be run before (required if
|
||||
|
@ -972,19 +971,7 @@ properties:
|
|||
repositories in the current configuration file.
|
||||
* "everything" runs before all configuration
|
||||
files.
|
||||
* "dump_data_sources" runs before each data
|
||||
source is dumped.
|
||||
example: action
|
||||
hooks:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: |
|
||||
List of names of other hooks that this command
|
||||
hook applies to. Defaults to all hooks of the
|
||||
relevant type. Only supported for the
|
||||
"dump_data_sources" hook.
|
||||
example: postgresql
|
||||
when:
|
||||
type: array
|
||||
items:
|
||||
|
@ -1013,9 +1000,7 @@ properties:
|
|||
- borg
|
||||
description: |
|
||||
List of actions for which the commands will be
|
||||
run. Defaults to running for all actions. Ignored
|
||||
for "dump_data_sources", which by its nature only
|
||||
runs for "create".
|
||||
run. Defaults to running for all actions.
|
||||
example: [create, prune, compact, check]
|
||||
run:
|
||||
type: array
|
||||
|
@ -1037,7 +1022,6 @@ properties:
|
|||
- configuration
|
||||
- everything
|
||||
- error
|
||||
- dump_data_sources
|
||||
description: |
|
||||
Name for the point in borgmatic's execution that
|
||||
the commands should be run after (required if
|
||||
|
@ -1051,19 +1035,7 @@ properties:
|
|||
* "everything" runs after all configuration
|
||||
files.
|
||||
* "error" runs after an error occurs.
|
||||
* "dump_data_sources" runs after each data
|
||||
source is dumped.
|
||||
example: action
|
||||
hooks:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: |
|
||||
List of names of other hooks that this command
|
||||
hook applies to. Defaults to all hooks of the
|
||||
relevant type. Only supported for the
|
||||
"dump_data_sources" hook.
|
||||
example: postgresql
|
||||
when:
|
||||
type: array
|
||||
items:
|
||||
|
@ -1093,9 +1065,7 @@ properties:
|
|||
description: |
|
||||
Only trigger the hook when borgmatic is run with
|
||||
particular actions listed here. Defaults to
|
||||
running for all actions. Ignored for
|
||||
"dump_data_sources", which by its nature only runs
|
||||
for "create".
|
||||
running for all actions.
|
||||
example: [create, prune, compact, check]
|
||||
run:
|
||||
type: array
|
||||
|
|
|
@ -55,11 +55,9 @@ def filter_hooks(command_hooks, before=None, after=None, hook_name=None, action_
|
|||
return tuple(
|
||||
hook_config
|
||||
for hook_config in command_hooks or ()
|
||||
for config_hook_names in (hook_config.get('hooks'),)
|
||||
for config_action_names in (hook_config.get('when'),)
|
||||
if before is None or hook_config.get('before') == before
|
||||
if after is None or hook_config.get('after') == after
|
||||
if hook_name is None or config_hook_names is None or hook_name in config_hook_names
|
||||
if action_names is None
|
||||
or config_action_names is None
|
||||
or set(config_action_names or ()).intersection(set(action_names))
|
||||
|
|
|
@ -6,7 +6,6 @@ import os
|
|||
|
||||
import borgmatic.borg.pattern
|
||||
import borgmatic.config.paths
|
||||
import borgmatic.hooks.command
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -38,13 +37,6 @@ def dump_data_sources(
|
|||
if hook_config and hook_config.get('store_config_files') is False:
|
||||
return []
|
||||
|
||||
with borgmatic.hooks.command.Before_after_hooks(
|
||||
command_hooks=config.get('commands'),
|
||||
before_after='dump_data_sources',
|
||||
umask=config.get('umask'),
|
||||
dry_run=dry_run,
|
||||
hook_name='bootstrap',
|
||||
):
|
||||
borgmatic_manifest_path = os.path.join(
|
||||
borgmatic_runtime_directory, 'bootstrap', 'manifest.json'
|
||||
)
|
||||
|
|
|
@ -9,7 +9,6 @@ import subprocess
|
|||
import borgmatic.borg.pattern
|
||||
import borgmatic.config.paths
|
||||
import borgmatic.execute
|
||||
import borgmatic.hooks.command
|
||||
import borgmatic.hooks.data_source.snapshot
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -250,13 +249,6 @@ def dump_data_sources(
|
|||
|
||||
If this is a dry run, then don't actually snapshot anything.
|
||||
'''
|
||||
with borgmatic.hooks.command.Before_after_hooks(
|
||||
command_hooks=config.get('commands'),
|
||||
before_after='dump_data_sources',
|
||||
umask=config.get('umask'),
|
||||
dry_run=dry_run,
|
||||
hook_name='btrfs',
|
||||
):
|
||||
dry_run_label = ' (dry run; not actually snapshotting anything)' if dry_run else ''
|
||||
logger.info(f'Snapshotting Btrfs subvolumes{dry_run_label}')
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import subprocess
|
|||
import borgmatic.borg.pattern
|
||||
import borgmatic.config.paths
|
||||
import borgmatic.execute
|
||||
import borgmatic.hooks.command
|
||||
import borgmatic.hooks.data_source.snapshot
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -198,13 +197,6 @@ def dump_data_sources(
|
|||
|
||||
If this is a dry run, then don't actually snapshot anything.
|
||||
'''
|
||||
with borgmatic.hooks.command.Before_after_hooks(
|
||||
command_hooks=config.get('commands'),
|
||||
before_after='dump_data_sources',
|
||||
umask=config.get('umask'),
|
||||
dry_run=dry_run,
|
||||
hook_name='lvm',
|
||||
):
|
||||
dry_run_label = ' (dry run; not actually snapshotting anything)' if dry_run else ''
|
||||
logger.info(f'Snapshotting LVM logical volumes{dry_run_label}')
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import shlex
|
|||
|
||||
import borgmatic.borg.pattern
|
||||
import borgmatic.config.paths
|
||||
import borgmatic.hooks.command
|
||||
import borgmatic.hooks.credential.parse
|
||||
from borgmatic.execute import (
|
||||
execute_command,
|
||||
|
@ -243,13 +242,6 @@ def dump_data_sources(
|
|||
Also append the the parent directory of the database dumps to the given patterns list, so the
|
||||
dumps actually get backed up.
|
||||
'''
|
||||
with borgmatic.hooks.command.Before_after_hooks(
|
||||
command_hooks=config.get('commands'),
|
||||
before_after='dump_data_sources',
|
||||
umask=config.get('umask'),
|
||||
dry_run=dry_run,
|
||||
hook_name='mariadb',
|
||||
):
|
||||
dry_run_label = ' (dry run; not actually dumping anything)' if dry_run else ''
|
||||
processes = []
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import shlex
|
|||
|
||||
import borgmatic.borg.pattern
|
||||
import borgmatic.config.paths
|
||||
import borgmatic.hooks.command
|
||||
import borgmatic.hooks.credential.parse
|
||||
from borgmatic.execute import execute_command, execute_command_with_processes
|
||||
from borgmatic.hooks.data_source import dump
|
||||
|
@ -49,13 +48,6 @@ def dump_data_sources(
|
|||
Also append the the parent directory of the database dumps to the given patterns list, so the
|
||||
dumps actually get backed up.
|
||||
'''
|
||||
with borgmatic.hooks.command.Before_after_hooks(
|
||||
command_hooks=config.get('commands'),
|
||||
before_after='dump_data_sources',
|
||||
umask=config.get('umask'),
|
||||
dry_run=dry_run,
|
||||
hook_name='mongodb',
|
||||
):
|
||||
dry_run_label = ' (dry run; not actually dumping anything)' if dry_run else ''
|
||||
|
||||
logger.info(f'Dumping MongoDB databases{dry_run_label}')
|
||||
|
|
|
@ -5,7 +5,6 @@ import shlex
|
|||
|
||||
import borgmatic.borg.pattern
|
||||
import borgmatic.config.paths
|
||||
import borgmatic.hooks.command
|
||||
import borgmatic.hooks.credential.parse
|
||||
import borgmatic.hooks.data_source.mariadb
|
||||
from borgmatic.execute import (
|
||||
|
@ -170,13 +169,6 @@ def dump_data_sources(
|
|||
Also append the the parent directory of the database dumps to the given patterns list, so the
|
||||
dumps actually get backed up.
|
||||
'''
|
||||
with borgmatic.hooks.command.Before_after_hooks(
|
||||
command_hooks=config.get('commands'),
|
||||
before_after='dump_data_sources',
|
||||
umask=config.get('umask'),
|
||||
dry_run=dry_run,
|
||||
hook_name='mysql',
|
||||
):
|
||||
dry_run_label = ' (dry run; not actually dumping anything)' if dry_run else ''
|
||||
processes = []
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import shlex
|
|||
|
||||
import borgmatic.borg.pattern
|
||||
import borgmatic.config.paths
|
||||
import borgmatic.hooks.command
|
||||
import borgmatic.hooks.credential.parse
|
||||
from borgmatic.execute import (
|
||||
execute_command,
|
||||
|
@ -142,13 +141,6 @@ def dump_data_sources(
|
|||
|
||||
Raise ValueError if the databases to dump cannot be determined.
|
||||
'''
|
||||
with borgmatic.hooks.command.Before_after_hooks(
|
||||
command_hooks=config.get('commands'),
|
||||
before_after='dump_data_sources',
|
||||
umask=config.get('umask'),
|
||||
dry_run=dry_run,
|
||||
hook_name='postgresql',
|
||||
):
|
||||
dry_run_label = ' (dry run; not actually dumping anything)' if dry_run else ''
|
||||
processes = []
|
||||
|
||||
|
@ -192,11 +184,7 @@ def dump_data_sources(
|
|||
'--clean',
|
||||
'--if-exists',
|
||||
)
|
||||
+ (
|
||||
('--host', shlex.quote(database['hostname']))
|
||||
if 'hostname' in database
|
||||
else ()
|
||||
)
|
||||
+ (('--host', shlex.quote(database['hostname'])) if 'hostname' in database else ())
|
||||
+ (('--port', shlex.quote(str(database['port']))) if 'port' in database else ())
|
||||
+ (
|
||||
(
|
||||
|
@ -212,11 +200,7 @@ def dump_data_sources(
|
|||
)
|
||||
+ (('--no-owner',) if database.get('no_owner', False) else ())
|
||||
+ (('--format', shlex.quote(dump_format)) if dump_format else ())
|
||||
+ (
|
||||
('--compress', shlex.quote(str(compression)))
|
||||
if compression is not None
|
||||
else ()
|
||||
)
|
||||
+ (('--compress', shlex.quote(str(compression))) if compression is not None else ())
|
||||
+ (('--file', shlex.quote(dump_filename)) if dump_format == 'directory' else ())
|
||||
+ (
|
||||
tuple(shlex.quote(option) for option in database['options'].split(' '))
|
||||
|
|
|
@ -4,7 +4,6 @@ import shlex
|
|||
|
||||
import borgmatic.borg.pattern
|
||||
import borgmatic.config.paths
|
||||
import borgmatic.hooks.command
|
||||
from borgmatic.execute import execute_command, execute_command_with_processes
|
||||
from borgmatic.hooks.data_source import dump
|
||||
|
||||
|
@ -48,13 +47,6 @@ def dump_data_sources(
|
|||
Also append the the parent directory of the database dumps to the given patterns list, so the
|
||||
dumps actually get backed up.
|
||||
'''
|
||||
with borgmatic.hooks.command.Before_after_hooks(
|
||||
command_hooks=config.get('commands'),
|
||||
before_after='dump_data_sources',
|
||||
umask=config.get('umask'),
|
||||
dry_run=dry_run,
|
||||
hook_name='sqlite',
|
||||
):
|
||||
dry_run_label = ' (dry run; not actually dumping anything)' if dry_run else ''
|
||||
processes = []
|
||||
|
||||
|
@ -80,8 +72,7 @@ def dump_data_sources(
|
|||
continue
|
||||
|
||||
sqlite_command = tuple(
|
||||
shlex.quote(part)
|
||||
for part in shlex.split(database.get('sqlite_command') or 'sqlite3')
|
||||
shlex.quote(part) for part in shlex.split(database.get('sqlite_command') or 'sqlite3')
|
||||
)
|
||||
command = sqlite_command + (
|
||||
shlex.quote(database_path),
|
||||
|
|
|
@ -9,7 +9,6 @@ import subprocess
|
|||
import borgmatic.borg.pattern
|
||||
import borgmatic.config.paths
|
||||
import borgmatic.execute
|
||||
import borgmatic.hooks.command
|
||||
import borgmatic.hooks.data_source.snapshot
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -244,13 +243,6 @@ def dump_data_sources(
|
|||
|
||||
If this is a dry run, then don't actually snapshot anything.
|
||||
'''
|
||||
with borgmatic.hooks.command.Before_after_hooks(
|
||||
command_hooks=config.get('commands'),
|
||||
before_after='dump_data_sources',
|
||||
umask=config.get('umask'),
|
||||
dry_run=dry_run,
|
||||
hook_name='zfs',
|
||||
):
|
||||
dry_run_label = ' (dry run; not actually snapshotting anything)' if dry_run else ''
|
||||
logger.info(f'Snapshotting ZFS datasets{dry_run_label}')
|
||||
|
||||
|
|
|
@ -71,23 +71,6 @@ those two hooks. This allows you to perform cleanup steps that correspond to `be
|
|||
commands—even when something goes wrong. This is a departure from the way that the deprecated
|
||||
`after_*` hooks worked.
|
||||
|
||||
There's also another command hook that works a little differently:
|
||||
|
||||
```yaml
|
||||
commands:
|
||||
- before: dump_data_sources
|
||||
hooks: [postgresql]
|
||||
run:
|
||||
- echo "Right before the PostgreSQL database dump!"
|
||||
```
|
||||
|
||||
This command hook has the following options:
|
||||
|
||||
* `before` or `after`: Name for the point in borgmatic's execution that the commands should be run before or after:
|
||||
* `dump_data_sources` runs before or after data sources are dumped (databases dumped or filesystems snapshotted) for each hook named in `hooks`.
|
||||
* `hooks`: Names of other hooks that this command hook applies to, e.g. `postgresql`, `mariadb`, `zfs`, `btrfs`, etc. Defaults to all hooks of the relevant type.
|
||||
* `run`: One or more shell commands or scripts to run when this command hook is triggered.
|
||||
|
||||
|
||||
### Order of execution
|
||||
|
||||
|
@ -102,9 +85,6 @@ borgmatic for the `create` and `prune` actions. Here's the order of execution:
|
|||
* Run `before: configuration` hooks (from the first configuration file).
|
||||
* Run `before: repository` hooks (for the first repository).
|
||||
* Run `before: action` hooks for `create`.
|
||||
* Run `before: dump_data_sources` hooks (e.g. for the PostgreSQL hook).
|
||||
* Actually dump data sources (e.g. PostgreSQL databases).
|
||||
* Run `after: dump_data_sources` hooks (e.g. for the PostgreSQL hook).
|
||||
* Actually run the `create` action (e.g. `borg create`).
|
||||
* Run `after: action` hooks for `create`.
|
||||
* Run `before: action` hooks for `prune`.
|
||||
|
|
|
@ -6,9 +6,6 @@ from borgmatic.hooks.data_source import bootstrap as module
|
|||
|
||||
|
||||
def test_dump_data_sources_creates_manifest_file():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
flexmock(module.os).should_receive('makedirs')
|
||||
|
||||
flexmock(module.importlib.metadata).should_receive('version').and_return('1.0.0')
|
||||
|
@ -35,7 +32,6 @@ def test_dump_data_sources_creates_manifest_file():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_store_config_files_false_does_not_create_manifest_file():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').never()
|
||||
flexmock(module.os).should_receive('makedirs').never()
|
||||
flexmock(module.json).should_receive('dump').never()
|
||||
hook_config = {'store_config_files': False}
|
||||
|
@ -51,9 +47,6 @@ def test_dump_data_sources_with_store_config_files_false_does_not_create_manifes
|
|||
|
||||
|
||||
def test_dump_data_sources_with_dry_run_does_not_create_manifest_file():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
flexmock(module.os).should_receive('makedirs').never()
|
||||
flexmock(module.json).should_receive('dump').never()
|
||||
|
||||
|
|
|
@ -269,9 +269,6 @@ def test_make_borg_snapshot_pattern_includes_slashdot_hack_and_stripped_pattern_
|
|||
|
||||
|
||||
def test_dump_data_sources_snapshots_each_subvolume_and_updates_patterns():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
patterns = [Pattern('/foo'), Pattern('/mnt/subvol1')]
|
||||
config = {'btrfs': {}}
|
||||
flexmock(module).should_receive('get_subvolumes').and_return(
|
||||
|
@ -350,9 +347,6 @@ def test_dump_data_sources_snapshots_each_subvolume_and_updates_patterns():
|
|||
|
||||
|
||||
def test_dump_data_sources_uses_custom_btrfs_command_in_commands():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
patterns = [Pattern('/foo'), Pattern('/mnt/subvol1')]
|
||||
config = {'btrfs': {'btrfs_command': '/usr/local/bin/btrfs'}}
|
||||
flexmock(module).should_receive('get_subvolumes').and_return(
|
||||
|
@ -406,9 +400,6 @@ def test_dump_data_sources_uses_custom_btrfs_command_in_commands():
|
|||
|
||||
|
||||
def test_dump_data_sources_uses_custom_findmnt_command_in_commands():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
patterns = [Pattern('/foo'), Pattern('/mnt/subvol1')]
|
||||
config = {'btrfs': {'findmnt_command': '/usr/local/bin/findmnt'}}
|
||||
flexmock(module).should_receive('get_subvolumes').with_args(
|
||||
|
@ -464,9 +455,6 @@ def test_dump_data_sources_uses_custom_findmnt_command_in_commands():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_dry_run_skips_snapshot_and_patterns_update():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
patterns = [Pattern('/foo'), Pattern('/mnt/subvol1')]
|
||||
config = {'btrfs': {}}
|
||||
flexmock(module).should_receive('get_subvolumes').and_return(
|
||||
|
@ -495,9 +483,6 @@ def test_dump_data_sources_with_dry_run_skips_snapshot_and_patterns_update():
|
|||
|
||||
|
||||
def test_dump_data_sources_without_matching_subvolumes_skips_snapshot_and_patterns_update():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
patterns = [Pattern('/foo'), Pattern('/mnt/subvol1')]
|
||||
config = {'btrfs': {}}
|
||||
flexmock(module).should_receive('get_subvolumes').and_return(())
|
||||
|
@ -522,9 +507,6 @@ def test_dump_data_sources_without_matching_subvolumes_skips_snapshot_and_patter
|
|||
|
||||
|
||||
def test_dump_data_sources_snapshots_adds_to_existing_exclude_patterns():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
patterns = [Pattern('/foo'), Pattern('/mnt/subvol1')]
|
||||
config = {'btrfs': {}, 'exclude_patterns': ['/bar']}
|
||||
flexmock(module).should_receive('get_subvolumes').and_return(
|
||||
|
|
|
@ -282,9 +282,6 @@ def test_make_borg_snapshot_pattern_includes_slashdot_hack_and_stripped_pattern_
|
|||
|
||||
|
||||
def test_dump_data_sources_snapshots_and_mounts_and_updates_patterns():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
config = {'lvm': {}}
|
||||
patterns = [Pattern('/mnt/lvolume1/subdir'), Pattern('/mnt/lvolume2')]
|
||||
logical_volumes = (
|
||||
|
@ -354,9 +351,6 @@ def test_dump_data_sources_snapshots_and_mounts_and_updates_patterns():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_no_logical_volumes_skips_snapshots():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
config = {'lvm': {}}
|
||||
patterns = [Pattern('/mnt/lvolume1/subdir'), Pattern('/mnt/lvolume2')]
|
||||
flexmock(module).should_receive('get_logical_volumes').and_return(())
|
||||
|
@ -379,9 +373,6 @@ def test_dump_data_sources_with_no_logical_volumes_skips_snapshots():
|
|||
|
||||
|
||||
def test_dump_data_sources_uses_snapshot_size_for_snapshot():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
config = {'lvm': {'snapshot_size': '1000PB'}}
|
||||
patterns = [Pattern('/mnt/lvolume1/subdir'), Pattern('/mnt/lvolume2')]
|
||||
logical_volumes = (
|
||||
|
@ -457,9 +448,6 @@ def test_dump_data_sources_uses_snapshot_size_for_snapshot():
|
|||
|
||||
|
||||
def test_dump_data_sources_uses_custom_commands():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
config = {
|
||||
'lvm': {
|
||||
'lsblk_command': '/usr/local/bin/lsblk',
|
||||
|
@ -546,9 +534,6 @@ def test_dump_data_sources_uses_custom_commands():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_dry_run_skips_snapshots_and_does_not_touch_patterns():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
config = {'lvm': {}}
|
||||
patterns = [Pattern('/mnt/lvolume1/subdir'), Pattern('/mnt/lvolume2')]
|
||||
flexmock(module).should_receive('get_logical_volumes').and_return(
|
||||
|
@ -600,9 +585,6 @@ def test_dump_data_sources_with_dry_run_skips_snapshots_and_does_not_touch_patte
|
|||
|
||||
|
||||
def test_dump_data_sources_ignores_mismatch_between_given_patterns_and_contained_patterns():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
config = {'lvm': {}}
|
||||
patterns = [Pattern('/hmm')]
|
||||
logical_volumes = (
|
||||
|
@ -673,9 +655,6 @@ def test_dump_data_sources_ignores_mismatch_between_given_patterns_and_contained
|
|||
|
||||
|
||||
def test_dump_data_sources_with_missing_snapshot_errors():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
config = {'lvm': {}}
|
||||
patterns = [Pattern('/mnt/lvolume1/subdir'), Pattern('/mnt/lvolume2')]
|
||||
flexmock(module).should_receive('get_logical_volumes').and_return(
|
||||
|
|
|
@ -237,9 +237,6 @@ def test_use_streaming_false_for_no_databases():
|
|||
|
||||
|
||||
def test_dump_data_sources_dumps_each_database():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||
processes = [flexmock(), flexmock()]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -281,9 +278,6 @@ def test_dump_data_sources_dumps_each_database():
|
|||
|
||||
|
||||
def test_dump_data_sources_dumps_with_password():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
database = {'name': 'foo', 'username': 'root', 'password': 'trustsome1'}
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -318,9 +312,6 @@ def test_dump_data_sources_dumps_with_password():
|
|||
|
||||
|
||||
def test_dump_data_sources_dumps_all_databases_at_once():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all'}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -352,9 +343,6 @@ def test_dump_data_sources_dumps_all_databases_at_once():
|
|||
|
||||
|
||||
def test_dump_data_sources_dumps_all_databases_separately_when_format_configured():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all', 'format': 'sql'}]
|
||||
processes = [flexmock(), flexmock()]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -862,9 +850,6 @@ def test_execute_dump_command_with_dry_run_skips_mariadb_dump():
|
|||
|
||||
|
||||
def test_dump_data_sources_errors_for_missing_all_databases():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all'}]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
flexmock(module.os).should_receive('environ').and_return({'USER': 'root'})
|
||||
|
@ -888,9 +873,6 @@ def test_dump_data_sources_errors_for_missing_all_databases():
|
|||
|
||||
|
||||
def test_dump_data_sources_does_not_error_for_missing_all_databases_with_dry_run():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all'}]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
flexmock(module.os).should_receive('environ').and_return({'USER': 'root'})
|
||||
|
|
|
@ -24,9 +24,6 @@ def test_use_streaming_false_for_no_databases():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_mongodump_for_each_database():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||
processes = [flexmock(), flexmock()]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -56,9 +53,6 @@ def test_dump_data_sources_runs_mongodump_for_each_database():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_dry_run_skips_mongodump():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return(
|
||||
|
@ -81,9 +75,6 @@ def test_dump_data_sources_with_dry_run_skips_mongodump():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_mongodump_with_hostname_and_port():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'hostname': 'database.example.org', 'port': 5433}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -120,9 +111,6 @@ def test_dump_data_sources_runs_mongodump_with_hostname_and_port():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_mongodump_with_username_and_password():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [
|
||||
{
|
||||
'name': 'foo',
|
||||
|
@ -174,9 +162,6 @@ def test_dump_data_sources_runs_mongodump_with_username_and_password():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_mongodump_with_directory_format():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'format': 'directory'}]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return(
|
||||
|
@ -204,9 +189,6 @@ def test_dump_data_sources_runs_mongodump_with_directory_format():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_mongodump_with_options():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'options': '--stuff=such'}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -240,9 +222,6 @@ def test_dump_data_sources_runs_mongodump_with_options():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_mongodumpall_for_all_databases():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all'}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
|
|
@ -134,9 +134,6 @@ def test_use_streaming_false_for_no_databases():
|
|||
|
||||
|
||||
def test_dump_data_sources_dumps_each_database():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||
processes = [flexmock(), flexmock()]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -175,9 +172,6 @@ def test_dump_data_sources_dumps_each_database():
|
|||
|
||||
|
||||
def test_dump_data_sources_dumps_with_password():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
database = {'name': 'foo', 'username': 'root', 'password': 'trustsome1'}
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -212,9 +206,6 @@ def test_dump_data_sources_dumps_with_password():
|
|||
|
||||
|
||||
def test_dump_data_sources_dumps_all_databases_at_once():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all'}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -246,9 +237,6 @@ def test_dump_data_sources_dumps_all_databases_at_once():
|
|||
|
||||
|
||||
def test_dump_data_sources_dumps_all_databases_separately_when_format_configured():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all', 'format': 'sql'}]
|
||||
processes = [flexmock(), flexmock()]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -774,9 +762,6 @@ def test_execute_dump_command_with_dry_run_skips_mysqldump():
|
|||
|
||||
|
||||
def test_dump_data_sources_errors_for_missing_all_databases():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all'}]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
flexmock(module.os).should_receive('environ').and_return({'USER': 'root'})
|
||||
|
@ -800,9 +785,6 @@ def test_dump_data_sources_errors_for_missing_all_databases():
|
|||
|
||||
|
||||
def test_dump_data_sources_does_not_error_for_missing_all_databases_with_dry_run():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all'}]
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
flexmock(module.os).should_receive('environ').and_return({'USER': 'root'})
|
||||
|
|
|
@ -236,9 +236,6 @@ def test_use_streaming_false_for_no_databases():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_pg_dump_for_each_database():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||
processes = [flexmock(), flexmock()]
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
|
@ -287,9 +284,6 @@ def test_dump_data_sources_runs_pg_dump_for_each_database():
|
|||
|
||||
|
||||
def test_dump_data_sources_raises_when_no_database_names_to_dump():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -307,9 +301,6 @@ def test_dump_data_sources_raises_when_no_database_names_to_dump():
|
|||
|
||||
|
||||
def test_dump_data_sources_does_not_raise_when_no_database_names_to_dump():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -326,9 +317,6 @@ def test_dump_data_sources_does_not_raise_when_no_database_names_to_dump():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_duplicate_dump_skips_pg_dump():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -356,9 +344,6 @@ def test_dump_data_sources_with_duplicate_dump_skips_pg_dump():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_dry_run_skips_pg_dump():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo'}, {'name': 'bar'}]
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -389,9 +374,6 @@ def test_dump_data_sources_with_dry_run_skips_pg_dump():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_pg_dump_with_hostname_and_port():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'hostname': 'database.example.org', 'port': 5433}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
|
@ -438,9 +420,6 @@ def test_dump_data_sources_runs_pg_dump_with_hostname_and_port():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_pg_dump_with_username_and_password():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'username': 'postgres', 'password': 'trustsome1'}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_environment').and_return(
|
||||
|
@ -487,9 +466,6 @@ def test_dump_data_sources_runs_pg_dump_with_username_and_password():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_username_injection_attack_gets_escaped():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'username': 'postgres; naughty-command', 'password': 'trustsome1'}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_environment').and_return(
|
||||
|
@ -536,9 +512,6 @@ def test_dump_data_sources_with_username_injection_attack_gets_escaped():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_pg_dump_with_directory_format():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'format': 'directory'}]
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
flexmock(module).should_receive('make_dump_path').and_return('')
|
||||
|
@ -583,9 +556,6 @@ def test_dump_data_sources_runs_pg_dump_with_directory_format():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_pg_dump_with_string_compression():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'compression': 'winrar'}]
|
||||
processes = [flexmock()]
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
|
@ -633,9 +603,6 @@ def test_dump_data_sources_runs_pg_dump_with_string_compression():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_pg_dump_with_integer_compression():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'compression': 0}]
|
||||
processes = [flexmock()]
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
|
@ -683,9 +650,6 @@ def test_dump_data_sources_runs_pg_dump_with_integer_compression():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_pg_dump_with_options():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'options': '--stuff=such'}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
|
@ -729,9 +693,6 @@ def test_dump_data_sources_runs_pg_dump_with_options():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_pg_dumpall_for_all_databases():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'all'}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
|
@ -764,9 +725,6 @@ def test_dump_data_sources_runs_pg_dumpall_for_all_databases():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_non_default_pg_dump():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'name': 'foo', 'pg_dump_command': 'special_pg_dump --compress *'}]
|
||||
process = flexmock()
|
||||
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
||||
|
|
|
@ -17,9 +17,6 @@ def test_use_streaming_false_for_no_databases():
|
|||
|
||||
|
||||
def test_dump_data_sources_logs_and_skips_if_dump_already_exists():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'path': '/path/to/database', 'name': 'database'}]
|
||||
|
||||
flexmock(module).should_receive('make_dump_path').and_return('/run/borgmatic')
|
||||
|
@ -44,9 +41,6 @@ def test_dump_data_sources_logs_and_skips_if_dump_already_exists():
|
|||
|
||||
|
||||
def test_dump_data_sources_dumps_each_database():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [
|
||||
{'path': '/path/to/database1', 'name': 'database1'},
|
||||
{'path': '/path/to/database2', 'name': 'database2'},
|
||||
|
@ -77,9 +71,6 @@ def test_dump_data_sources_dumps_each_database():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_path_injection_attack_gets_escaped():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [
|
||||
{'path': '/path/to/database1; naughty-command', 'name': 'database1'},
|
||||
]
|
||||
|
@ -117,9 +108,6 @@ def test_dump_data_sources_with_path_injection_attack_gets_escaped():
|
|||
|
||||
|
||||
def test_dump_data_sources_runs_non_default_sqlite_with_path_injection_attack_gets_escaped():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [
|
||||
{
|
||||
'path': '/path/to/database1; naughty-command',
|
||||
|
@ -162,9 +150,6 @@ def test_dump_data_sources_runs_non_default_sqlite_with_path_injection_attack_ge
|
|||
|
||||
|
||||
def test_dump_data_sources_with_non_existent_path_warns_and_dumps_database():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [
|
||||
{'path': '/path/to/database1', 'name': 'database1'},
|
||||
]
|
||||
|
@ -193,9 +178,6 @@ def test_dump_data_sources_with_non_existent_path_warns_and_dumps_database():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_name_all_warns_and_dumps_all_databases():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [
|
||||
{'path': '/path/to/database1', 'name': 'all'},
|
||||
]
|
||||
|
@ -226,9 +208,6 @@ def test_dump_data_sources_with_name_all_warns_and_dumps_all_databases():
|
|||
|
||||
|
||||
def test_dump_data_sources_does_not_dump_if_dry_run():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
databases = [{'path': '/path/to/database', 'name': 'database'}]
|
||||
|
||||
flexmock(module).should_receive('make_dump_path').and_return('/run/borgmatic')
|
||||
|
|
|
@ -296,9 +296,6 @@ def test_make_borg_snapshot_pattern_includes_slashdot_hack_and_stripped_pattern_
|
|||
|
||||
|
||||
def test_dump_data_sources_snapshots_and_mounts_and_updates_patterns():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
dataset = flexmock(
|
||||
name='dataset',
|
||||
mount_point='/mnt/dataset',
|
||||
|
@ -341,9 +338,6 @@ def test_dump_data_sources_snapshots_and_mounts_and_updates_patterns():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_no_datasets_skips_snapshots():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
flexmock(module).should_receive('get_datasets_to_backup').and_return(())
|
||||
flexmock(module.os).should_receive('getpid').and_return(1234)
|
||||
flexmock(module).should_receive('snapshot_dataset').never()
|
||||
|
@ -366,9 +360,6 @@ def test_dump_data_sources_with_no_datasets_skips_snapshots():
|
|||
|
||||
|
||||
def test_dump_data_sources_uses_custom_commands():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
dataset = flexmock(
|
||||
name='dataset',
|
||||
mount_point='/mnt/dataset',
|
||||
|
@ -418,9 +409,6 @@ def test_dump_data_sources_uses_custom_commands():
|
|||
|
||||
|
||||
def test_dump_data_sources_with_dry_run_skips_commands_and_does_not_touch_patterns():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
flexmock(module).should_receive('get_datasets_to_backup').and_return(
|
||||
(flexmock(name='dataset', mount_point='/mnt/dataset'),)
|
||||
)
|
||||
|
@ -445,9 +433,6 @@ def test_dump_data_sources_with_dry_run_skips_commands_and_does_not_touch_patter
|
|||
|
||||
|
||||
def test_dump_data_sources_ignores_mismatch_between_given_patterns_and_contained_patterns():
|
||||
flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
|
||||
flexmock()
|
||||
)
|
||||
dataset = flexmock(
|
||||
name='dataset',
|
||||
mount_point='/mnt/dataset',
|
||||
|
|
|
@ -133,121 +133,6 @@ def test_make_environment_with_pyinstaller_and_LD_LIBRARY_PATH_ORIG_copies_it_in
|
|||
},
|
||||
),
|
||||
),
|
||||
(
|
||||
(
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'hooks': ['postgresql'],
|
||||
'run': ['foo'],
|
||||
},
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'hooks': ['lvm'],
|
||||
'run': ['bar'],
|
||||
},
|
||||
{
|
||||
'after': 'dump_data_sources',
|
||||
'hooks': ['lvm'],
|
||||
'run': ['baz'],
|
||||
},
|
||||
),
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'hook_name': 'lvm',
|
||||
},
|
||||
(
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'hooks': ['lvm'],
|
||||
'run': ['bar'],
|
||||
},
|
||||
),
|
||||
),
|
||||
(
|
||||
(
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'run': ['foo'],
|
||||
},
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'run': ['bar'],
|
||||
},
|
||||
{
|
||||
'after': 'dump_data_sources',
|
||||
'run': ['baz'],
|
||||
},
|
||||
),
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'hook_name': 'lvm',
|
||||
},
|
||||
(
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'run': ['foo'],
|
||||
},
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'run': ['bar'],
|
||||
},
|
||||
),
|
||||
),
|
||||
(
|
||||
(
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'hooks': ['postgresql', 'zfs', 'lvm'],
|
||||
'run': ['foo'],
|
||||
},
|
||||
),
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'hook_name': 'lvm',
|
||||
},
|
||||
(
|
||||
{
|
||||
'before': 'dump_data_sources',
|
||||
'hooks': ['postgresql', 'zfs', 'lvm'],
|
||||
'run': ['foo'],
|
||||
},
|
||||
),
|
||||
),
|
||||
(
|
||||
(
|
||||
{
|
||||
'before': 'action',
|
||||
'when': ['create'],
|
||||
'run': ['foo'],
|
||||
},
|
||||
{
|
||||
'before': 'action',
|
||||
'when': ['prune'],
|
||||
'run': ['bar'],
|
||||
},
|
||||
{
|
||||
'before': 'action',
|
||||
'when': ['compact'],
|
||||
'run': ['baz'],
|
||||
},
|
||||
),
|
||||
{
|
||||
'before': 'action',
|
||||
'action_names': ['create', 'compact', 'extract'],
|
||||
},
|
||||
(
|
||||
{
|
||||
'before': 'action',
|
||||
'when': ['create'],
|
||||
'run': ['foo'],
|
||||
},
|
||||
{
|
||||
'before': 'action',
|
||||
'when': ['compact'],
|
||||
'run': ['baz'],
|
||||
},
|
||||
),
|
||||
),
|
||||
(
|
||||
(
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue