mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-11 02:27:57 +00:00
cli: rename r* commands to repo-*
also: - adapt tests - adapt BuildMan manpage generation - adapt help strings / doc strings - docs
This commit is contained in:
parent
a7bfd4aec8
commit
04dfadbbd6
56 changed files with 387 additions and 376 deletions
|
@ -122,9 +122,9 @@ For ease of use, set the BORG_REPO environment variable::
|
|||
|
||||
$ export BORG_REPO=/path/to/repo
|
||||
|
||||
Create a new backup repository (see ``borg rcreate --help`` for encryption options)::
|
||||
Create a new backup repository (see ``borg repo-create --help`` for encryption options)::
|
||||
|
||||
$ borg rcreate -e repokey-aes-ocb
|
||||
$ borg repo-create -e repokey-aes-ocb
|
||||
|
||||
Create a new backup archive::
|
||||
|
||||
|
|
10
docs/faq.rst
10
docs/faq.rst
|
@ -41,8 +41,8 @@ Can I copy or synchronize my repo to another location?
|
|||
If you want to have redundant backup repositories (preferably at separate
|
||||
locations), the recommended way to do that is like this:
|
||||
|
||||
- ``borg rcreate repo1 --encryption=X``
|
||||
- ``borg rcreate repo2 --encryption=X --other-repo=repo1``
|
||||
- ``borg repo-create repo1 --encryption=X``
|
||||
- ``borg repo-create repo2 --encryption=X --other-repo=repo1``
|
||||
- maybe do a snapshot to have stable and same input data for both borg create.
|
||||
- client machine ---borg create---> repo1
|
||||
- client machine ---borg create---> repo2
|
||||
|
@ -86,7 +86,7 @@ you could delete the manifest-timestamp and the local cache:
|
|||
|
||||
borg config id # shows the REPO_ID
|
||||
rm ~/.config/borg/security/REPO_ID/manifest-timestamp
|
||||
borg rdelete --cache-only
|
||||
borg repo-delete --cache-only
|
||||
|
||||
This is an unsafe and unsupported way to use borg, you have been warned.
|
||||
|
||||
|
@ -355,7 +355,7 @@ are calculated *before* compression. New compression settings
|
|||
will only be applied to new chunks, not existing chunks. So it's safe
|
||||
to change them.
|
||||
|
||||
Use ``borg rcompress`` to efficiently recompress a complete repository.
|
||||
Use ``borg repo-compress`` to efficiently recompress a complete repository.
|
||||
|
||||
Security
|
||||
########
|
||||
|
@ -445,7 +445,7 @@ Using ``BORG_PASSCOMMAND`` with a file of proper permissions
|
|||
Using keyfile-based encryption with a blank passphrase
|
||||
It is possible to encrypt your repository in ``keyfile`` mode instead of the default
|
||||
``repokey`` mode and use a blank passphrase for the key file (simply press Enter twice
|
||||
when ``borg rcreate`` asks for the password). See :ref:`encrypted_repos`
|
||||
when ``borg repo-create`` asks for the password). See :ref:`encrypted_repos`
|
||||
for more details.
|
||||
|
||||
Using ``BORG_PASSCOMMAND`` with macOS Keychain
|
||||
|
|
|
@ -43,7 +43,7 @@ in your backup log files (you check them regularly anyway, right?).
|
|||
|
||||
Also helpful:
|
||||
|
||||
- use `borg rspace` to reserve some disk space that can be freed when the fs
|
||||
- use `borg repo-space` to reserve some disk space that can be freed when the fs
|
||||
does not have free space any more.
|
||||
- if you use LVM: use a LV + a filesystem that you can resize later and have
|
||||
some unallocated PEs you can add to the LV.
|
||||
|
@ -332,7 +332,7 @@ Repository encryption
|
|||
|
||||
You can choose the repository encryption mode at repository creation time::
|
||||
|
||||
$ borg rcreate --encryption=MODE
|
||||
$ borg repo-create --encryption=MODE
|
||||
|
||||
For a list of available encryption MODEs and their descriptions, please refer
|
||||
to :ref:`borg_rcreate`.
|
||||
|
@ -380,7 +380,7 @@ Borg can initialize and access repositories on remote hosts if the
|
|||
host is accessible using SSH. This is fastest and easiest when Borg
|
||||
is installed on the remote host, in which case the following syntax is used::
|
||||
|
||||
$ borg -r ssh://user@hostname:port/path/to/repo rcreate ...
|
||||
$ borg -r ssh://user@hostname:port/path/to/repo repo-create ...
|
||||
|
||||
Note: please see the usage chapter for a full documentation of repo URLs.
|
||||
|
||||
|
@ -396,7 +396,7 @@ it is still possible to use the remote host to store a repository by
|
|||
mounting the remote filesystem, for example, using sshfs::
|
||||
|
||||
$ sshfs user@hostname:/path/to /path/to
|
||||
$ borg -r /path/to/repo rcreate ...
|
||||
$ borg -r /path/to/repo repo-create ...
|
||||
$ fusermount -u /path/to
|
||||
|
||||
You can also use other remote filesystems in a similar way. Just be careful,
|
||||
|
@ -502,7 +502,7 @@ Example with **borg mount**:
|
|||
# open a new, separate terminal (this terminal will be blocked until umount)
|
||||
|
||||
# now we find out the archive names we have in the repo:
|
||||
borg rlist
|
||||
borg repo-list
|
||||
|
||||
# mount one archive from a borg repo:
|
||||
borg mount -a myserver-system-2019-08-11 /mnt/borg
|
||||
|
@ -528,7 +528,7 @@ Example with **borg extract**:
|
|||
cd borg_restore
|
||||
|
||||
# now we find out the archive names we have in the repo:
|
||||
borg rlist
|
||||
borg repo-list
|
||||
|
||||
# we could find out the archive contents, esp. the path layout:
|
||||
borg list myserver-system-2019-08-11
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
1. Before a backup can be made, a repository has to be initialized::
|
||||
|
||||
$ borg -r /path/to/repo rcreate --encryption=repokey-aes-ocb
|
||||
$ borg -r /path/to/repo repo-create --encryption=repokey-aes-ocb
|
||||
|
||||
2. Back up the ``~/src`` and ``~/Documents`` directories into an archive called
|
||||
*Monday*::
|
||||
|
@ -29,7 +29,7 @@
|
|||
|
||||
4. List all archives in the repository::
|
||||
|
||||
$ borg -r /path/to/repo rlist
|
||||
$ borg -r /path/to/repo repo-list
|
||||
Monday Sat, 2022-06-25 20:21:14 [b80e24d2...b179f298]
|
||||
Tuesday Sat, 2022-06-25 20:21:43 [bcd1b53f...1877718d]
|
||||
|
||||
|
|
|
@ -138,9 +138,9 @@ General:
|
|||
|
||||
Output formatting:
|
||||
BORG_LIST_FORMAT
|
||||
Giving the default value for ``borg list --format=X``.
|
||||
Giving the default value for ``borg repo-list --format=X``.
|
||||
BORG_RLIST_FORMAT
|
||||
Giving the default value for ``borg rlist --format=X``.
|
||||
Giving the default value for ``borg repo-list --format=X``.
|
||||
BORG_PRUNE_FORMAT
|
||||
Giving the default value for ``borg prune --format=X``.
|
||||
|
||||
|
@ -200,7 +200,7 @@ Directories and files:
|
|||
- using a full, absolute path to the key file is recommended.
|
||||
- all directories in the given path must exist.
|
||||
- this setting forces borg to use the key file at the given location.
|
||||
- the key file must either exist (for most commands) or will be created (``borg rcreate``).
|
||||
- the key file must either exist (for most commands) or will be created (``borg repo-create``).
|
||||
- you need to give a different path for different repositories.
|
||||
- you need to point to the correct key file matching the repository the command will operate on.
|
||||
TMPDIR
|
||||
|
|
|
@ -9,7 +9,7 @@ Examples
|
|||
::
|
||||
|
||||
# Create a key file protected repository
|
||||
$ borg rcreate --encryption=keyfile-aes-ocb -v
|
||||
$ borg repo-create --encryption=keyfile-aes-ocb -v
|
||||
Initializing repository at "/path/to/repo"
|
||||
Enter new passphrase:
|
||||
Enter same passphrase again:
|
||||
|
@ -37,7 +37,7 @@ Fully automated using environment variables:
|
|||
|
||||
::
|
||||
|
||||
$ BORG_NEW_PASSPHRASE=old borg rcreate --encryption=repokey-aes-ocb
|
||||
$ BORG_NEW_PASSPHRASE=old borg repo-create --encryption=repokey-aes-ocb
|
||||
# now "old" is the current passphrase.
|
||||
$ BORG_PASSPHRASE=old BORG_NEW_PASSPHRASE=new borg key change-passphrase
|
||||
# now "new" is the current passphrase.
|
||||
|
|
|
@ -234,8 +234,8 @@ in ``.ssh/authorized_keys``:
|
|||
command="borg serve --append-only ..." ssh-rsa <key used for not-always-trustable backup clients>
|
||||
command="borg serve ..." ssh-rsa <key used for backup management>
|
||||
|
||||
Running ``borg rcreate`` via a ``borg serve --append-only`` server will *not* create
|
||||
an append-only repository. Running ``borg rcreate --append-only`` creates an append-only
|
||||
Running ``borg repo-create`` via a ``borg serve --append-only`` server will *not* create
|
||||
an append-only repository. Running ``borg repo-create --append-only`` creates an append-only
|
||||
repository regardless of server settings.
|
||||
|
||||
Example
|
||||
|
@ -280,7 +280,7 @@ than what you actually have in the repository now, after the rollback.
|
|||
|
||||
Thus, you need to clear the cache::
|
||||
|
||||
borg rdelete --cache-only
|
||||
borg repo-delete --cache-only
|
||||
|
||||
The cache will get rebuilt automatically. Depending on repo size and archive
|
||||
count, it may take a while.
|
||||
|
|
|
@ -6,7 +6,7 @@ Examples
|
|||
::
|
||||
|
||||
# recompress repo contents
|
||||
$ borg rcompress --progress --compression=zstd,3
|
||||
$ borg repo-compress --progress --compression=zstd,3
|
||||
|
||||
# recompress and obfuscate repo contents
|
||||
$ borg rcompress --progress --compression=obfuscate,1,zstd,3
|
||||
$ borg repo-compress --progress --compression=obfuscate,1,zstd,3
|
||||
|
|
|
@ -9,19 +9,19 @@ Examples
|
|||
# Local repository
|
||||
$ export BORG_REPO=/path/to/repo
|
||||
# recommended repokey AEAD crypto modes
|
||||
$ borg rcreate --encryption=repokey-aes-ocb
|
||||
$ borg rcreate --encryption=repokey-chacha20-poly1305
|
||||
$ borg rcreate --encryption=repokey-blake2-aes-ocb
|
||||
$ borg rcreate --encryption=repokey-blake2-chacha20-poly1305
|
||||
$ borg repo-create --encryption=repokey-aes-ocb
|
||||
$ borg repo-create --encryption=repokey-chacha20-poly1305
|
||||
$ borg repo-create --encryption=repokey-blake2-aes-ocb
|
||||
$ borg repo-create --encryption=repokey-blake2-chacha20-poly1305
|
||||
# no encryption, not recommended
|
||||
$ borg rcreate --encryption=authenticated
|
||||
$ borg rcreate --encryption=authenticated-blake2
|
||||
$ borg rcreate --encryption=none
|
||||
$ borg repo-create --encryption=authenticated
|
||||
$ borg repo-create --encryption=authenticated-blake2
|
||||
$ borg repo-create --encryption=none
|
||||
|
||||
# Remote repository (accesses a remote borg via ssh)
|
||||
$ export BORG_REPO=ssh://user@hostname/~/backup
|
||||
# repokey: stores the (encrypted) key into <REPO_DIR>/config
|
||||
$ borg rcreate --encryption=repokey-aes-ocb
|
||||
$ borg repo-create --encryption=repokey-aes-ocb
|
||||
# keyfile: stores the (encrypted) key into ~/.config/borg/keys/
|
||||
$ borg rcreate --encryption=keyfile-aes-ocb
|
||||
$ borg repo-create --encryption=keyfile-aes-ocb
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ Examples
|
|||
::
|
||||
|
||||
# delete the whole repository and the related local cache:
|
||||
$ borg rdelete
|
||||
$ borg repo-delete
|
||||
You requested to DELETE the repository completely *including* all archives it contains:
|
||||
repo Mon, 2016-02-15 19:26:54
|
||||
root-2016-02-15 Mon, 2016-02-15 19:36:29
|
||||
|
|
|
@ -5,10 +5,10 @@ Examples
|
|||
::
|
||||
|
||||
$ borg create archivename ~
|
||||
$ borg rlist
|
||||
$ borg repo-list
|
||||
archivename Mon, 2016-02-15 19:50:19
|
||||
|
||||
$ borg rename archivename newname
|
||||
$ borg rlist
|
||||
$ borg repo-list
|
||||
newname Mon, 2016-02-15 19:50:19
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ Examples
|
|||
~~~~~~~~
|
||||
::
|
||||
|
||||
$ borg rinfo
|
||||
$ borg repo-info
|
||||
Repository ID: 0e85a7811022326c067acb2a7181d5b526b7d2f61b34470fb8670c440a67f1a9
|
||||
Location: /Users/tw/w/borg/path/to/repo
|
||||
Encrypted: Yes (repokey AES-OCB)
|
||||
|
|
|
@ -4,7 +4,7 @@ Examples
|
|||
~~~~~~~~
|
||||
::
|
||||
|
||||
$ borg rlist
|
||||
$ borg repo-list
|
||||
Monday Mon, 2016-02-15 19:15:11
|
||||
repo Mon, 2016-02-15 19:26:54
|
||||
root-2016-02-15 Mon, 2016-02-15 19:36:29
|
||||
|
|
|
@ -15,7 +15,7 @@ Examples
|
|||
# the AEAD cipher does not matter (everything must be re-encrypted and
|
||||
# re-authenticated anyway), you could also choose repokey-blake2-chacha20-poly1305.
|
||||
# in case your old borg repo did not use blake2, just remove the "-blake2".
|
||||
$ borg --repo ssh://borg2@borgbackup/./tests/b20 rcreate \
|
||||
$ borg --repo ssh://borg2@borgbackup/./tests/b20 repo-create \
|
||||
--other-repo ssh://borg2@borgbackup/./tests/b12 -e repokey-blake2-aes-ocb
|
||||
|
||||
# 2. Check what and how much it would transfer:
|
||||
|
|
|
@ -257,17 +257,25 @@ class BuildMan:
|
|||
"""build man pages"""
|
||||
|
||||
see_also = {
|
||||
"create": ("delete", "prune", "check", "patterns", "placeholders", "compression", "rcreate"),
|
||||
"create": ("delete", "prune", "check", "patterns", "placeholders", "compression", "repo-create"),
|
||||
"recreate": ("patterns", "placeholders", "compression"),
|
||||
"list": ("info", "diff", "prune", "patterns", "rlist"),
|
||||
"info": ("list", "diff", "rinfo"),
|
||||
"rcreate": ("rdelete", "rlist", "check", "benchmark-cpu", "key-import", "key-export", "key-change-passphrase"),
|
||||
"list": ("info", "diff", "prune", "patterns", "repo-list"),
|
||||
"info": ("list", "diff", "repo-info"),
|
||||
"repo-create": (
|
||||
"repo-delete",
|
||||
"repo-list",
|
||||
"check",
|
||||
"benchmark-cpu",
|
||||
"key-import",
|
||||
"key-export",
|
||||
"key-change-passphrase",
|
||||
),
|
||||
"key-import": ("key-export",),
|
||||
"key-export": ("key-import",),
|
||||
"mount": ("umount", "extract"), # Would be cooler if these two were on the same page
|
||||
"umount": ("mount",),
|
||||
"extract": ("mount",),
|
||||
"delete": ("compact", "rdelete"),
|
||||
"delete": ("compact", "repo-delete"),
|
||||
"prune": ("compact",),
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ def build_parser_prune(self, subparsers, common_parser, mid_common_parser):
|
|||
|
||||
You can influence how the ``--list`` output is formatted by using the ``--short``
|
||||
option (less wide output) or by giving a custom format using ``--format`` (see
|
||||
the ``borg rlist`` description for more details about the format string).
|
||||
the ``borg repo-list`` description for more details about the format string).
|
||||
"""
|
||||
)
|
||||
subparser = subparsers.add_parser(
|
||||
|
|
|
@ -103,7 +103,7 @@ def get_csettings(c):
|
|||
return ctype, clevel, olevel
|
||||
|
||||
if not isinstance(repository, (Repository, RemoteRepository)):
|
||||
raise Error("rcompress not supported for legacy repositories.")
|
||||
raise Error("repo-compress not supported for legacy repositories.")
|
||||
|
||||
repo_objs = manifest.repo_objs
|
||||
ctype, clevel, olevel = get_csettings(repo_objs.compressor) # desired compression set by --compression
|
||||
|
@ -115,7 +115,7 @@ def get_csettings(c):
|
|||
chunks_limit = min(1000, max(100, recompress_candidate_count // 1000))
|
||||
|
||||
pi = ProgressIndicatorPercent(
|
||||
total=len(recompress_ids), msg="Recompressing %3.1f%%", step=0.1, msgid="rcompress.process_chunks"
|
||||
total=len(recompress_ids), msg="Recompressing %3.1f%%", step=0.1, msgid="repo_compress.process_chunks"
|
||||
)
|
||||
while recompress_ids:
|
||||
if sig_int and sig_int.action_done():
|
||||
|
@ -173,17 +173,17 @@ def build_parser_repo_compress(self, subparsers, common_parser, mid_common_parse
|
|||
Please note that this command can not work in low (or zero) free disk space
|
||||
conditions.
|
||||
|
||||
If the ``borg rcompress`` process receives a SIGINT signal (Ctrl-C), the repo
|
||||
If the ``borg repo-compress`` process receives a SIGINT signal (Ctrl-C), the repo
|
||||
will be committed and compacted and borg will terminate cleanly afterwards.
|
||||
|
||||
Both ``--progress`` and ``--stats`` are recommended when ``borg rcompress``
|
||||
Both ``--progress`` and ``--stats`` are recommended when ``borg repo-compress``
|
||||
is used interactively.
|
||||
|
||||
You do **not** need to run ``borg compact`` after ``borg rcompress``.
|
||||
You do **not** need to run ``borg compact`` after ``borg repo-compress``.
|
||||
"""
|
||||
)
|
||||
subparser = subparsers.add_parser(
|
||||
"rcompress",
|
||||
"repo-compress",
|
||||
parents=[common_parser],
|
||||
add_help=False,
|
||||
description=self.do_repo_compress.__doc__,
|
||||
|
|
|
@ -58,7 +58,7 @@ def do_repo_create(self, args, repository, *, other_repository=None, other_manif
|
|||
"\n"
|
||||
"Reserve some repository storage space now for emergencies like 'disk full'\n"
|
||||
"by running:\n"
|
||||
" borg rspace --reserve 1G"
|
||||
" borg repo-space --reserve 1G"
|
||||
)
|
||||
|
||||
def build_parser_repo_create(self, subparsers, common_parser, mid_common_parser):
|
||||
|
@ -79,7 +79,7 @@ def build_parser_repo_create(self, subparsers, common_parser, mid_common_parser)
|
|||
|
||||
::
|
||||
|
||||
borg rcreate --encryption repokey-aes-ocb
|
||||
borg repo-create --encryption repokey-aes-ocb
|
||||
|
||||
Borg will:
|
||||
|
||||
|
@ -170,7 +170,7 @@ def build_parser_repo_create(self, subparsers, common_parser, mid_common_parser)
|
|||
Creating a related repository
|
||||
+++++++++++++++++++++++++++++
|
||||
|
||||
You can use ``borg rcreate --other-repo ORIG_REPO ...`` to create a related repository
|
||||
You can use ``borg repo-create --other-repo ORIG_REPO ...`` to create a related repository
|
||||
that uses the same secret key material as the given other/original repository.
|
||||
|
||||
By default, only the ID key and chunker secret will be the same (these are important
|
||||
|
@ -185,14 +185,14 @@ def build_parser_repo_create(self, subparsers, common_parser, mid_common_parser)
|
|||
Creating a related repository for data migration from borg 1.2 or 1.4
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
You can use ``borg rcreate --other-repo ORIG_REPO --from-borg1 ...`` to create a related
|
||||
You can use ``borg repo-create --other-repo ORIG_REPO --from-borg1 ...`` to create a related
|
||||
repository that uses the same secret key material as the given other/original repository.
|
||||
|
||||
Then use ``borg transfer --other-repo ORIG_REPO --from-borg1 ...`` to transfer the archives.
|
||||
"""
|
||||
)
|
||||
subparser = subparsers.add_parser(
|
||||
"rcreate",
|
||||
"repo-create",
|
||||
parents=[common_parser],
|
||||
add_help=False,
|
||||
description=self.do_repo_create.__doc__,
|
||||
|
|
|
@ -103,7 +103,7 @@ def build_parser_repo_delete(self, subparsers, common_parser, mid_common_parser)
|
|||
"""
|
||||
)
|
||||
subparser = subparsers.add_parser(
|
||||
"rdelete",
|
||||
"repo-delete",
|
||||
parents=[common_parser],
|
||||
add_help=False,
|
||||
description=self.do_repo_delete.__doc__,
|
||||
|
|
|
@ -74,7 +74,7 @@ def build_parser_repo_info(self, subparsers, common_parser, mid_common_parser):
|
|||
"""
|
||||
)
|
||||
subparser = subparsers.add_parser(
|
||||
"rinfo",
|
||||
"repo-info",
|
||||
parents=[common_parser],
|
||||
add_help=False,
|
||||
description=self.do_repo_info.__doc__,
|
||||
|
|
|
@ -55,7 +55,7 @@ def build_parser_repo_list(self, subparsers, common_parser, mid_common_parser):
|
|||
Examples:
|
||||
::
|
||||
|
||||
$ borg rlist --format '{archive}{NL}'
|
||||
$ borg repo-list --format '{archive}{NL}'
|
||||
ArchiveFoo
|
||||
ArchiveBar
|
||||
...
|
||||
|
@ -63,7 +63,7 @@ def build_parser_repo_list(self, subparsers, common_parser, mid_common_parser):
|
|||
# {VAR:NUMBER} - pad to NUMBER columns.
|
||||
# Strings are left-aligned, numbers are right-aligned.
|
||||
# Note: time columns except ``isomtime``, ``isoctime`` and ``isoatime`` cannot be padded.
|
||||
$ borg rlist --format '{archive:36} {time} [{id}]{NL}' /path/to/repo
|
||||
$ borg repo-list --format '{archive:36} {time} [{id}]{NL}' /path/to/repo
|
||||
ArchiveFoo Thu, 2021-12-09 10:22:28 [0b8e9...3b274]
|
||||
...
|
||||
|
||||
|
@ -83,7 +83,7 @@ def build_parser_repo_list(self, subparsers, common_parser, mid_common_parser):
|
|||
+ ArchiveFormatter.keys_help()
|
||||
)
|
||||
subparser = subparsers.add_parser(
|
||||
"rlist",
|
||||
"repo-list",
|
||||
parents=[common_parser],
|
||||
add_help=False,
|
||||
description=self.do_repo_list.__doc__,
|
||||
|
|
|
@ -65,26 +65,26 @@ def build_parser_repo_space(self, subparsers, common_parser, mid_common_parser):
|
|||
Examples::
|
||||
|
||||
# Create a new repository:
|
||||
$ borg rcreate ...
|
||||
$ borg repo-create ...
|
||||
# Reserve approx. 1GB of space for emergencies:
|
||||
$ borg rspace --reserve 1G
|
||||
$ borg repo-space --reserve 1G
|
||||
|
||||
# Check amount of reserved space in the repository:
|
||||
$ borg rspace
|
||||
$ borg repo-space
|
||||
|
||||
# EMERGENCY! Free all reserved space to get things back to normal:
|
||||
$ borg rspace --free
|
||||
$ borg repo-space --free
|
||||
$ borg prune ...
|
||||
$ borg delete ...
|
||||
$ borg compact -v # only this actually frees space of deleted archives
|
||||
$ borg rspace --reserve 1G # reserve space again for next time
|
||||
$ borg repo-space --reserve 1G # reserve space again for next time
|
||||
|
||||
|
||||
Reserved space is always rounded up to use full reservation blocks of 64MiB.
|
||||
"""
|
||||
)
|
||||
subparser = subparsers.add_parser(
|
||||
"rspace",
|
||||
"repo-space",
|
||||
parents=[common_parser],
|
||||
add_help=False,
|
||||
description=self.do_repo_space.__doc__,
|
||||
|
|
|
@ -205,7 +205,7 @@ def build_parser_transfer(self, subparsers, common_parser, mid_common_parser):
|
|||
|
||||
# create a related DST_REPO (reusing key material from SRC_REPO), so that
|
||||
# chunking and chunk id generation will work in the same way as before.
|
||||
borg --repo=DST_REPO rcreate --encryption=DST_ENC --other-repo=SRC_REPO
|
||||
borg --repo=DST_REPO repo-create --encryption=DST_ENC --other-repo=SRC_REPO
|
||||
|
||||
# transfer archives from SRC_REPO to DST_REPO
|
||||
borg --repo=DST_REPO transfer --other-repo=SRC_REPO --dry-run # check what it would do
|
||||
|
@ -219,7 +219,7 @@ def build_parser_transfer(self, subparsers, common_parser, mid_common_parser):
|
|||
To migrate your borg 1.x archives into a related, new borg2 repository, usage is quite similar
|
||||
to the above, but you need the ``--from-borg1`` option::
|
||||
|
||||
borg --repo=DST_REPO rcreate --encryption=DST_ENC --other-repo=SRC_REPO --from-borg1
|
||||
borg --repo=DST_REPO repocreate --encryption=DST_ENC --other-repo=SRC_REPO --from-borg1
|
||||
|
||||
# to continue using lz4 compression as you did in SRC_REPO:
|
||||
borg --repo=DST_REPO transfer --other-repo=SRC_REPO --from-borg1 \\
|
||||
|
|
|
@ -587,7 +587,7 @@ class ObfuscateSize(CompressorBase):
|
|||
trailer = bytes(addtl_size)
|
||||
obfuscated_data = compressed_data + trailer
|
||||
meta["csize"] = len(obfuscated_data) # csize is the overall output size of this "obfuscation compressor"
|
||||
meta["olevel"] = self.level # remember the obfuscation level, useful for rcompress
|
||||
meta["olevel"] = self.level # remember the obfuscation level, useful for repo-compress
|
||||
return meta, obfuscated_data # for borg2 it is enough that we have the payload size in meta["psize"]
|
||||
|
||||
def decompress(self, meta, data):
|
||||
|
|
|
@ -276,13 +276,13 @@ def _extract_hardlinks_setup(archiver):
|
|||
create_regular_file(input_path, "dir1/source2")
|
||||
os.link(os.path.join(input_path, "dir1/source2"), os.path.join(input_path, "dir1/aaaa"))
|
||||
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
|
||||
|
||||
def _create_test_caches(archiver):
|
||||
input_path = archiver.input_path
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(input_path, "cache1/%s" % CACHE_TAG_NAME, contents=CACHE_TAG_CONTENTS + b" extra stuff")
|
||||
create_regular_file(input_path, "cache2/%s" % CACHE_TAG_NAME, contents=b"invalid signature")
|
||||
|
@ -302,7 +302,7 @@ def _assert_test_caches(archiver):
|
|||
|
||||
def _create_test_tagged(archiver):
|
||||
input_path = archiver.input_path
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(input_path, "tagged1/.NOBACKUP")
|
||||
create_regular_file(input_path, "tagged2/00-NOBACKUP")
|
||||
|
@ -317,7 +317,7 @@ def _assert_test_tagged(archiver):
|
|||
|
||||
def _create_test_keep_tagged(archiver):
|
||||
input_path = archiver.input_path
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(input_path, "file0", size=1024)
|
||||
create_regular_file(input_path, "tagged1/.NOBACKUP1")
|
||||
create_regular_file(input_path, "tagged1/file1", size=1024)
|
||||
|
|
|
@ -6,24 +6,24 @@
|
|||
|
||||
|
||||
def test_bad_filters(archiver):
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
cmd(archiver, "delete", "--first", "1", "--last", "1", fork=True, exit_code=2)
|
||||
|
||||
|
||||
def test_highlander(archiver):
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "--comment", "comment 1", "test-1", __file__)
|
||||
error_msg = "There can be only one"
|
||||
# Default umask value is 0077
|
||||
# Test that it works with a one time specified default or custom value
|
||||
output_default = cmd(archiver, "--umask", "0077", "rlist")
|
||||
output_default = cmd(archiver, "--umask", "0077", "repo-list")
|
||||
assert error_msg not in output_default
|
||||
output_custom = cmd(archiver, "--umask", "0007", "rlist")
|
||||
output_custom = cmd(archiver, "--umask", "0007", "repo-list")
|
||||
assert error_msg not in output_custom
|
||||
# Test that all combinations of custom and default values fail
|
||||
for first, second in [("0007", "0007"), ("0007", "0077"), ("0077", "0007"), ("0077", "0077")]:
|
||||
output_custom = cmd(archiver, "--umask", first, "--umask", second, "rlist", exit_code=2)
|
||||
output_custom = cmd(archiver, "--umask", first, "--umask", second, "repo-list", exit_code=2)
|
||||
assert error_msg in output_custom
|
||||
|
||||
|
||||
|
@ -64,7 +64,8 @@ def test_get_args():
|
|||
assert args.restrict_to_repositories == ["/r1", "/r2"]
|
||||
# trying to cheat - try to execute different subcommand
|
||||
args = archiver.get_args(
|
||||
["borg", "serve", "--restrict-to-path=/p1", "--restrict-to-path=/p2"], f"borg --repo=/ rcreate {RK_ENCRYPTION}"
|
||||
["borg", "serve", "--restrict-to-path=/p1", "--restrict-to-path=/p2"],
|
||||
f"borg --repo=/ repo-create {RK_ENCRYPTION}",
|
||||
)
|
||||
assert args.func == archiver.do_serve
|
||||
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
|
||||
def test_benchmark_crud(archiver, monkeypatch):
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
monkeypatch.setenv("_BORG_BENCHMARK_CRUD_TEST", "YES")
|
||||
cmd(archiver, "benchmark", "crud", archiver.input_path)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
def check_cmd_setup(archiver):
|
||||
with patch.object(ChunkBuffer, "BUFFER_SIZE", 10):
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_src_archive(archiver, "archive1")
|
||||
create_src_archive(archiver, "archive2")
|
||||
|
||||
|
@ -56,7 +56,7 @@ def test_date_matching(archivers, request):
|
|||
check_cmd_setup(archiver)
|
||||
|
||||
shutil.rmtree(archiver.repository_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
earliest_ts = "2022-11-20T23:59:59"
|
||||
ts_in_between = "2022-12-18T23:59:59"
|
||||
create_src_archive(archiver, "archive1", ts=earliest_ts)
|
||||
|
@ -294,7 +294,7 @@ def test_manifest_rebuild_duplicate_archive(archivers, request):
|
|||
# named archive1.1 will be created because we request undeleting archives and there
|
||||
# is no archives directory entry for the fake archive yet.
|
||||
cmd(archiver, "check", "--repair", "--undelete-archives", exit_code=0)
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
assert "archive1" in output
|
||||
assert "archive1.1" in output
|
||||
assert "archive2" in output
|
||||
|
@ -334,7 +334,7 @@ def test_spoofed_archive(archivers, request):
|
|||
)
|
||||
cmd(archiver, "check", exit_code=1)
|
||||
cmd(archiver, "check", "--repair", "--debug", exit_code=0)
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
assert "archive1" in output
|
||||
assert "archive2" in output
|
||||
assert "archive_spoofed" not in output
|
||||
|
@ -371,7 +371,7 @@ def fake_xxh64(data, seed=0):
|
|||
with patch.object(borg.repoobj, "xxh64", fake_xxh64), patch.object(borg.repository, "xxh64", fake_xxh64):
|
||||
check_cmd_setup(archiver)
|
||||
shutil.rmtree(archiver.repository_path)
|
||||
cmd(archiver, "rcreate", *init_args)
|
||||
cmd(archiver, "repo-create", *init_args)
|
||||
create_src_archive(archiver, "archive1")
|
||||
archive, repository = open_archive(archiver.repository_path, "archive1")
|
||||
with repository:
|
||||
|
@ -405,7 +405,7 @@ def test_corrupted_file_chunk(archivers, request, init_args):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
check_cmd_setup(archiver)
|
||||
shutil.rmtree(archiver.repository_path)
|
||||
cmd(archiver, "rcreate", *init_args)
|
||||
cmd(archiver, "repo-create", *init_args)
|
||||
create_src_archive(archiver, "archive1")
|
||||
archive, repository = open_archive(archiver.repository_path, "archive1")
|
||||
with repository:
|
||||
|
|
|
@ -44,11 +44,11 @@ def test_repository_swap_detection(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
os.environ["BORG_PASSPHRASE"] = "passphrase"
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
repository_id = _extract_repository_id(archiver.repository_path)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
shutil.rmtree(archiver.repository_path)
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
_set_repository_id(archiver.repository_path, repository_id)
|
||||
assert repository_id == _extract_repository_id(archiver.repository_path)
|
||||
if archiver.FORK_DEFAULT:
|
||||
|
@ -63,10 +63,10 @@ def test_repository_swap_detection2(archivers, request):
|
|||
create_test_files(archiver.input_path)
|
||||
original_location = archiver.repository_location
|
||||
archiver.repository_location = original_location + "_unencrypted"
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
os.environ["BORG_PASSPHRASE"] = "passphrase"
|
||||
archiver.repository_location = original_location + "_encrypted"
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
shutil.rmtree(archiver.repository_path + "_encrypted")
|
||||
os.replace(archiver.repository_path + "_unencrypted", archiver.repository_path + "_encrypted")
|
||||
|
@ -81,14 +81,14 @@ def test_repository_swap_detection_no_cache(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
os.environ["BORG_PASSPHRASE"] = "passphrase"
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
repository_id = _extract_repository_id(archiver.repository_path)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
shutil.rmtree(archiver.repository_path)
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
_set_repository_id(archiver.repository_path, repository_id)
|
||||
assert repository_id == _extract_repository_id(archiver.repository_path)
|
||||
cmd(archiver, "rdelete", "--cache-only")
|
||||
cmd(archiver, "repo-delete", "--cache-only")
|
||||
if archiver.FORK_DEFAULT:
|
||||
cmd(archiver, "create", "test.2", "input", exit_code=EXIT_ERROR)
|
||||
else:
|
||||
|
@ -101,15 +101,15 @@ def test_repository_swap_detection2_no_cache(archivers, request):
|
|||
original_location = archiver.repository_location
|
||||
create_test_files(archiver.input_path)
|
||||
archiver.repository_location = original_location + "_unencrypted"
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
os.environ["BORG_PASSPHRASE"] = "passphrase"
|
||||
archiver.repository_location = original_location + "_encrypted"
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
archiver.repository_location = original_location + "_unencrypted"
|
||||
cmd(archiver, "rdelete", "--cache-only")
|
||||
cmd(archiver, "repo-delete", "--cache-only")
|
||||
archiver.repository_location = original_location + "_encrypted"
|
||||
cmd(archiver, "rdelete", "--cache-only")
|
||||
cmd(archiver, "repo-delete", "--cache-only")
|
||||
shutil.rmtree(archiver.repository_path + "_encrypted")
|
||||
os.replace(archiver.repository_path + "_unencrypted", archiver.repository_path + "_encrypted")
|
||||
if archiver.FORK_DEFAULT:
|
||||
|
@ -124,15 +124,15 @@ def test_repository_swap_detection_repokey_blank_passphrase(archivers, request,
|
|||
# Check that a repokey repo with a blank passphrase is considered like a plaintext repo.
|
||||
create_test_files(archiver.input_path)
|
||||
# User initializes her repository with her passphrase
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
# Attacker replaces it with her own repository, which is encrypted but has no passphrase set
|
||||
shutil.rmtree(archiver.repository_path)
|
||||
|
||||
monkeypatch.setenv("BORG_PASSPHRASE", "")
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# Delete cache & security database, AKA switch to user perspective
|
||||
cmd(archiver, "rdelete", "--cache-only")
|
||||
cmd(archiver, "repo-delete", "--cache-only")
|
||||
shutil.rmtree(get_security_directory(archiver.repository_path))
|
||||
|
||||
monkeypatch.delenv("BORG_PASSPHRASE")
|
||||
|
@ -148,28 +148,28 @@ def test_repository_swap_detection_repokey_blank_passphrase(archivers, request,
|
|||
|
||||
def test_repository_move(archivers, request, monkeypatch):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
security_dir = get_security_directory(archiver.repository_path)
|
||||
os.replace(archiver.repository_path, archiver.repository_path + "_new")
|
||||
archiver.repository_location += "_new"
|
||||
# borg should notice that the repository location changed and abort.
|
||||
if archiver.FORK_DEFAULT:
|
||||
cmd(archiver, "rinfo", exit_code=EXIT_ERROR)
|
||||
cmd(archiver, "repo-info", exit_code=EXIT_ERROR)
|
||||
else:
|
||||
with pytest.raises(Cache.RepositoryAccessAborted):
|
||||
cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-info")
|
||||
# if we explicitly allow relocated repos, it should work fine.
|
||||
monkeypatch.setenv("BORG_RELOCATED_REPO_ACCESS_IS_OK", "yes")
|
||||
cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-info")
|
||||
monkeypatch.delenv("BORG_RELOCATED_REPO_ACCESS_IS_OK")
|
||||
with open(os.path.join(security_dir, "location")) as fd:
|
||||
location = fd.read()
|
||||
assert location == Location(archiver.repository_location).canonical_path()
|
||||
# after new repo location was confirmed once, it needs no further confirmation anymore.
|
||||
cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-info")
|
||||
shutil.rmtree(security_dir)
|
||||
# it also needs no confirmation if we have no knowledge about the previous location.
|
||||
cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-info")
|
||||
# it will re-create security-related infos in the security dir:
|
||||
for file in ("location", "key-type", "manifest-timestamp"):
|
||||
assert os.path.exists(os.path.join(security_dir, file))
|
||||
|
@ -177,53 +177,53 @@ def test_repository_move(archivers, request, monkeypatch):
|
|||
|
||||
def test_unknown_unencrypted(archivers, request, monkeypatch):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
# Ok: repository is known
|
||||
cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-info")
|
||||
|
||||
# Ok: repository is still known (through security_dir)
|
||||
shutil.rmtree(archiver.cache_path)
|
||||
cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-info")
|
||||
|
||||
# Needs confirmation: cache and security dir both gone (e.g. another host or rm -rf ~)
|
||||
shutil.rmtree(get_security_directory(archiver.repository_path))
|
||||
if archiver.FORK_DEFAULT:
|
||||
cmd(archiver, "rinfo", exit_code=EXIT_ERROR)
|
||||
cmd(archiver, "repo-info", exit_code=EXIT_ERROR)
|
||||
else:
|
||||
with pytest.raises(Cache.CacheInitAbortedError):
|
||||
cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-info")
|
||||
monkeypatch.setenv("BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK", "yes")
|
||||
cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-info")
|
||||
|
||||
|
||||
def test_unknown_feature_on_create(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
print(cmd(archiver, "rcreate", RK_ENCRYPTION))
|
||||
print(cmd(archiver, "repo-create", RK_ENCRYPTION))
|
||||
add_unknown_feature(archiver.repository_path, Manifest.Operation.WRITE)
|
||||
cmd_raises_unknown_feature(archiver, ["create", "test", "input"])
|
||||
|
||||
|
||||
def test_unknown_feature_on_change_passphrase(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
print(cmd(archiver, "rcreate", RK_ENCRYPTION))
|
||||
print(cmd(archiver, "repo-create", RK_ENCRYPTION))
|
||||
add_unknown_feature(archiver.repository_path, Manifest.Operation.CHECK)
|
||||
cmd_raises_unknown_feature(archiver, ["key", "change-passphrase"])
|
||||
|
||||
|
||||
def test_unknown_feature_on_read(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
print(cmd(archiver, "rcreate", RK_ENCRYPTION))
|
||||
print(cmd(archiver, "repo-create", RK_ENCRYPTION))
|
||||
cmd(archiver, "create", "test", "input")
|
||||
add_unknown_feature(archiver.repository_path, Manifest.Operation.READ)
|
||||
with changedir("output"):
|
||||
cmd_raises_unknown_feature(archiver, ["extract", "test"])
|
||||
cmd_raises_unknown_feature(archiver, ["rlist"])
|
||||
cmd_raises_unknown_feature(archiver, ["repo-list"])
|
||||
cmd_raises_unknown_feature(archiver, ["info", "-a", "test"])
|
||||
|
||||
|
||||
def test_unknown_feature_on_rename(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
print(cmd(archiver, "rcreate", RK_ENCRYPTION))
|
||||
print(cmd(archiver, "repo-create", RK_ENCRYPTION))
|
||||
cmd(archiver, "create", "test", "input")
|
||||
add_unknown_feature(archiver.repository_path, Manifest.Operation.CHECK)
|
||||
cmd_raises_unknown_feature(archiver, ["rename", "test", "other"])
|
||||
|
@ -231,20 +231,20 @@ def test_unknown_feature_on_rename(archivers, request):
|
|||
|
||||
def test_unknown_feature_on_delete(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
print(cmd(archiver, "rcreate", RK_ENCRYPTION))
|
||||
print(cmd(archiver, "repo-create", RK_ENCRYPTION))
|
||||
cmd(archiver, "create", "test", "input")
|
||||
add_unknown_feature(archiver.repository_path, Manifest.Operation.DELETE)
|
||||
# delete of an archive raises
|
||||
cmd_raises_unknown_feature(archiver, ["delete", "-a", "test"])
|
||||
cmd_raises_unknown_feature(archiver, ["prune", "--keep-daily=3"])
|
||||
# delete of the whole repository ignores features
|
||||
cmd(archiver, "rdelete")
|
||||
cmd(archiver, "repo-delete")
|
||||
|
||||
|
||||
@pytest.mark.skipif(not llfuse, reason="llfuse not installed")
|
||||
def test_unknown_feature_on_mount(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
add_unknown_feature(archiver.repository_path, Manifest.Operation.READ)
|
||||
mountpoint = os.path.join(archiver.tmpdir, "mountpoint")
|
||||
|
@ -257,7 +257,7 @@ def test_unknown_feature_on_mount(archivers, request):
|
|||
def test_unknown_mandatory_feature_in_cache(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
remote_repo = archiver.get_kind() == "remote"
|
||||
print(cmd(archiver, "rcreate", RK_ENCRYPTION))
|
||||
print(cmd(archiver, "repo-create", RK_ENCRYPTION))
|
||||
|
||||
with Repository(archiver.repository_path, exclusive=True) as repository:
|
||||
if remote_repo:
|
||||
|
@ -282,43 +282,43 @@ def test_remote_repo_restrict_to_path(remote_archiver):
|
|||
original_location, repo_path = remote_archiver.repository_location, remote_archiver.repository_path
|
||||
# restricted to repo directory itself:
|
||||
with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-path", repo_path]):
|
||||
cmd(remote_archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
|
||||
# restricted to repo directory itself, fail for other directories with same prefix:
|
||||
with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-path", repo_path]):
|
||||
with pytest.raises(PathNotAllowed):
|
||||
remote_archiver.repository_location = original_location + "_0"
|
||||
cmd(remote_archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
|
||||
# restricted to a completely different path:
|
||||
with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-path", "/foo"]):
|
||||
with pytest.raises(PathNotAllowed):
|
||||
remote_archiver.repository_location = original_location + "_1"
|
||||
cmd(remote_archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
|
||||
path_prefix = os.path.dirname(repo_path)
|
||||
# restrict to repo directory's parent directory:
|
||||
with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-path", path_prefix]):
|
||||
remote_archiver.repository_location = original_location + "_2"
|
||||
cmd(remote_archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
|
||||
# restrict to repo directory's parent directory and another directory:
|
||||
with patch.object(
|
||||
RemoteRepository, "extra_test_args", ["--restrict-to-path", "/foo", "--restrict-to-path", path_prefix]
|
||||
):
|
||||
remote_archiver.repository_location = original_location + "_3"
|
||||
cmd(remote_archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
|
||||
|
||||
|
||||
def test_remote_repo_restrict_to_repository(remote_archiver):
|
||||
repo_path = remote_archiver.repository_path
|
||||
# restricted to repo directory itself:
|
||||
with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-repository", repo_path]):
|
||||
cmd(remote_archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
|
||||
parent_path = os.path.join(repo_path, "..")
|
||||
with patch.object(RemoteRepository, "extra_test_args", ["--restrict-to-repository", parent_path]):
|
||||
with pytest.raises(PathNotAllowed):
|
||||
cmd(remote_archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
|
||||
|
||||
|
||||
def test_remote_repo_strip_components_doesnt_leak(remote_archiver):
|
||||
cmd(remote_archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(remote_archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(remote_archiver.input_path, "dir/file", contents=b"test file contents 1")
|
||||
create_regular_file(remote_archiver.input_path, "dir/file2", contents=b"test file contents 2")
|
||||
create_regular_file(remote_archiver.input_path, "skipped-file1", contents=b"test file contents 3")
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
def test_compact_empty_repository(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
|
||||
output = cmd(archiver, "compact", "-v", exit_code=0)
|
||||
assert "Starting compaction" in output
|
||||
|
@ -18,7 +18,7 @@ def test_compact_empty_repository(archivers, request):
|
|||
def test_compact_after_deleting_all_archives(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_src_archive(archiver, "archive")
|
||||
cmd(archiver, "delete", "-a", "archive", exit_code=0)
|
||||
|
||||
|
@ -32,7 +32,7 @@ def test_compact_after_deleting_all_archives(archivers, request):
|
|||
def test_compact_after_deleting_some_archives(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_src_archive(archiver, "archive1")
|
||||
create_src_archive(archiver, "archive2")
|
||||
cmd(archiver, "delete", "-a", "archive1", exit_code=0)
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
def corrupt_archiver(archiver):
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
archiver.cache_path = json.loads(cmd(archiver, "rinfo", "--json"))["cache"].get("path")
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
archiver.cache_path = json.loads(cmd(archiver, "repo-info", "--json"))["cache"].get("path")
|
||||
|
||||
|
||||
def corrupt(file, amount=1):
|
||||
|
@ -49,5 +49,5 @@ def test_old_version_interfered(archiver):
|
|||
config.set("cache", "manifest", bin_to_hex(bytes(32)))
|
||||
with open(config_path, "w") as fd:
|
||||
config.write(fd)
|
||||
out = cmd(archiver, "rinfo")
|
||||
out = cmd(archiver, "repo-info")
|
||||
assert "Cache integrity data not available: old Borg version modified the cache." in out
|
||||
|
|
|
@ -54,7 +54,7 @@ def test_basic_functionality(archivers, request):
|
|||
pytest.skip("test_basic_functionality seems incompatible with fakeroot and/or the binary.")
|
||||
have_root = create_test_files(archiver.input_path)
|
||||
# fork required to test show-rc output
|
||||
output = cmd(archiver, "rcreate", RK_ENCRYPTION, "--show-version", "--show-rc", fork=True)
|
||||
output = cmd(archiver, "repo-create", RK_ENCRYPTION, "--show-version", "--show-rc", fork=True)
|
||||
assert "borgbackup version" in output
|
||||
assert "terminating with success status, rc 0" in output
|
||||
|
||||
|
@ -65,7 +65,7 @@ def test_basic_functionality(archivers, request):
|
|||
with changedir("output"):
|
||||
cmd(archiver, "extract", "test")
|
||||
|
||||
list_output = cmd(archiver, "rlist", "--short")
|
||||
list_output = cmd(archiver, "repo-list", "--short")
|
||||
assert "test" in list_output
|
||||
assert "test.2" in list_output
|
||||
|
||||
|
@ -133,7 +133,7 @@ def test_archived_paths(archivers, request):
|
|||
# no leading slash in borg archives:
|
||||
archived_path = posix_path.lstrip("/")
|
||||
create_regular_file(archiver.input_path, "test")
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
cmd(archiver, "create", "test", "input", posix_path)
|
||||
# "input" directory is recursed into, "input/test" is discovered and joined by borg's recursion.
|
||||
# posix_path was directly given as a cli argument and should end up as archive_path in the borg archive.
|
||||
|
@ -160,7 +160,7 @@ def test_create_duplicate_root(archivers, request):
|
|||
hl_b = os.path.join(path_b, "hardlink")
|
||||
create_regular_file(archiver.input_path, hl_a, contents=b"123456")
|
||||
os.link(hl_a, hl_b)
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
cmd(archiver, "create", "test", "input", "input") # give input twice!
|
||||
# test if created archive has 'input' contents twice:
|
||||
archive_list = cmd(archiver, "list", "test", "--json-lines")
|
||||
|
@ -176,7 +176,7 @@ def test_create_unreadable_parent(archiver):
|
|||
os.mkdir(root_dir)
|
||||
os.chmod(parent_dir, 0o111) # --x--x--x == parent dir traversable, but not readable
|
||||
try:
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
# issue #7746: we *can* read root_dir and we *can* traverse parent_dir, so this should work:
|
||||
cmd(archiver, "create", "test", root_dir)
|
||||
finally:
|
||||
|
@ -186,7 +186,7 @@ def test_create_unreadable_parent(archiver):
|
|||
@pytest.mark.skipif(is_win32, reason="unix sockets not available on windows")
|
||||
def test_unix_socket(archivers, request, monkeypatch):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
try:
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
|
@ -212,7 +212,7 @@ def test_nobirthtime(archivers, request):
|
|||
birthtime, mtime, atime = 946598400, 946684800, 946771200
|
||||
os.utime("input/file1", (atime, birthtime))
|
||||
os.utime("input/file1", (atime, mtime))
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input", "--nobirthtime")
|
||||
with changedir("output"):
|
||||
cmd(archiver, "extract", "test")
|
||||
|
@ -226,7 +226,7 @@ def test_nobirthtime(archivers, request):
|
|||
|
||||
def test_create_stdin(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
input_data = b"\x00foo\n\nbar\n \n"
|
||||
cmd(archiver, "create", "test", "-", input=input_data)
|
||||
item = json.loads(cmd(archiver, "list", "test", "--json-lines"))
|
||||
|