mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-31 13:43:02 +02:00
add rest of flags
This commit is contained in:
@@ -23,9 +23,9 @@ def run_recreate(
|
||||
repository, recreate_arguments.repository
|
||||
):
|
||||
if recreate_arguments.archive:
|
||||
logger.info(f'Recreating archive {recreate_arguments.archive}')
|
||||
logger.answer(f'Recreating archive {recreate_arguments.archive}')
|
||||
else:
|
||||
logger.info('Recreating repository')
|
||||
logger.answer('Recreating repository')
|
||||
|
||||
# Collect and process patterns.
|
||||
processed_patterns = process_patterns(
|
||||
|
||||
+15
-15
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import shlex
|
||||
from datetime import datetime
|
||||
|
||||
import borgmatic.borg.environment
|
||||
@@ -10,15 +11,6 @@ from borgmatic.borg.create import make_exclude_flags, make_list_filter_flags, wr
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def is_valid_timestamp(time_str):
|
||||
try:
|
||||
# Attempt to parse the time string using the expected format
|
||||
datetime.strptime(time_str, r"%Y-%m-%dT%H:%M:%S")
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def recreate_archive(
|
||||
repository,
|
||||
archive,
|
||||
@@ -37,15 +29,11 @@ def recreate_archive(
|
||||
|
||||
Executes the recreate command with the given arguments.
|
||||
'''
|
||||
if recreate_arguments.timestamp and not is_valid_timestamp(recreate_arguments.timestamp):
|
||||
logger.error(
|
||||
'Please provide a valid timestamp of format: yyyy-mm-ddThh:mm:ss. Example: 2025-03-26T14:45:59'
|
||||
)
|
||||
return
|
||||
|
||||
lock_wait = config.get('lock_wait', None)
|
||||
exclude_flags = make_exclude_flags(config)
|
||||
compression = config.get('compression', None)
|
||||
chunker_params = config.get('chunker_params', None)
|
||||
|
||||
# Write patterns to a temporary file and use that file with --patterns-from.
|
||||
patterns_file = write_patterns_file(
|
||||
@@ -80,8 +68,20 @@ def recreate_archive(
|
||||
if recreate_arguments.target and recreate_arguments.archive
|
||||
else ()
|
||||
)
|
||||
+ (('--comment', f'"{recreate_arguments.comment}"') if recreate_arguments.comment else ())
|
||||
+ (
|
||||
('--comment', shlex.quote(recreate_arguments.comment))
|
||||
if recreate_arguments.comment
|
||||
else ()
|
||||
)
|
||||
+ (('--timestamp', recreate_arguments.timestamp) if recreate_arguments.timestamp else ())
|
||||
+ (('--compression', compression) if compression else ())
|
||||
+ (('--chunker-params', chunker_params) if chunker_params else ())
|
||||
+ flags.make_match_archives_flags(
|
||||
recreate_arguments.match_archives or archive or config.get('match_archives'),
|
||||
config.get('archive_name_format'),
|
||||
local_borg_version,
|
||||
)
|
||||
+ (('--recompress', recreate_arguments.recompress) if recreate_arguments.recompress else ())
|
||||
+ exclude_flags
|
||||
+ (
|
||||
flags.make_repository_archive_flags(repository, archive, local_borg_version)
|
||||
|
||||
@@ -1582,17 +1582,22 @@ def make_parsers():
|
||||
metavar='COMMENT',
|
||||
help='Add a comment text to the archive, if archive not provided, consider all archives',
|
||||
)
|
||||
recreate_group.add_argument(
|
||||
'--compression',
|
||||
'-C',
|
||||
dest='compression',
|
||||
metavar='COMPRESSION',
|
||||
help='Select the compression algorithm',
|
||||
)
|
||||
recreate_group.add_argument(
|
||||
'--timestamp',
|
||||
metavar='TIMESTAMP',
|
||||
help='Manually specify the archive creation date/time (UTC, yyyy-mm-ddThh:mm:ss format)',
|
||||
help='Manually specify the archive creation date/time (UTC)',
|
||||
)
|
||||
recreate_group.add_argument(
|
||||
'-a',
|
||||
'--match-archives',
|
||||
'--glob-archives',
|
||||
metavar='PATTERN',
|
||||
help='Only consider archive names, hashes, or series matching this pattern',
|
||||
)
|
||||
recreate_group.add_argument(
|
||||
'--recompress',
|
||||
metavar='MODE',
|
||||
help='Recompress data chunks according to MODE: [if-different (default), always, never]',
|
||||
)
|
||||
recreate_group.add_argument(
|
||||
'-h', '--help', action='help', help='Show this help message and exit'
|
||||
|
||||
Reference in New Issue
Block a user