Add "--repository" flag to the "rcreate" action. Add "--progress" flag to the "transfer" action.

This commit is contained in:
Dan Helfman 2023-02-26 23:22:23 -08:00
parent d7a07f0428
commit 2a36a2a312
5 changed files with 36 additions and 6 deletions

3
NEWS
View file

@ -6,6 +6,9 @@
action. action.
* Fix the "create" action with the "--dry-run" flag querying for databases when a PostgreSQL/MySQL * Fix the "create" action with the "--dry-run" flag querying for databases when a PostgreSQL/MySQL
"all" database is configured. Now, these queries are skipped due to the dry run. "all" database is configured. Now, these queries are skipped due to the dry run.
* Add "--repository" flag to the "rcreate" action to optionally select one configured repository to
create.
* Add "--progress" flag to the "transfer" action, new in Borg 2.0.0b5.
1.7.7 1.7.7
* #642: Add MySQL database hook "add_drop_database" configuration option to control whether dumped * #642: Add MySQL database hook "add_drop_database" configuration option to control whether dumped

View file

@ -1,6 +1,7 @@
import logging import logging
import borgmatic.borg.rcreate import borgmatic.borg.rcreate
import borgmatic.config.validate
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -17,6 +18,11 @@ def run_rcreate(
''' '''
Run the "rcreate" action for the given repository. Run the "rcreate" action for the given repository.
''' '''
if rcreate_arguments.repository and not borgmatic.config.validate.repositories_match(
repository, rcreate_arguments.repository
):
return
logger.info('{}: Creating repository'.format(repository)) logger.info('{}: Creating repository'.format(repository))
borgmatic.borg.rcreate.create_repository( borgmatic.borg.rcreate.create_repository(
global_arguments.dry_run, global_arguments.dry_run,

View file

@ -2,7 +2,7 @@ import logging
import borgmatic.logger import borgmatic.logger
from borgmatic.borg import environment, flags from borgmatic.borg import environment, flags
from borgmatic.execute import execute_command from borgmatic.execute import DO_NOT_CAPTURE, execute_command
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -28,6 +28,7 @@ def transfer_archives(
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ()) + (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
+ flags.make_flags('remote-path', remote_path) + flags.make_flags('remote-path', remote_path)
+ flags.make_flags('lock-wait', storage_config.get('lock_wait', None)) + flags.make_flags('lock-wait', storage_config.get('lock_wait', None))
+ (('--progress',) if transfer_arguments.progress else ())
+ ( + (
flags.make_flags( flags.make_flags(
'match-archives', transfer_arguments.match_archives or transfer_arguments.archive 'match-archives', transfer_arguments.match_archives or transfer_arguments.archive
@ -45,6 +46,7 @@ def transfer_archives(
return execute_command( return execute_command(
full_command, full_command,
output_log_level=logging.ANSWER, output_log_level=logging.ANSWER,
output_file=DO_NOT_CAPTURE if transfer_arguments.progress else None,
borg_local_path=local_path, borg_local_path=local_path,
extra_environment=environment.make_environment(storage_config), extra_environment=environment.make_environment(storage_config),
) )

View file

@ -247,6 +247,10 @@ def make_parsers():
metavar='KEY_REPOSITORY', metavar='KEY_REPOSITORY',
help='Path to an existing Borg repository whose key material should be reused (Borg 2.x+ only)', help='Path to an existing Borg repository whose key material should be reused (Borg 2.x+ only)',
) )
rcreate_group.add_argument(
'--repository',
help='Path of the new repository to create (must be already specified in a borgmatic configuration file), defaults to the configured repository if there is only one',
)
rcreate_group.add_argument( rcreate_group.add_argument(
'--copy-crypt-key', '--copy-crypt-key',
action='store_true', action='store_true',
@ -292,6 +296,12 @@ def make_parsers():
'--upgrader', '--upgrader',
help='Upgrader type used to convert the transfered data, e.g. "From12To20" to upgrade data from Borg 1.2 to 2.0 format, defaults to no conversion', help='Upgrader type used to convert the transfered data, e.g. "From12To20" to upgrade data from Borg 1.2 to 2.0 format, defaults to no conversion',
) )
transfer_group.add_argument(
'--progress',
default=False,
action='store_true',
help='Display progress as each archive is transferred',
)
transfer_group.add_argument( transfer_group.add_argument(
'-a', '-a',
'--match-archives', '--match-archives',

View file

@ -169,12 +169,21 @@ The `--source-repository` flag is necessary to reuse key material from your
Borg 1 repository so that the subsequent data transfer can work. Borg 1 repository so that the subsequent data transfer can work.
The `--encryption` value above selects the same chunk ID algorithm (`blake2`) The `--encryption` value above selects the same chunk ID algorithm (`blake2`)
used in Borg 1, thereby making deduplication work across transferred archives commonly used in Borg 1, thereby making deduplication work across transferred
and new archives. Note that `repokey-blake2-chacha20-poly1305` may be faster archives and new archives.
than `repokey-blake2-aes-ocb` on certain platforms like ARM64. Read about
[Borg encryption If you get an error about "You must keep the same ID hash" from Borg, that
means the encryption value you specified doesn't correspond to your source
repository's chunk ID algorithm. In that case, try not using `blake2`:
```bash
borgmatic rcreate --verbosity 1 --encryption repokey-aes-ocb \
--source-repository original.borg --repository upgraded.borg
```
Read about [Borg encryption
modes](https://borgbackup.readthedocs.io/en/2.0.0b5/usage/rcreate.html#encryption-mode-tldr) modes](https://borgbackup.readthedocs.io/en/2.0.0b5/usage/rcreate.html#encryption-mode-tldr)
for the menu of available encryption modes. for more details.
To transfer data from your original Borg 1 repository to your newly created To transfer data from your original Borg 1 repository to your newly created
Borg 2 repository: Borg 2 repository: