mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-22 10:13:00 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58d33503a1 | ||
|
|
38322a3f6f | ||
|
|
52ab7cb881 | ||
|
|
17ac63aae6 |
@@ -12,3 +12,5 @@ a03495a8e8b471da63b5e2ae79d3ff9065839c2a 0.0.5
|
||||
cf4c7065f0711deda1cba878398bc05390e2c3f9 0.0.7
|
||||
38d72677343f0a5d6845f4ac50d6778397083d45 0.1.0
|
||||
ac5dfa01e9d14d09845f5e94c2c679e21c5eb2f9 0.1.1
|
||||
ac5dfa01e9d14d09845f5e94c2c679e21c5eb2f9 0.1.1
|
||||
7b6c87dca7ea312b2257ac1b46857b3f8c56b39c 0.1.1
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
0.1.2
|
||||
|
||||
* As a convenience to new users, allow a missing default excludes file.
|
||||
* New issue tracker, linked from documentation.
|
||||
|
||||
0.1.1
|
||||
|
||||
* Adding borgmatic cron example, and updating documentation to refer to it.
|
||||
|
||||
@@ -135,6 +135,9 @@ This should make the client keep the connection alive while validating
|
||||
backups.
|
||||
|
||||
|
||||
## Feedback
|
||||
## Issues and feedback
|
||||
|
||||
Questions? Comments? Got a patch? Contact <mailto:witten@torsion.org>.
|
||||
Got an issue or an idea for a feature enhancement? Check out the [atticmatic
|
||||
issue tracker](https://tree.taiga.io/project/witten-atticmatic/issues).
|
||||
|
||||
Other questions or comments? Contact <mailto:witten@torsion.org>.
|
||||
|
||||
@@ -14,10 +14,11 @@ from atticmatic.verbosity import VERBOSITY_SOME, VERBOSITY_LOTS
|
||||
|
||||
def create_archive(excludes_filename, verbosity, source_directories, repository, command):
|
||||
'''
|
||||
Given an excludes filename, a vebosity flag, a space-separated list of source directories, a
|
||||
local or remote repository path, and a command to run, create an attic archive.
|
||||
Given an excludes filename (or None), a vebosity flag, a space-separated list of source
|
||||
directories, a local or remote repository path, and a command to run, create an attic archive.
|
||||
'''
|
||||
sources = tuple(source_directories.split(' '))
|
||||
exclude_flags = ('--exclude-from', excludes_filename) if excludes_filename else ()
|
||||
verbosity_flags = {
|
||||
VERBOSITY_SOME: ('--stats',),
|
||||
VERBOSITY_LOTS: ('--verbose', '--stats'),
|
||||
@@ -25,13 +26,12 @@ def create_archive(excludes_filename, verbosity, source_directories, repository,
|
||||
|
||||
full_command = (
|
||||
command, 'create',
|
||||
'--exclude-from', excludes_filename,
|
||||
'{repo}::{hostname}-{timestamp}'.format(
|
||||
repo=repository,
|
||||
hostname=platform.node(),
|
||||
timestamp=datetime.now().isoformat(),
|
||||
),
|
||||
) + sources + verbosity_flags
|
||||
) + sources + exclude_flags + verbosity_flags
|
||||
|
||||
subprocess.check_call(full_command)
|
||||
|
||||
|
||||
@@ -18,17 +18,20 @@ def parse_arguments(command_name, *arguments):
|
||||
parse the arguments and return them as an ArgumentParser instance. Use the command name to
|
||||
determine the default configuration and excludes paths.
|
||||
'''
|
||||
config_filename_default = DEFAULT_CONFIG_FILENAME_PATTERN.format(command_name)
|
||||
excludes_filename_default = DEFAULT_EXCLUDES_FILENAME_PATTERN.format(command_name)
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument(
|
||||
'-c', '--config',
|
||||
dest='config_filename',
|
||||
default=DEFAULT_CONFIG_FILENAME_PATTERN.format(command_name),
|
||||
default=config_filename_default,
|
||||
help='Configuration filename',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--excludes',
|
||||
dest='excludes_filename',
|
||||
default=DEFAULT_EXCLUDES_FILENAME_PATTERN.format(command_name),
|
||||
default=excludes_filename_default if os.path.exists(excludes_filename_default) else None,
|
||||
help='Excludes filename',
|
||||
)
|
||||
parser.add_argument(
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
from flexmock import flexmock
|
||||
from nose.tools import assert_raises
|
||||
|
||||
from atticmatic import command as module
|
||||
@@ -9,6 +11,8 @@ COMMAND_NAME = 'foomatic'
|
||||
|
||||
|
||||
def test_parse_arguments_with_no_arguments_uses_defaults():
|
||||
flexmock(os.path).should_receive('exists').and_return(True)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME)
|
||||
|
||||
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
@@ -17,6 +21,8 @@ def test_parse_arguments_with_no_arguments_uses_defaults():
|
||||
|
||||
|
||||
def test_parse_arguments_with_filename_arguments_overrides_defaults():
|
||||
flexmock(os.path).should_receive('exists').and_return(True)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME, '--config', 'myconfig', '--excludes', 'myexcludes')
|
||||
|
||||
assert parser.config_filename == 'myconfig'
|
||||
@@ -24,7 +30,29 @@ def test_parse_arguments_with_filename_arguments_overrides_defaults():
|
||||
assert parser.verbosity == None
|
||||
|
||||
|
||||
def test_parse_arguments_with_missing_default_excludes_file_sets_filename_to_none():
|
||||
flexmock(os.path).should_receive('exists').and_return(False)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME)
|
||||
|
||||
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
assert parser.excludes_filename == None
|
||||
assert parser.verbosity == None
|
||||
|
||||
|
||||
def test_parse_arguments_with_missing_overridden_excludes_file_retains_filename():
|
||||
flexmock(os.path).should_receive('exists').and_return(False)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME, '--excludes', 'myexcludes')
|
||||
|
||||
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
assert parser.excludes_filename == 'myexcludes'
|
||||
assert parser.verbosity == None
|
||||
|
||||
|
||||
def test_parse_arguments_with_verbosity_flag_overrides_default():
|
||||
flexmock(os.path).should_receive('exists').and_return(True)
|
||||
|
||||
parser = module.parse_arguments(COMMAND_NAME, '--verbosity', '1')
|
||||
|
||||
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME_PATTERN.format(COMMAND_NAME)
|
||||
@@ -33,6 +61,7 @@ def test_parse_arguments_with_verbosity_flag_overrides_default():
|
||||
|
||||
|
||||
def test_parse_arguments_with_invalid_arguments_exits():
|
||||
flexmock(os.path).should_receive('exists').and_return(True)
|
||||
original_stderr = sys.stderr
|
||||
sys.stderr = sys.stdout
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ def insert_datetime_mock():
|
||||
).mock
|
||||
|
||||
|
||||
CREATE_COMMAND = ('attic', 'create', '--exclude-from', 'excludes', 'repo::host-now', 'foo', 'bar')
|
||||
CREATE_COMMAND_WITHOUT_EXCLUDES = ('attic', 'create', 'repo::host-now', 'foo', 'bar')
|
||||
CREATE_COMMAND = CREATE_COMMAND_WITHOUT_EXCLUDES + ('--exclude-from', 'excludes')
|
||||
|
||||
|
||||
def test_create_archive_should_call_attic_with_parameters():
|
||||
@@ -46,6 +47,20 @@ def test_create_archive_should_call_attic_with_parameters():
|
||||
)
|
||||
|
||||
|
||||
def test_create_archive_with_none_excludes_filename_should_call_attic_without_excludes():
|
||||
insert_subprocess_mock(CREATE_COMMAND_WITHOUT_EXCLUDES)
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
|
||||
module.create_archive(
|
||||
excludes_filename=None,
|
||||
verbosity=None,
|
||||
source_directories='foo bar',
|
||||
repository='repo',
|
||||
command='attic',
|
||||
)
|
||||
|
||||
|
||||
def test_create_archive_with_verbosity_some_should_call_attic_with_stats_parameter():
|
||||
insert_subprocess_mock(CREATE_COMMAND + ('--stats',))
|
||||
insert_platform_mock()
|
||||
|
||||
+2
-1
@@ -7,7 +7,8 @@ repository: user@backupserver:sourcehostname.attic
|
||||
|
||||
[retention]
|
||||
# Retention policy for how many backups to keep in each category. See
|
||||
# https://attic-backup.org/usage.html#attic-prune for details.
|
||||
# https://attic-backup.org/usage.html#attic-prune or
|
||||
# https://borgbackup.github.io/borgbackup/usage.html#borg-prune for details.
|
||||
#keep_within: 3h
|
||||
#keep_hourly: 24
|
||||
keep_daily: 7
|
||||
|
||||
Reference in New Issue
Block a user