mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-21 15:23:11 +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"))
|
||||
|
@ -242,7 +242,7 @@ def test_create_erroneous_file(archivers, request):
|
|||
create_regular_file(archiver.input_path, os.path.join(archiver.input_path, "file1"), size=chunk_size * 2)
|
||||
create_regular_file(archiver.input_path, os.path.join(archiver.input_path, "file2"), size=chunk_size * 2)
|
||||
create_regular_file(archiver.input_path, os.path.join(archiver.input_path, "file3"), size=chunk_size * 2)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
flist = "".join(f"input/file{n}\n" for n in range(1, 4))
|
||||
out = cmd(
|
||||
archiver,
|
||||
|
@ -278,7 +278,7 @@ def test_create_no_permission_file(archivers, request):
|
|||
else:
|
||||
# note: this will NOT take away read permissions for root
|
||||
os.chmod(file_path + "2", 0o000)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
flist = "".join(f"input/file{n}\n" for n in range(1, 4))
|
||||
expected_ec = BackupPermissionError("open", OSError(13, "permission denied")).exit_code
|
||||
if expected_ec == EXIT_ERROR: # workaround, TODO: fix it
|
||||
|
@ -305,7 +305,7 @@ def test_create_no_permission_file(archivers, request):
|
|||
|
||||
def test_sanitized_stdin_name(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "--stdin-name", "./a//path", "test", "-", input=b"")
|
||||
item = json.loads(cmd(archiver, "list", "test", "--json-lines"))
|
||||
assert item["path"] == "a/path"
|
||||
|
@ -313,21 +313,21 @@ def test_sanitized_stdin_name(archivers, request):
|
|||
|
||||
def test_dotdot_stdin_name(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
output = cmd(archiver, "create", "--stdin-name", "foo/../bar", "test", "-", input=b"", exit_code=2)
|
||||
assert output.endswith("'..' element in path 'foo/../bar'" + os.linesep)
|
||||
|
||||
|
||||
def test_dot_stdin_name(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
output = cmd(archiver, "create", "--stdin-name", "./", "test", "-", input=b"", exit_code=2)
|
||||
assert output.endswith("'./' is not a valid file name" + os.linesep)
|
||||
|
||||
|
||||
def test_create_content_from_command(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
input_data = "some test content"
|
||||
name = "a/b/c"
|
||||
cmd(archiver, "create", "--stdin-name", name, "--content-from-command", "test", "--", "echo", input_data)
|
||||
|
@ -340,7 +340,7 @@ def test_create_content_from_command(archivers, request):
|
|||
|
||||
def test_create_content_from_command_with_failed_command(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
if archiver.FORK_DEFAULT:
|
||||
expected_ec = CommandError().exit_code
|
||||
output = cmd(
|
||||
|
@ -350,20 +350,20 @@ def test_create_content_from_command_with_failed_command(archivers, request):
|
|||
else:
|
||||
with pytest.raises(CommandError):
|
||||
cmd(archiver, "create", "--content-from-command", "test", "--", "sh", "-c", "exit 73;")
|
||||
archive_list = json.loads(cmd(archiver, "rlist", "--json"))
|
||||
archive_list = json.loads(cmd(archiver, "repo-list", "--json"))
|
||||
assert archive_list["archives"] == []
|
||||
|
||||
|
||||
def test_create_content_from_command_missing_command(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
output = cmd(archiver, "create", "test", "--content-from-command", exit_code=2)
|
||||
assert output.endswith("No command given." + os.linesep)
|
||||
|
||||
|
||||
def test_create_paths_from_stdin(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "dir1/file2", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "dir1/file3", size=1024 * 80)
|
||||
|
@ -377,7 +377,7 @@ def test_create_paths_from_stdin(archivers, request):
|
|||
|
||||
def test_create_paths_from_command(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file3", size=1024 * 80)
|
||||
|
@ -395,7 +395,7 @@ def test_create_paths_from_command(archivers, request):
|
|||
|
||||
def test_create_paths_from_command_with_failed_command(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
if archiver.FORK_DEFAULT:
|
||||
expected_ec = CommandError().exit_code
|
||||
output = cmd(
|
||||
|
@ -405,13 +405,13 @@ def test_create_paths_from_command_with_failed_command(archivers, request):
|
|||
else:
|
||||
with pytest.raises(CommandError):
|
||||
cmd(archiver, "create", "--paths-from-command", "test", "--", "sh", "-c", "exit 73;")
|
||||
archive_list = json.loads(cmd(archiver, "rlist", "--json"))
|
||||
archive_list = json.loads(cmd(archiver, "repo-list", "--json"))
|
||||
assert archive_list["archives"] == []
|
||||
|
||||
|
||||
def test_create_paths_from_command_missing_command(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
output = cmd(archiver, "create", "test", "--paths-from-command", exit_code=2)
|
||||
assert output.endswith("No command given." + os.linesep)
|
||||
|
||||
|
@ -419,14 +419,14 @@ def test_create_paths_from_command_missing_command(archivers, request):
|
|||
def test_create_without_root(archivers, request):
|
||||
"""test create without a root"""
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", exit_code=2)
|
||||
|
||||
|
||||
def test_create_pattern_root(archivers, request):
|
||||
"""test create with only a root pattern"""
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
output = cmd(archiver, "create", "test", "-v", "--list", "--pattern=R input")
|
||||
|
@ -437,7 +437,7 @@ def test_create_pattern_root(archivers, request):
|
|||
def test_create_pattern(archivers, request):
|
||||
"""test file patterns during create"""
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file_important", size=1024 * 80)
|
||||
|
@ -452,7 +452,7 @@ def test_create_pattern(archivers, request):
|
|||
def test_create_pattern_file(archivers, request):
|
||||
"""test file patterns during create"""
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "otherfile", size=1024 * 80)
|
||||
|
@ -479,7 +479,7 @@ def test_create_pattern_exclude_folder_but_recurse(archivers, request):
|
|||
patterns_file_path2 = os.path.join(archiver.tmpdir, "patterns2")
|
||||
with open(patterns_file_path2, "wb") as fd:
|
||||
fd.write(b"+ input/x/b\n- input/x*\n")
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "x/a/foo_a", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "x/b/foo_b", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "y/foo_y", size=1024 * 80)
|
||||
|
@ -495,7 +495,7 @@ def test_create_pattern_exclude_folder_no_recurse(archivers, request):
|
|||
patterns_file_path2 = os.path.join(archiver.tmpdir, "patterns2")
|
||||
with open(patterns_file_path2, "wb") as fd:
|
||||
fd.write(b"+ input/x/b\n! input/x*\n")
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "x/a/foo_a", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "x/b/foo_b", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "y/foo_y", size=1024 * 80)
|
||||
|
@ -511,7 +511,7 @@ def test_create_pattern_intermediate_folders_first(archivers, request):
|
|||
patterns_file_path2 = os.path.join(archiver.tmpdir, "patterns2")
|
||||
with open(patterns_file_path2, "wb") as fd:
|
||||
fd.write(b"+ input/x/a\n+ input/x/b\n- input/x*\n")
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "x/a/foo_a", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "x/b/foo_b", size=1024 * 80)
|
||||
with changedir("input"):
|
||||
|
@ -530,8 +530,8 @@ def test_create_pattern_intermediate_folders_first(archivers, request):
|
|||
def test_create_no_cache_sync_adhoc(archivers, request): # TODO: add test for AdHocWithFilesCache
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "rdelete", "--cache-only")
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-delete", "--cache-only")
|
||||
create_json = json.loads(
|
||||
cmd(archiver, "create", "--no-cache-sync", "--prefer-adhoc-cache", "--json", "test", "input")
|
||||
)
|
||||
|
@ -539,21 +539,21 @@ def test_create_no_cache_sync_adhoc(archivers, request): # TODO: add test for A
|
|||
create_stats = create_json["cache"]["stats"]
|
||||
info_stats = info_json["cache"]["stats"]
|
||||
assert create_stats == info_stats
|
||||
cmd(archiver, "rdelete", "--cache-only")
|
||||
cmd(archiver, "repo-delete", "--cache-only")
|
||||
cmd(archiver, "create", "--no-cache-sync", "--prefer-adhoc-cache", "test2", "input")
|
||||
cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-info")
|
||||
cmd(archiver, "check")
|
||||
|
||||
|
||||
def test_create_archivename_with_placeholder(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
ts = "1999-12-31T23:59:59"
|
||||
name_given = "test-{now}" # placeholder in archive name gets replaced by borg
|
||||
name_expected = f"test-{ts}" # placeholder in f-string gets replaced by python
|
||||
cmd(archiver, "create", f"--timestamp={ts}", name_given, "input")
|
||||
list_output = cmd(archiver, "rlist", "--short")
|
||||
list_output = cmd(archiver, "repo-list", "--short")
|
||||
assert name_expected in list_output
|
||||
|
||||
|
||||
|
@ -591,7 +591,7 @@ def test_exclude_keep_tagged(archivers, request):
|
|||
|
||||
def test_path_sanitation(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "dir1/dir2/file", size=1024 * 80)
|
||||
with changedir("input/dir1/dir2"):
|
||||
cmd(archiver, "create", "test", "../../../input/dir1/../dir1/dir2/..")
|
||||
|
@ -602,7 +602,7 @@ def test_path_sanitation(archivers, request):
|
|||
|
||||
def test_exclude_sanitation(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
with changedir("input"):
|
||||
|
@ -624,7 +624,7 @@ def test_exclude_sanitation(archivers, request):
|
|||
def test_repeated_files(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input", "input")
|
||||
|
||||
|
||||
|
@ -633,7 +633,7 @@ def test_repeated_files(archivers, request):
|
|||
def test_umask(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
mode = os.stat(archiver.repository_path).st_mode
|
||||
assert stat.S_IMODE(mode) == 0o700
|
||||
|
@ -641,7 +641,7 @@ def test_umask(archivers, request):
|
|||
|
||||
def test_create_dry_run(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "--dry-run", "test", "input")
|
||||
# Make sure no archive has been created
|
||||
with Repository(archiver.repository_path) as repository:
|
||||
|
@ -652,7 +652,7 @@ def test_create_dry_run(archivers, request):
|
|||
def test_progress_on(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
output = cmd(archiver, "create", "test4", "input", "--progress")
|
||||
assert "\r" in output
|
||||
|
||||
|
@ -660,7 +660,7 @@ def test_progress_on(archivers, request):
|
|||
def test_progress_off(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
output = cmd(archiver, "create", "test5", "input")
|
||||
assert "\r" not in output
|
||||
|
||||
|
@ -672,7 +672,7 @@ def test_file_status(archivers, request):
|
|||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
time.sleep(1) # file2 must have newer timestamps than file1
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
output = cmd(archiver, "create", "--list", "test", "input")
|
||||
assert "A input/file1" in output
|
||||
assert "A input/file2" in output
|
||||
|
@ -693,7 +693,7 @@ def test_file_status_cs_cache_mode(archivers, request):
|
|||
create_regular_file(archiver.input_path, "file1", contents=b"123")
|
||||
time.sleep(1) # file2 must have newer timestamps than file1
|
||||
create_regular_file(archiver.input_path, "file2", size=10)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test1", "input", "--list", "--files-cache=ctime,size")
|
||||
# modify file1, but cheat with the mtime (and atime) and also keep same size:
|
||||
st = os.stat("input/file1")
|
||||
|
@ -710,7 +710,7 @@ def test_file_status_ms_cache_mode(archivers, request):
|
|||
create_regular_file(archiver.input_path, "file1", size=10)
|
||||
time.sleep(1) # file2 must have newer timestamps than file1
|
||||
create_regular_file(archiver.input_path, "file2", size=10)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "--list", "--files-cache=mtime,size", "test1", "input")
|
||||
# change mode of file1, no content change:
|
||||
st = os.stat("input/file1")
|
||||
|
@ -726,7 +726,7 @@ def test_file_status_rc_cache_mode(archivers, request):
|
|||
create_regular_file(archiver.input_path, "file1", size=10)
|
||||
time.sleep(1) # file2 must have newer timestamps than file1
|
||||
create_regular_file(archiver.input_path, "file2", size=10)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "--list", "--files-cache=rechunk,ctime", "test1", "input")
|
||||
# no changes here, but this mode rechunks unconditionally
|
||||
output = cmd(archiver, "create", "--list", "--files-cache=rechunk,ctime", "test2", "input")
|
||||
|
@ -742,7 +742,7 @@ def test_file_status_excluded(archivers, request):
|
|||
if has_lchflags:
|
||||
create_regular_file(archiver.input_path, "file3", size=1024 * 80)
|
||||
platform.set_flags(os.path.join(archiver.input_path, "file3"), stat.UF_NODUMP)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
output = cmd(archiver, "create", "--list", "--exclude-nodump", "test", "input")
|
||||
assert "A input/file1" in output
|
||||
assert "A input/file2" in output
|
||||
|
@ -771,7 +771,7 @@ def to_dict(borg_create_output):
|
|||
return borg_create_output
|
||||
|
||||
# Test case set up: create a repository
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# Archive an empty dir
|
||||
result = cmd(archiver, "create", "--stats", "test_archive", archiver.input_path)
|
||||
result = to_dict(result)
|
||||
|
@ -801,7 +801,7 @@ def to_dict(borg_create_output):
|
|||
def test_create_json(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_info = json.loads(cmd(archiver, "create", "--json", "test", "input"))
|
||||
# The usual keys
|
||||
assert "encryption" in create_info
|
||||
|
@ -822,7 +822,7 @@ def test_create_topical(archivers, request):
|
|||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
time.sleep(1) # file2 must have newer timestamps than file1
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# no listing by default
|
||||
output = cmd(archiver, "create", "test", "input")
|
||||
assert "file1" not in output
|
||||
|
@ -854,7 +854,7 @@ def fifo_feeder(fifo_fn, data):
|
|||
finally:
|
||||
os.close(fd)
|
||||
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
data = b"foobar" * 1000
|
||||
|
||||
fifo_fn = os.path.join(archiver.input_path, "fifo")
|
||||
|
@ -889,7 +889,7 @@ def fifo_feeder(fifo_fn, data):
|
|||
def test_create_read_special_broken_symlink(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
os.symlink("somewhere does not exist", os.path.join(archiver.input_path, "link"))
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "--read-special", "test", "input")
|
||||
output = cmd(archiver, "list", "test")
|
||||
assert "input/link -> somewhere does not exist" in output
|
||||
|
@ -899,7 +899,7 @@ def test_create_dotslash_hack(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
os.makedirs(os.path.join(archiver.input_path, "first", "secondA", "thirdA"))
|
||||
os.makedirs(os.path.join(archiver.input_path, "first", "secondB", "thirdB"))
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input/first/./") # hack!
|
||||
output = cmd(archiver, "list", "test")
|
||||
# dir levels left of slashdot (= input, first) not in archive:
|
||||
|
@ -924,7 +924,7 @@ def test_create_dotslash_hack(archivers, request):
|
|||
def test_log_json(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
log = cmd(archiver, "create", "test", "input", "--log-json", "--list", "--debug")
|
||||
messages = {} # type -> message, one of each kind
|
||||
for line in log.splitlines():
|
||||
|
@ -944,7 +944,7 @@ def test_log_json(archivers, request):
|
|||
def test_common_options(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
log = cmd(archiver, "--debug", "create", "test", "input")
|
||||
assert "security: read previous location" in log
|
||||
|
||||
|
@ -961,7 +961,7 @@ def extract_hashing_time(borg_create_output):
|
|||
return hashing_time
|
||||
|
||||
# Test case set up: create a repository and a file
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
create_regular_file(archiver.input_path, "testfile", contents=randbytes(50000000))
|
||||
# Archive
|
||||
result = cmd(archiver, "create", "--stats", "test_archive", archiver.input_path)
|
||||
|
@ -981,7 +981,7 @@ def extract_chunking_time(borg_create_output):
|
|||
return chunking_time
|
||||
|
||||
# Test case set up: create a repository and a file
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "testfile", contents=randbytes(50000000))
|
||||
# Archive
|
||||
result = cmd(archiver, "create", "--stats", "test_archive", archiver.input_path)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
def test_debug_profile(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input", "--debug-profile=create.prof")
|
||||
cmd(archiver, "debug", "convert-profile", "create.prof", "create.pyprof")
|
||||
stats = pstats.Stats("create.pyprof")
|
||||
|
@ -28,7 +28,7 @@ def test_debug_profile(archivers, request):
|
|||
def test_debug_dump_archive_items(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
output = cmd(archiver, "debug", "dump-archive-items", "test")
|
||||
|
@ -40,7 +40,7 @@ def test_debug_dump_archive_items(archivers, request):
|
|||
def test_debug_dump_repo_objs(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
output = cmd(archiver, "debug", "dump-repo-objs")
|
||||
|
@ -51,7 +51,7 @@ def test_debug_dump_repo_objs(archivers, request):
|
|||
|
||||
def test_debug_put_get_delete_obj(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
data = b"some data"
|
||||
create_regular_file(archiver.input_path, "file", contents=data)
|
||||
|
||||
|
@ -81,7 +81,7 @@ def test_debug_put_get_delete_obj(archivers, request):
|
|||
def test_debug_id_hash_format_put_get_parse_obj(archivers, request):
|
||||
"""Test format-obj and parse-obj commands"""
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
data = b"some data" * 100
|
||||
meta_dict = {"some": "property"}
|
||||
meta = json.dumps(meta_dict).encode()
|
||||
|
@ -126,7 +126,7 @@ def test_debug_id_hash_format_put_get_parse_obj(archivers, request):
|
|||
def test_debug_dump_manifest(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
dump_file = archiver.output_path + "/dump"
|
||||
output = cmd(archiver, "debug", "dump-manifest", dump_file)
|
||||
|
@ -144,7 +144,7 @@ def test_debug_dump_manifest(archivers, request):
|
|||
def test_debug_dump_archive(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
dump_file = archiver.output_path + "/dump"
|
||||
output = cmd(archiver, "debug", "dump-archive", "test", dump_file)
|
||||
|
|
|
@ -8,7 +8,7 @@ def test_delete_options(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "dir2/file2", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
cmd(archiver, "create", "test.2", "input")
|
||||
cmd(archiver, "create", "test.3", "input")
|
||||
|
@ -19,16 +19,16 @@ def test_delete_options(archivers, request):
|
|||
cmd(archiver, "delete", "-a", "test")
|
||||
cmd(archiver, "extract", "test.2", "--dry-run") # still there?
|
||||
cmd(archiver, "delete", "-a", "test.2")
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
assert output == "" # no archives left!
|
||||
|
||||
|
||||
def test_delete_multiple(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test1", "input")
|
||||
cmd(archiver, "create", "test2", "input")
|
||||
cmd(archiver, "delete", "-a", "test1")
|
||||
cmd(archiver, "delete", "-a", "test2")
|
||||
assert not cmd(archiver, "rlist")
|
||||
assert not cmd(archiver, "repo-list")
|
||||
|
|
|
@ -34,7 +34,7 @@ def test_basic_functionality(archivers, request):
|
|||
os.link("input/empty", "input/hardlink_contents_changed")
|
||||
os.link("input/file_removed", "input/hardlink_removed")
|
||||
os.link("input/file_removed2", "input/hardlink_target_removed")
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# Create the first snapshot
|
||||
cmd(archiver, "create", "test0", "input")
|
||||
# Setup files for the second snapshot
|
||||
|
@ -232,7 +232,7 @@ def get_changes(filename, data):
|
|||
|
||||
def test_time_diffs(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "test_file", size=10)
|
||||
cmd(archiver, "create", "archive1", "input")
|
||||
time.sleep(0.1)
|
||||
|
@ -263,7 +263,7 @@ def test_time_diffs(archivers, request):
|
|||
|
||||
def test_sort_option(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
|
||||
create_regular_file(archiver.input_path, "a_file_removed", size=8)
|
||||
create_regular_file(archiver.input_path, "f_file_removed", size=16)
|
||||
|
|
|
@ -51,9 +51,9 @@ def test_disk_full(test_pass, cmd_fixture, monkeypatch):
|
|||
input = os.path.join(DF_MOUNT, "input")
|
||||
shutil.rmtree(repo, ignore_errors=True)
|
||||
shutil.rmtree(input, ignore_errors=True)
|
||||
rc, out = cmd_fixture(f"--repo={repo}", "rcreate", "--encryption=none")
|
||||
rc, out = cmd_fixture(f"--repo={repo}", "repo-create", "--encryption=none")
|
||||
if rc != EXIT_SUCCESS:
|
||||
print("rcreate", rc, out)
|
||||
print("repo-create", rc, out)
|
||||
assert rc == EXIT_SUCCESS
|
||||
try:
|
||||
try:
|
||||
|
@ -81,13 +81,13 @@ def test_disk_full(test_pass, cmd_fixture, monkeypatch):
|
|||
# now some error happened, likely we are out of disk space.
|
||||
# free some space such that we can expect borg to be able to work normally:
|
||||
shutil.rmtree(input, ignore_errors=True)
|
||||
rc, out = cmd_fixture(f"--repo={repo}", "rlist")
|
||||
rc, out = cmd_fixture(f"--repo={repo}", "repo-list")
|
||||
if rc != EXIT_SUCCESS:
|
||||
print("rlist", rc, out)
|
||||
print("repo-list", rc, out)
|
||||
rc, out = cmd_fixture(f"--repo={repo}", "check", "--repair")
|
||||
if rc != EXIT_SUCCESS:
|
||||
print("check", rc, out)
|
||||
assert rc == EXIT_SUCCESS
|
||||
finally:
|
||||
# try to free the space allocated for the repo
|
||||
cmd_fixture(f"--repo={repo}", "rdelete")
|
||||
cmd_fixture(f"--repo={repo}", "repo-delete")
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
def test_symlink_extract(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
cmd(archiver, "extract", "test")
|
||||
|
@ -50,7 +50,7 @@ def test_hardlinked_symlinks_extract(archivers, request):
|
|||
with changedir("input"):
|
||||
os.symlink("target", "symlink1")
|
||||
os.link("symlink1", "symlink2", follow_symlinks=False)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
output = cmd(archiver, "extract", "test")
|
||||
|
@ -71,7 +71,7 @@ def test_hardlinked_symlinks_extract(archivers, request):
|
|||
def test_directory_timestamps1(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# default file archiving order (internal recursion)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
|
@ -88,7 +88,7 @@ def test_directory_timestamps1(archivers, request):
|
|||
def test_directory_timestamps2(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# given order, dir first, file second
|
||||
flist_dir_first = b"input/dir2\ninput/dir2/file2\n"
|
||||
cmd(archiver, "create", "--paths-from-stdin", "test", input=flist_dir_first)
|
||||
|
@ -106,7 +106,7 @@ def test_directory_timestamps2(archivers, request):
|
|||
def test_directory_timestamps3(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# given order, file first, dir second
|
||||
flist_file_first = b"input/dir2/file2\ninput/dir2\n"
|
||||
cmd(archiver, "create", "--paths-from-stdin", "test", input=flist_file_first)
|
||||
|
@ -140,7 +140,7 @@ def has_noatime(some_file):
|
|||
atime, mtime = 123456780, 234567890
|
||||
have_noatime = has_noatime("input/file1")
|
||||
os.utime("input/file1", (atime, mtime))
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "--atime", "test", "input")
|
||||
with changedir("output"):
|
||||
cmd(archiver, "extract", "test")
|
||||
|
@ -164,7 +164,7 @@ def test_birthtime(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")
|
||||
with changedir("output"):
|
||||
cmd(archiver, "extract", "test")
|
||||
|
@ -217,7 +217,7 @@ def is_sparse(fn, total_size, hole_size):
|
|||
if sparse_support:
|
||||
# we could create a sparse input file, so creating a backup of it and
|
||||
# extracting it again (as sparse) should also work:
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir(archiver.output_path):
|
||||
cmd(archiver, "extract", "test", "--sparse")
|
||||
|
@ -238,7 +238,7 @@ def test_unusual_filenames(archivers, request):
|
|||
filename = os.path.join(archiver.input_path, filename)
|
||||
with open(filename, "wb"):
|
||||
pass
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
for filename in filenames:
|
||||
with changedir("output"):
|
||||
|
@ -248,7 +248,7 @@ def test_unusual_filenames(archivers, request):
|
|||
|
||||
def test_strip_components(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "dir/file")
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
|
@ -309,7 +309,7 @@ def test_extract_hardlinks_twice(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!
|
||||
# now test extraction
|
||||
with changedir("output"):
|
||||
|
@ -324,7 +324,7 @@ def test_extract_hardlinks_twice(archivers, request):
|
|||
|
||||
def test_extract_include_exclude(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file3", size=1024 * 80)
|
||||
|
@ -346,7 +346,7 @@ def test_extract_include_exclude(archivers, request):
|
|||
|
||||
def test_extract_include_exclude_regex(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file3", size=1024 * 80)
|
||||
|
@ -387,7 +387,7 @@ def test_extract_include_exclude_regex(archivers, request):
|
|||
|
||||
def test_extract_include_exclude_regex_from_file(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file3", size=1024 * 80)
|
||||
|
@ -427,7 +427,7 @@ def test_extract_include_exclude_regex_from_file(archivers, request):
|
|||
|
||||
def test_extract_with_pattern(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file3", size=1024 * 80)
|
||||
|
@ -461,7 +461,7 @@ def test_extract_with_pattern(archivers, request):
|
|||
|
||||
def test_extract_list_output(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file", size=1024 * 80)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
|
||||
|
@ -487,7 +487,7 @@ def test_extract_list_output(archivers, request):
|
|||
|
||||
def test_extract_progress(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file", size=1024 * 80)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
|
||||
|
@ -498,7 +498,7 @@ def test_extract_progress(archivers, request):
|
|||
|
||||
def test_extract_pattern_opt(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file2", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "file_important", size=1024 * 80)
|
||||
|
@ -525,7 +525,7 @@ def patched_fchown(fd, uid, gid):
|
|||
capabilities = b"\x01\x00\x00\x02\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
|
||||
create_regular_file(archiver.input_path, "file")
|
||||
xattr.setxattr(b"input/file", b"security.capability", capabilities)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
with patch.object(os, "fchown", patched_fchown):
|
||||
|
@ -550,7 +550,7 @@ def patched_setxattr_EACCES(*args, **kwargs):
|
|||
|
||||
create_regular_file(archiver.input_path, "file")
|
||||
xattr.setxattr(b"input/file", b"user.attribute", b"value")
|
||||
cmd(archiver, "rcreate", "-e" "none")
|
||||
cmd(archiver, "repo-create", "-e" "none")
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
input_abspath = os.path.abspath("input/file")
|
||||
|
@ -578,7 +578,7 @@ def patched_setxattr_EACCES(*args, **kwargs):
|
|||
def test_extract_xattrs_resourcefork(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file")
|
||||
cmd(archiver, "rcreate", "-e" "none")
|
||||
cmd(archiver, "repo-create", "-e" "none")
|
||||
input_path = os.path.abspath("input/file")
|
||||
xa_key, xa_value = b"com.apple.ResourceFork", b"whatshouldbehere" # issue #7234
|
||||
xattr.setxattr(input_path.encode(), xa_key, xa_value)
|
||||
|
@ -606,7 +606,7 @@ def test_overwrite(archivers, request):
|
|||
pytest.skip("Test_overwrite seems incompatible with fakeroot and/or the binary.")
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "dir2/file2", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
|
||||
# Overwriting regular files and directories should be supported
|
||||
|
@ -641,7 +641,7 @@ def patched_setxattr_EACCES(*args, **kwargs):
|
|||
|
||||
create_regular_file(archiver.input_path, "file")
|
||||
xattr.setxattr(b"input/file", b"user.attribute%p", b"value")
|
||||
cmd(archiver, "rcreate", "-e" "none")
|
||||
cmd(archiver, "repo-create", "-e" "none")
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
with patch.object(xattr, "setxattr", patched_setxattr_EACCES):
|
||||
|
@ -661,7 +661,7 @@ def patched_setxattr_EACCES(*args, **kwargs):
|
|||
|
||||
os.makedirs(os.path.join(archiver.input_path, "dir%p"))
|
||||
xattr.setxattr(b"input/dir%p", b"user.attribute", b"value")
|
||||
cmd(archiver, "rcreate", "-e" "none")
|
||||
cmd(archiver, "repo-create", "-e" "none")
|
||||
cmd(archiver, "create", "test", "input")
|
||||
with changedir("output"):
|
||||
with patch.object(xattr, "setxattr", patched_setxattr_EACCES):
|
||||
|
@ -671,7 +671,7 @@ def patched_setxattr_EACCES(*args, **kwargs):
|
|||
def test_extract_continue(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
CONTENTS1, CONTENTS2, CONTENTS3 = b"contents1" * 100, b"contents2" * 200, b"contents3" * 300
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", contents=CONTENTS1)
|
||||
create_regular_file(archiver.input_path, "file2", contents=CONTENTS2)
|
||||
create_regular_file(archiver.input_path, "file3", contents=CONTENTS3)
|
||||
|
|
|
@ -38,9 +38,9 @@ def test_usage(archiver):
|
|||
def test_help(archiver):
|
||||
assert "Borg" in cmd(archiver, "help")
|
||||
assert "patterns" in cmd(archiver, "help", "patterns")
|
||||
assert "creates a new, empty repository" in cmd(archiver, "help", "rcreate")
|
||||
assert "positional arguments" not in cmd(archiver, "help", "rcreate", "--epilog-only")
|
||||
assert "creates a new, empty repository" not in cmd(archiver, "help", "rcreate", "--usage-only")
|
||||
assert "creates a new, empty repository" in cmd(archiver, "help", "repo-create")
|
||||
assert "positional arguments" not in cmd(archiver, "help", "repo-create", "--epilog-only")
|
||||
assert "creates a new, empty repository" not in cmd(archiver, "help", "repo-create", "--usage-only")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("command, parser", list(get_all_parsers().items()))
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
def test_info(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
info_archive = cmd(archiver, "info", "-a", "test")
|
||||
assert "Archive name: test" + os.linesep in info_archive
|
||||
|
@ -21,7 +21,7 @@ def test_info(archivers, request):
|
|||
def test_info_json(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
|
||||
info_archive = json.loads(cmd(archiver, "info", "-a", "test", "--json"))
|
||||
|
@ -40,7 +40,7 @@ def test_info_json(archivers, request):
|
|||
def test_info_json_of_empty_archive(archivers, request):
|
||||
"""See https://github.com/borgbackup/borg/issues/6120"""
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
info_repo = json.loads(cmd(archiver, "info", "--json", "--first=1"))
|
||||
assert info_repo["archives"] == []
|
||||
info_repo = json.loads(cmd(archiver, "info", "--json", "--last=1"))
|
||||
|
|
|
@ -18,58 +18,58 @@
|
|||
|
||||
def test_change_passphrase(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
os.environ["BORG_NEW_PASSPHRASE"] = "newpassphrase"
|
||||
# here we have both BORG_PASSPHRASE and BORG_NEW_PASSPHRASE set:
|
||||
cmd(archiver, "key", "change-passphrase")
|
||||
os.environ["BORG_PASSPHRASE"] = "newpassphrase"
|
||||
cmd(archiver, "rlist")
|
||||
cmd(archiver, "repo-list")
|
||||
|
||||
|
||||
def test_change_location_to_keyfile(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
log = cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
log = cmd(archiver, "repo-info")
|
||||
assert "(repokey" in log
|
||||
cmd(archiver, "key", "change-location", "keyfile")
|
||||
log = cmd(archiver, "rinfo")
|
||||
log = cmd(archiver, "repo-info")
|
||||
assert "(key file" in log
|
||||
|
||||
|
||||
def test_change_location_to_b2keyfile(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", "--encryption=repokey-blake2-aes-ocb")
|
||||
log = cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-create", "--encryption=repokey-blake2-aes-ocb")
|
||||
log = cmd(archiver, "repo-info")
|
||||
assert "(repokey BLAKE2b" in log
|
||||
cmd(archiver, "key", "change-location", "keyfile")
|
||||
log = cmd(archiver, "rinfo")
|
||||
log = cmd(archiver, "repo-info")
|
||||
assert "(key file BLAKE2b" in log
|
||||
|
||||
|
||||
def test_change_location_to_repokey(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", KF_ENCRYPTION)
|
||||
log = cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-create", KF_ENCRYPTION)
|
||||
log = cmd(archiver, "repo-info")
|
||||
assert "(key file" in log
|
||||
cmd(archiver, "key", "change-location", "repokey")
|
||||
log = cmd(archiver, "rinfo")
|
||||
log = cmd(archiver, "repo-info")
|
||||
assert "(repokey" in log
|
||||
|
||||
|
||||
def test_change_location_to_b2repokey(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", "--encryption=keyfile-blake2-aes-ocb")
|
||||
log = cmd(archiver, "rinfo")
|
||||
cmd(archiver, "repo-create", "--encryption=keyfile-blake2-aes-ocb")
|
||||
log = cmd(archiver, "repo-info")
|
||||
assert "(key file BLAKE2b" in log
|
||||
cmd(archiver, "key", "change-location", "repokey")
|
||||
log = cmd(archiver, "rinfo")
|
||||
log = cmd(archiver, "repo-info")
|
||||
assert "(repokey BLAKE2b" in log
|
||||
|
||||
|
||||
def test_key_export_keyfile(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
export_file = archiver.output_path + "/exported"
|
||||
cmd(archiver, "rcreate", KF_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", KF_ENCRYPTION)
|
||||
repo_id = _extract_repository_id(archiver.repository_path)
|
||||
cmd(archiver, "key", "export", export_file)
|
||||
|
||||
|
@ -97,7 +97,7 @@ def test_key_export_keyfile(archivers, request):
|
|||
|
||||
def test_key_import_keyfile_with_borg_key_file(archivers, request, monkeypatch):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", KF_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", KF_ENCRYPTION)
|
||||
|
||||
exported_key_file = os.path.join(archiver.output_path, "exported")
|
||||
cmd(archiver, "key", "export", exported_key_file)
|
||||
|
@ -120,7 +120,7 @@ def test_key_import_keyfile_with_borg_key_file(archivers, request, monkeypatch):
|
|||
def test_key_export_repokey(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
export_file = archiver.output_path + "/exported"
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
repo_id = _extract_repository_id(archiver.repository_path)
|
||||
cmd(archiver, "key", "export", export_file)
|
||||
|
||||
|
@ -153,7 +153,7 @@ def test_key_export_repokey(archivers, request):
|
|||
def test_key_export_qr(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
export_file = archiver.output_path + "/exported.html"
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
repo_id = _extract_repository_id(archiver.repository_path)
|
||||
cmd(archiver, "key", "export", "--qr-html", export_file)
|
||||
|
||||
|
@ -169,7 +169,7 @@ def test_key_export_directory(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
export_directory = archiver.output_path + "/exported"
|
||||
os.mkdir(export_directory)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
if archiver.FORK_DEFAULT:
|
||||
expected_ec = CommandError().exit_code
|
||||
cmd(archiver, "key", "export", export_directory, exit_code=expected_ec)
|
||||
|
@ -182,7 +182,7 @@ def test_key_export_qr_directory(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
export_directory = archiver.output_path + "/exported"
|
||||
os.mkdir(export_directory)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
if archiver.FORK_DEFAULT:
|
||||
expected_ec = CommandError().exit_code
|
||||
cmd(archiver, "key", "export", "--qr-html", export_directory, exit_code=expected_ec)
|
||||
|
@ -194,7 +194,7 @@ def test_key_export_qr_directory(archivers, request):
|
|||
def test_key_import_errors(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
export_file = archiver.output_path + "/exported"
|
||||
cmd(archiver, "rcreate", KF_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", KF_ENCRYPTION)
|
||||
if archiver.FORK_DEFAULT:
|
||||
expected_ec = CommandError().exit_code
|
||||
cmd(archiver, "key", "import", export_file, exit_code=expected_ec)
|
||||
|
@ -227,7 +227,7 @@ def test_key_export_paperkey(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
repo_id = "e294423506da4e1ea76e8dcdf1a3919624ae3ae496fddf905610c351d3f09239"
|
||||
export_file = archiver.output_path + "/exported"
|
||||
cmd(archiver, "rcreate", KF_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", KF_ENCRYPTION)
|
||||
_set_repository_id(archiver.repository_path, hex_to_bin(repo_id))
|
||||
key_file = archiver.keys_path + "/" + os.listdir(archiver.keys_path)[0]
|
||||
|
||||
|
@ -255,7 +255,7 @@ def test_key_export_paperkey(archivers, request):
|
|||
def test_key_import_paperkey(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
repo_id = "e294423506da4e1ea76e8dcdf1a3919624ae3ae496fddf905610c351d3f09239"
|
||||
cmd(archiver, "rcreate", KF_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", KF_ENCRYPTION)
|
||||
_set_repository_id(archiver.repository_path, hex_to_bin(repo_id))
|
||||
|
||||
key_file = archiver.keys_path + "/" + os.listdir(archiver.keys_path)[0]
|
||||
|
@ -301,7 +301,7 @@ def test_key_import_paperkey(archivers, request):
|
|||
def test_init_defaults_to_argon2(archivers, request):
|
||||
"""https://github.com/borgbackup/borg/issues/747#issuecomment-1076160401"""
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
with Repository(archiver.repository_path) as repository:
|
||||
key = msgpack.unpackb(binascii.a2b_base64(repository.load_key()))
|
||||
assert key["algorithm"] == "argon2 chacha20-poly1305"
|
||||
|
@ -309,7 +309,7 @@ def test_init_defaults_to_argon2(archivers, request):
|
|||
|
||||
def test_change_passphrase_does_not_change_algorithm_argon2(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
os.environ["BORG_NEW_PASSPHRASE"] = "newpassphrase"
|
||||
cmd(archiver, "key", "change-passphrase")
|
||||
|
||||
|
@ -320,7 +320,7 @@ def test_change_passphrase_does_not_change_algorithm_argon2(archivers, request):
|
|||
|
||||
def test_change_location_does_not_change_algorithm_argon2(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", KF_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", KF_ENCRYPTION)
|
||||
cmd(archiver, "key", "change-location", "repokey")
|
||||
|
||||
with Repository(archiver.repository_path) as repository:
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
def test_list_format(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", src_dir)
|
||||
output_1 = cmd(archiver, "list", "test")
|
||||
output_2 = cmd(
|
||||
|
@ -24,7 +24,7 @@ def test_list_hash(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "empty_file", size=0)
|
||||
create_regular_file(archiver.input_path, "amb", contents=b"a" * 1000000)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
output = cmd(archiver, "list", "test", "--format", "{sha256} {path}{NL}")
|
||||
assert "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 input/amb" in output
|
||||
|
@ -38,7 +38,7 @@ def test_list_chunk_counts(archivers, request):
|
|||
with open(os.path.join(archiver.input_path, "two_chunks"), "wb") as fd:
|
||||
fd.write(b"abba" * 2000000)
|
||||
fd.write(b"baab" * 2000000)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
output = cmd(archiver, "list", "test", "--format", "{num_chunks} {path}{NL}")
|
||||
assert "0 input/empty_file" in output
|
||||
|
@ -48,7 +48,7 @@ def test_list_chunk_counts(archivers, request):
|
|||
def test_list_size(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "compressible_file", size=10000)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "-C", "lz4", "test", "input")
|
||||
output = cmd(archiver, "list", "test", "--format", "{size} {path}{NL}")
|
||||
size, path = output.split("\n")[1].split(" ")
|
||||
|
@ -58,7 +58,7 @@ def test_list_size(archivers, request):
|
|||
def test_list_json(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
|
||||
list_archive = cmd(archiver, "list", "test", "--json-lines")
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
def test_break_lock(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "break-lock")
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ def test_with_lock(tmp_path):
|
|||
repo_path = tmp_path / "repo"
|
||||
env = os.environ.copy()
|
||||
env["BORG_REPO"] = "file://" + str(repo_path)
|
||||
command0 = "python3", "-m", "borg", "rcreate", "--encryption=none"
|
||||
command0 = "python3", "-m", "borg", "repo-create", "--encryption=none"
|
||||
# timings must be adjusted so that command1 keeps running while command2 tries to get the lock,
|
||||
# so that lock acquisition for command2 fails as the test expects it.
|
||||
lock_wait, execution_time, startup_wait = 2, 4, 1
|
||||
|
@ -46,7 +46,7 @@ def test_with_lock(tmp_path):
|
|||
|
||||
def test_with_lock_non_existent_command(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
command = ["non_existent_command"]
|
||||
expected_ec = CommandError().exit_code
|
||||
cmd(archiver, "with-lock", *command, fork=True, exit_code=expected_ec)
|
||||
|
|
|
@ -75,7 +75,7 @@ def has_noatime(some_file):
|
|||
noatime_used = flags_noatime != flags_normal
|
||||
return noatime_used and atime_before == atime_after
|
||||
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_test_files(archiver.input_path)
|
||||
have_noatime = has_noatime("input/file1")
|
||||
cmd(archiver, "create", "--exclude-nodump", "--atime", "archive", "input")
|
||||
|
@ -169,7 +169,7 @@ def has_noatime(some_file):
|
|||
@pytest.mark.skipif(not llfuse, reason="llfuse not installed")
|
||||
def test_fuse_versions_view(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "test", contents=b"first")
|
||||
if are_hardlinks_supported():
|
||||
create_regular_file(archiver.input_path, "hardlink1", contents=b"123456")
|
||||
|
@ -203,7 +203,7 @@ def test_fuse_versions_view(archivers, request):
|
|||
@pytest.mark.skipif(not llfuse, reason="llfuse not installed")
|
||||
def test_fuse_allow_damaged_files(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_src_archive(archiver, "archive")
|
||||
# Get rid of a chunk and repair it
|
||||
archive, repository = open_archive(archiver.repository_path, "archive")
|
||||
|
@ -229,7 +229,7 @@ def test_fuse_allow_damaged_files(archivers, request):
|
|||
@pytest.mark.skipif(not llfuse, reason="llfuse not installed")
|
||||
def test_fuse_mount_options(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_src_archive(archiver, "arch11")
|
||||
create_src_archive(archiver, "arch12")
|
||||
create_src_archive(archiver, "arch21")
|
||||
|
@ -307,7 +307,7 @@ def wrapper(self, old_id, new_id):
|
|||
# Decorate
|
||||
Lock.migrate_lock = write_assert_data(Lock.migrate_lock)
|
||||
try:
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
create_src_archive(archiver, "arch")
|
||||
mountpoint = os.path.join(archiver.tmpdir, "mountpoint")
|
||||
# In order that the decoration is kept for the borg mount process, we must not spawn, but actually fork;
|
||||
|
|
|
@ -20,18 +20,18 @@ def _create_archive_ts(archiver, name, y, m, d, H=0, M=0, S=0):
|
|||
|
||||
def test_prune_repository(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test1", src_dir)
|
||||
cmd(archiver, "create", "test2", src_dir)
|
||||
output = cmd(archiver, "prune", "--list", "--dry-run", "--keep-daily=1")
|
||||
assert re.search(r"Would prune:\s+test1", output)
|
||||
# must keep the latest archive:
|
||||
assert re.search(r"Keeping archive \(rule: daily #1\):\s+test2", output)
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
assert "test1" in output
|
||||
assert "test2" in output
|
||||
cmd(archiver, "prune", "--keep-daily=1")
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
assert "test1" not in output
|
||||
# the latest archive must be still there:
|
||||
assert "test2" in output
|
||||
|
@ -40,7 +40,7 @@ def test_prune_repository(archivers, request):
|
|||
# This test must match docs/misc/prune-example.txt
|
||||
def test_prune_repository_example(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# Archives that will be kept, per the example
|
||||
# Oldest archive
|
||||
_create_archive_ts(archiver, "test01", 2015, 1, 1)
|
||||
|
@ -86,12 +86,12 @@ def test_prune_repository_example(archivers, request):
|
|||
assert re.search(r"Keeping archive \(rule: monthly #" + str(i) + r"\):\s+test" + ("%02d" % (8 - i)), output)
|
||||
for i in range(1, 15):
|
||||
assert re.search(r"Keeping archive \(rule: daily #" + str(i) + r"\):\s+test" + ("%02d" % (22 - i)), output)
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
# Nothing pruned after dry run
|
||||
for i in range(1, 25):
|
||||
assert "test%02d" % i in output
|
||||
cmd(archiver, "prune", "--keep-daily=14", "--keep-monthly=6", "--keep-yearly=1")
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
# All matching backups plus oldest kept
|
||||
for i in range(1, 22):
|
||||
assert "test%02d" % i in output
|
||||
|
@ -103,7 +103,7 @@ def test_prune_repository_example(archivers, request):
|
|||
# With an initial and daily backup, prune daily until oldest is replaced by a monthly backup
|
||||
def test_prune_retain_and_expire_oldest(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# Initial backup
|
||||
_create_archive_ts(archiver, "original_archive", 2020, 9, 1, 11, 15)
|
||||
# Archive and prune daily for 30 days
|
||||
|
@ -128,7 +128,7 @@ def test_prune_retain_and_expire_oldest(archivers, request):
|
|||
|
||||
def test_prune_repository_prefix(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "foo-2015-08-12-10:00", src_dir)
|
||||
cmd(archiver, "create", "foo-2015-08-12-20:00", src_dir)
|
||||
cmd(archiver, "create", "bar-2015-08-12-10:00", src_dir)
|
||||
|
@ -136,13 +136,13 @@ def test_prune_repository_prefix(archivers, request):
|
|||
output = cmd(archiver, "prune", "--list", "--dry-run", "--keep-daily=1", "--match-archives=sh:foo-*")
|
||||
assert re.search(r"Keeping archive \(rule: daily #1\):\s+foo-2015-08-12-20:00", output)
|
||||
assert re.search(r"Would prune:\s+foo-2015-08-12-10:00", output)
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
assert "foo-2015-08-12-10:00" in output
|
||||
assert "foo-2015-08-12-20:00" in output
|
||||
assert "bar-2015-08-12-10:00" in output
|
||||
assert "bar-2015-08-12-20:00" in output
|
||||
cmd(archiver, "prune", "--keep-daily=1", "--match-archives=sh:foo-*")
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
assert "foo-2015-08-12-10:00" not in output
|
||||
assert "foo-2015-08-12-20:00" in output
|
||||
assert "bar-2015-08-12-10:00" in output
|
||||
|
@ -151,7 +151,7 @@ def test_prune_repository_prefix(archivers, request):
|
|||
|
||||
def test_prune_repository_glob(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "2015-08-12-10:00-foo", src_dir)
|
||||
cmd(archiver, "create", "2015-08-12-20:00-foo", src_dir)
|
||||
cmd(archiver, "create", "2015-08-12-10:00-bar", src_dir)
|
||||
|
@ -159,13 +159,13 @@ def test_prune_repository_glob(archivers, request):
|
|||
output = cmd(archiver, "prune", "--list", "--dry-run", "--keep-daily=1", "--match-archives=sh:2015-*-foo")
|
||||
assert re.search(r"Keeping archive \(rule: daily #1\):\s+2015-08-12-20:00-foo", output)
|
||||
assert re.search(r"Would prune:\s+2015-08-12-10:00-foo", output)
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
assert "2015-08-12-10:00-foo" in output
|
||||
assert "2015-08-12-20:00-foo" in output
|
||||
assert "2015-08-12-10:00-bar" in output
|
||||
assert "2015-08-12-20:00-bar" in output
|
||||
cmd(archiver, "prune", "--keep-daily=1", "--match-archives=sh:2015-*-foo")
|
||||
output = cmd(archiver, "rlist")
|
||||
output = cmd(archiver, "repo-list")
|
||||
assert "2015-08-12-10:00-foo" not in output
|
||||
assert "2015-08-12-20:00-foo" in output
|
||||
assert "2015-08-12-10:00-bar" in output
|
||||
|
|
|
@ -63,7 +63,7 @@ def test_recreate_exclude_keep_tagged(archivers, request):
|
|||
@pytest.mark.skipif(not are_hardlinks_supported(), reason="hardlinks not supported")
|
||||
def test_recreate_hardlinked_tags(archivers, request): # test for issue #4911
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
create_regular_file(
|
||||
archiver.input_path, "file1", contents=CACHE_TAG_CONTENTS
|
||||
) # "wrong" filename, but correct tag contents
|
||||
|
@ -81,7 +81,7 @@ def test_recreate_hardlinked_tags(archivers, request): # test for issue #4911
|
|||
|
||||
def test_recreate_target_rc(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
if archiver.FORK_DEFAULT:
|
||||
expected_ec = CommandError().exit_code
|
||||
output = cmd(archiver, "recreate", "--target=asdf", exit_code=expected_ec)
|
||||
|
@ -94,15 +94,15 @@ def test_recreate_target_rc(archivers, request):
|
|||
def test_recreate_target(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "check")
|
||||
cmd(archiver, "create", "test0", "input")
|
||||
cmd(archiver, "check")
|
||||
original_archive = cmd(archiver, "rlist")
|
||||
original_archive = cmd(archiver, "repo-list")
|
||||
cmd(archiver, "recreate", "test0", "input/dir2", "-e", "input/dir2/file3", "--target=new-archive")
|
||||
cmd(archiver, "check")
|
||||
|
||||
archives = cmd(archiver, "rlist")
|
||||
archives = cmd(archiver, "repo-list")
|
||||
assert original_archive in archives
|
||||
assert "new-archive" in archives
|
||||
|
||||
|
@ -116,7 +116,7 @@ def test_recreate_basic(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
create_regular_file(archiver.input_path, "dir2/file3", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test0", "input")
|
||||
cmd(archiver, "recreate", "test0", "input/dir2", "-e", "input/dir2/file3")
|
||||
cmd(archiver, "check")
|
||||
|
@ -150,7 +150,7 @@ def test_recreate_rechunkify(archivers, request):
|
|||
with open(os.path.join(archiver.input_path, "large_file"), "wb") as fd:
|
||||
fd.write(b"a" * 280)
|
||||
fd.write(b"b" * 280)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test1", "input", "--chunker-params", "7,9,8,128")
|
||||
cmd(archiver, "create", "test2", "input", "--files-cache=disabled")
|
||||
num_chunks1 = int(cmd(archiver, "list", "test1", "input/large_file", "--format", "{num_chunks}"))
|
||||
|
@ -171,7 +171,7 @@ def test_recreate_fixed_rechunkify(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
with open(os.path.join(archiver.input_path, "file"), "wb") as fd:
|
||||
fd.write(b"a" * 8192)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input", "--chunker-params", "7,9,8,128")
|
||||
output = cmd(archiver, "list", "test", "input/file", "--format", "{num_chunks}")
|
||||
num_chunks = int(output)
|
||||
|
@ -186,7 +186,7 @@ def test_recreate_no_rechunkify(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
with open(os.path.join(archiver.input_path, "file"), "wb") as fd:
|
||||
fd.write(b"a" * 8192)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
# first create an archive with non-default chunker params:
|
||||
cmd(archiver, "create", "test", "input", "--chunker-params", "7,9,8,128")
|
||||
output = cmd(archiver, "list", "test", "input/file", "--format", "{num_chunks}")
|
||||
|
@ -202,7 +202,7 @@ def test_recreate_no_rechunkify(archivers, request):
|
|||
def test_recreate_timestamp(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test0", "input")
|
||||
cmd(archiver, "recreate", "test0", "--timestamp", "1970-01-02T00:00:00", "--comment", "test")
|
||||
info = cmd(archiver, "info", "-a", "test0").splitlines()
|
||||
|
@ -215,7 +215,7 @@ def test_recreate_timestamp(archivers, request):
|
|||
def test_recreate_dry_run(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "compressible", size=10000)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
archives_before = cmd(archiver, "list", "test")
|
||||
cmd(archiver, "recreate", "-n", "-e", "input/compressible")
|
||||
|
@ -227,7 +227,7 @@ def test_recreate_dry_run(archivers, request):
|
|||
def test_recreate_skips_nothing_to_do(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
info_before = cmd(archiver, "info", "-a", "test")
|
||||
cmd(archiver, "recreate", "--chunker-params", "default")
|
||||
|
@ -238,7 +238,7 @@ def test_recreate_skips_nothing_to_do(archivers, request):
|
|||
|
||||
def test_recreate_list_output(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=0)
|
||||
create_regular_file(archiver.input_path, "file2", size=0)
|
||||
create_regular_file(archiver.input_path, "file3", size=0)
|
||||
|
@ -271,7 +271,7 @@ def test_comment(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test1", "input")
|
||||
cmd(archiver, "create", "test2", "input", "--comment", "this is the comment")
|
||||
cmd(archiver, "create", "test3", "input", "--comment", '"deleted" comment')
|
||||
|
|
|
@ -10,7 +10,7 @@ def test_rename(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "dir2/file2", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
cmd(archiver, "create", "test.2", "input")
|
||||
cmd(archiver, "extract", "test", "--dry-run")
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
from . import create_regular_file, cmd, RK_ENCRYPTION
|
||||
|
||||
|
||||
def test_rcompress(archiver):
|
||||
def test_repo_compress(archiver):
|
||||
def check_compression(ctype, clevel, olevel):
|
||||
"""check if all the chunks in the repo are compressed/obfuscated like expected"""
|
||||
repository = Repository(archiver.repository_path, exclusive=True)
|
||||
|
@ -42,36 +42,36 @@ def check_compression(ctype, clevel, olevel):
|
|||
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 10)
|
||||
create_regular_file(archiver.input_path, "file2", contents=os.urandom(1024 * 10))
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
|
||||
cname, ctype, clevel, olevel = ZLIB.name, ZLIB.ID, 3, -1
|
||||
cmd(archiver, "create", "test", "input", "-C", f"{cname},{clevel}")
|
||||
check_compression(ctype, clevel, olevel)
|
||||
|
||||
cname, ctype, clevel, olevel = ZSTD.name, ZSTD.ID, 1, -1 # change compressor (and level)
|
||||
cmd(archiver, "rcompress", "-C", f"{cname},{clevel}")
|
||||
cmd(archiver, "repo-compress", "-C", f"{cname},{clevel}")
|
||||
check_compression(ctype, clevel, olevel)
|
||||
|
||||
cname, ctype, clevel, olevel = ZSTD.name, ZSTD.ID, 3, -1 # only change level
|
||||
cmd(archiver, "rcompress", "-C", f"{cname},{clevel}")
|
||||
cmd(archiver, "repo-compress", "-C", f"{cname},{clevel}")
|
||||
check_compression(ctype, clevel, olevel)
|
||||
|
||||
cname, ctype, clevel, olevel = ZSTD.name, ZSTD.ID, 3, 110 # only change to obfuscated
|
||||
cmd(archiver, "rcompress", "-C", f"obfuscate,{olevel},{cname},{clevel}")
|
||||
cmd(archiver, "repo-compress", "-C", f"obfuscate,{olevel},{cname},{clevel}")
|
||||
check_compression(ctype, clevel, olevel)
|
||||
|
||||
cname, ctype, clevel, olevel = ZSTD.name, ZSTD.ID, 3, 112 # only change obfuscation level
|
||||
cmd(archiver, "rcompress", "-C", f"obfuscate,{olevel},{cname},{clevel}")
|
||||
cmd(archiver, "repo-compress", "-C", f"obfuscate,{olevel},{cname},{clevel}")
|
||||
check_compression(ctype, clevel, olevel)
|
||||
|
||||
cname, ctype, clevel, olevel = ZSTD.name, ZSTD.ID, 3, -1 # change to not obfuscated
|
||||
cmd(archiver, "rcompress", "-C", f"{cname},{clevel}")
|
||||
cmd(archiver, "repo-compress", "-C", f"{cname},{clevel}")
|
||||
check_compression(ctype, clevel, olevel)
|
||||
|
||||
cname, ctype, clevel, olevel = ZLIB.name, ZLIB.ID, 1, -1
|
||||
cmd(archiver, "rcompress", "-C", f"auto,{cname},{clevel}")
|
||||
cmd(archiver, "repo-compress", "-C", f"auto,{cname},{clevel}")
|
||||
check_compression(ctype, clevel, olevel)
|
||||
|
||||
cname, ctype, clevel, olevel = ZLIB.name, ZLIB.ID, 2, 111
|
||||
cmd(archiver, "rcompress", "-C", f"obfuscate,{olevel},auto,{cname},{clevel}")
|
||||
cmd(archiver, "repo-compress", "-C", f"obfuscate,{olevel},auto,{cname},{clevel}")
|
||||
check_compression(ctype, clevel, olevel)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_rcreate_interrupt(archivers, request):
|
||||
def test_repo_create_interrupt(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
if archiver.EXE:
|
||||
pytest.skip("patches object")
|
||||
|
@ -21,32 +21,32 @@ def raise_eof(*args, **kwargs):
|
|||
|
||||
with patch.object(FlexiKey, "create", raise_eof):
|
||||
if archiver.FORK_DEFAULT:
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION, exit_code=2)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION, exit_code=2)
|
||||
else:
|
||||
with pytest.raises(CancelledByUser):
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
|
||||
assert not os.path.exists(archiver.repository_location)
|
||||
|
||||
|
||||
def test_rcreate_requires_encryption_option(archivers, request):
|
||||
def test_repo_create_requires_encryption_option(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", exit_code=2)
|
||||
cmd(archiver, "repo-create", exit_code=2)
|
||||
|
||||
|
||||
def test_rcreate_refuse_to_overwrite_keyfile(archivers, request, monkeypatch):
|
||||
# BORG_KEY_FILE=something borg rcreate should quit if "something" already exists.
|
||||
def test_repo_create_refuse_to_overwrite_keyfile(archivers, request, monkeypatch):
|
||||
# BORG_KEY_FILE=something borg repo-create should quit if "something" already exists.
|
||||
# See: https://github.com/borgbackup/borg/pull/6046
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
keyfile = os.path.join(archiver.tmpdir, "keyfile")
|
||||
monkeypatch.setenv("BORG_KEY_FILE", keyfile)
|
||||
original_location = archiver.repository_location
|
||||
archiver.repository_location = original_location + "0"
|
||||
cmd(archiver, "rcreate", KF_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", KF_ENCRYPTION)
|
||||
with open(keyfile) as file:
|
||||
before = file.read()
|
||||
archiver.repository_location = original_location + "1"
|
||||
arg = ("rcreate", KF_ENCRYPTION)
|
||||
arg = ("repo-create", KF_ENCRYPTION)
|
||||
if archiver.FORK_DEFAULT:
|
||||
cmd(archiver, *arg, exit_code=2)
|
||||
else:
|
||||
|
|
|
@ -13,18 +13,18 @@ def test_delete_repo(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
create_regular_file(archiver.input_path, "dir2/file2", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
cmd(archiver, "create", "test.2", "input")
|
||||
os.environ["BORG_DELETE_I_KNOW_WHAT_I_AM_DOING"] = "no"
|
||||
if archiver.FORK_DEFAULT:
|
||||
expected_ec = CancelledByUser().exit_code
|
||||
cmd(archiver, "rdelete", exit_code=expected_ec)
|
||||
cmd(archiver, "repo-delete", exit_code=expected_ec)
|
||||
else:
|
||||
with pytest.raises(CancelledByUser):
|
||||
cmd(archiver, "rdelete")
|
||||
cmd(archiver, "repo-delete")
|
||||
assert os.path.exists(archiver.repository_path)
|
||||
os.environ["BORG_DELETE_I_KNOW_WHAT_I_AM_DOING"] = "YES"
|
||||
cmd(archiver, "rdelete")
|
||||
cmd(archiver, "repo-delete")
|
||||
# Make sure the repo is gone
|
||||
assert not os.path.exists(archiver.repository_path)
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
def test_info(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
info_repo = cmd(archiver, "rinfo")
|
||||
info_repo = cmd(archiver, "repo-info")
|
||||
assert "Repository ID:" in info_repo
|
||||
|
||||
|
||||
def test_info_json(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
|
||||
info_repo = json.loads(cmd(archiver, "rinfo", "--json"))
|
||||
info_repo = json.loads(cmd(archiver, "repo-info", "--json"))
|
||||
repository = info_repo["repository"]
|
||||
assert len(repository["id"]) == 64
|
||||
assert "last_modified" in repository
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_rlist_glob(archivers, request):
|
||||
def test_repo_list_glob(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test-1", src_dir)
|
||||
cmd(archiver, "create", "something-else-than-test-1", src_dir)
|
||||
cmd(archiver, "create", "test-2", src_dir)
|
||||
output = cmd(archiver, "rlist", "--match-archives=sh:test-*")
|
||||
output = cmd(archiver, "repo-list", "--match-archives=sh:test-*")
|
||||
assert "test-1" in output
|
||||
assert "test-2" in output
|
||||
assert "something-else" not in output
|
||||
|
@ -21,28 +21,28 @@ def test_rlist_glob(archivers, request):
|
|||
|
||||
def test_archives_format(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "--comment", "comment 1", "test-1", src_dir)
|
||||
cmd(archiver, "create", "--comment", "comment 2", "test-2", src_dir)
|
||||
output_1 = cmd(archiver, "rlist")
|
||||
output_2 = cmd(archiver, "rlist", "--format", "{archive:<36} {time} [{id}]{NL}")
|
||||
output_1 = cmd(archiver, "repo-list")
|
||||
output_2 = cmd(archiver, "repo-list", "--format", "{archive:<36} {time} [{id}]{NL}")
|
||||
assert output_1 == output_2
|
||||
output_1 = cmd(archiver, "rlist", "--short")
|
||||
output_1 = cmd(archiver, "repo-list", "--short")
|
||||
assert output_1 == "test-1" + os.linesep + "test-2" + os.linesep
|
||||
output_3 = cmd(archiver, "rlist", "--format", "{name} {comment}{NL}")
|
||||
output_3 = cmd(archiver, "repo-list", "--format", "{name} {comment}{NL}")
|
||||
assert "test-1 comment 1" + os.linesep in output_3
|
||||
assert "test-2 comment 2" + os.linesep in output_3
|
||||
|
||||
|
||||
def test_size_nfiles(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
create_regular_file(archiver.input_path, "file1", size=123000)
|
||||
create_regular_file(archiver.input_path, "file2", size=456)
|
||||
cmd(archiver, "create", "test", "input/file1", "input/file2")
|
||||
output = cmd(archiver, "list", "test")
|
||||
print(output)
|
||||
output = cmd(archiver, "rlist", "--format", "{name} {nfiles} {size}")
|
||||
output = cmd(archiver, "repo-list", "--format", "{name} {nfiles} {size}")
|
||||
o_t = output.split()
|
||||
assert o_t[0] == "test"
|
||||
assert int(o_t[1]) == 2
|
||||
|
@ -51,41 +51,41 @@ def test_size_nfiles(archivers, request):
|
|||
|
||||
def test_date_matching(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
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)
|
||||
create_src_archive(archiver, "archive2", ts=ts_in_between)
|
||||
create_src_archive(archiver, "archive3")
|
||||
cmd(archiver, "rlist", "-v", "--oldest=23e", exit_code=2)
|
||||
cmd(archiver, "repo-list", "-v", "--oldest=23e", exit_code=2)
|
||||
|
||||
output = cmd(archiver, "rlist", "-v", "--oldest=1m", exit_code=0)
|
||||
output = cmd(archiver, "repo-list", "-v", "--oldest=1m", exit_code=0)
|
||||
assert "archive1" in output
|
||||
assert "archive2" in output
|
||||
assert "archive3" not in output
|
||||
|
||||
output = cmd(archiver, "rlist", "-v", "--newest=1m", exit_code=0)
|
||||
output = cmd(archiver, "repo-list", "-v", "--newest=1m", exit_code=0)
|
||||
assert "archive3" in output
|
||||
assert "archive2" not in output
|
||||
assert "archive1" not in output
|
||||
|
||||
output = cmd(archiver, "rlist", "-v", "--newer=1d", exit_code=0)
|
||||
output = cmd(archiver, "repo-list", "-v", "--newer=1d", exit_code=0)
|
||||
assert "archive3" in output
|
||||
assert "archive1" not in output
|
||||
assert "archive2" not in output
|
||||
|
||||
output = cmd(archiver, "rlist", "-v", "--older=1d", exit_code=0)
|
||||
output = cmd(archiver, "repo-list", "-v", "--older=1d", exit_code=0)
|
||||
assert "archive1" in output
|
||||
assert "archive2" in output
|
||||
assert "archive3" not in output
|
||||
|
||||
|
||||
def test_rlist_json(archivers, request):
|
||||
def test_repo_list_json(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_regular_file(archiver.input_path, "file1", size=1024 * 80)
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
list_repo = json.loads(cmd(archiver, "rlist", "--json"))
|
||||
list_repo = json.loads(cmd(archiver, "repo-list", "--json"))
|
||||
repository = list_repo["repository"]
|
||||
assert len(repository["id"]) == 64
|
||||
checkts(repository["last_modified"])
|
||||
|
|
|
@ -9,7 +9,7 @@ def test_return_codes(cmd_fixture, tmpdir):
|
|||
input = tmpdir.mkdir("input")
|
||||
output = tmpdir.mkdir("output")
|
||||
input.join("test_file").write("content")
|
||||
rc, out = cmd_fixture("--repo=%s" % str(repo), "rcreate", "--encryption=none")
|
||||
rc, out = cmd_fixture("--repo=%s" % str(repo), "repo-create", "--encryption=none")
|
||||
assert rc == EXIT_SUCCESS
|
||||
rc, out = cmd_fixture("--repo=%s" % repo, "create", "archive", str(input))
|
||||
assert rc == EXIT_SUCCESS
|
||||
|
|
|
@ -35,15 +35,17 @@ def test_with_socket(serve_socket, tmpdir, monkeypatch):
|
|||
have_a_short_runtime_dir(monkeypatch)
|
||||
repo_path = str(tmpdir.join("repo"))
|
||||
|
||||
ret, output = exec_cmd(f"--socket={serve_socket}", f"--repo=socket://{repo_path}", "rcreate", "--encryption=none")
|
||||
ret, output = exec_cmd(
|
||||
f"--socket={serve_socket}", f"--repo=socket://{repo_path}", "repo-create", "--encryption=none"
|
||||
)
|
||||
assert ret == 0
|
||||
|
||||
ret, output = exec_cmd(f"--socket={serve_socket}", f"--repo=socket://{repo_path}", "rinfo")
|
||||
ret, output = exec_cmd(f"--socket={serve_socket}", f"--repo=socket://{repo_path}", "repo-info")
|
||||
assert ret == 0
|
||||
assert "Repository ID: " in output
|
||||
|
||||
monkeypatch.setenv("BORG_DELETE_I_KNOW_WHAT_I_AM_DOING", "YES")
|
||||
ret, output = exec_cmd(f"--socket={serve_socket}", f"--repo=socket://{repo_path}", "rdelete")
|
||||
ret, output = exec_cmd(f"--socket={serve_socket}", f"--repo=socket://{repo_path}", "repo-delete")
|
||||
assert ret == 0
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ def test_export_tar(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
os.unlink("input/flagfile")
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
cmd(archiver, "export-tar", "test", "simple.tar", "--progress", "--tar-format=GNU")
|
||||
with changedir("output"):
|
||||
|
@ -44,7 +44,7 @@ def test_export_tar_gz(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
os.unlink("input/flagfile")
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
test_list = cmd(archiver, "export-tar", "test", "simple.tar.gz", "--list", "--tar-format=GNU")
|
||||
assert "input/file1\n" in test_list
|
||||
|
@ -60,7 +60,7 @@ def test_export_tar_strip_components(archivers, request):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
os.unlink("input/flagfile")
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "test", "input")
|
||||
test_list = cmd(archiver, "export-tar", "test", "simple.tar", "--strip-components=1", "--list", "--tar-format=GNU")
|
||||
# --list's path are those before processing with --strip-components
|
||||
|
@ -103,7 +103,7 @@ def test_import_tar(archivers, request, tar_format="PAX"):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path, create_hardlinks=False) # hardlinks become separate files
|
||||
os.unlink("input/flagfile")
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
cmd(archiver, "create", "src", "input")
|
||||
cmd(archiver, "export-tar", "src", "simple.tar", f"--tar-format={tar_format}")
|
||||
cmd(archiver, "import-tar", "dst", "simple.tar")
|
||||
|
@ -122,7 +122,7 @@ def test_import_unusual_tar(archivers, request):
|
|||
# ./foo//bar
|
||||
# ./
|
||||
tar_archive = os.path.join(os.path.dirname(__file__), "unusual_paths.tar")
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
cmd(archiver, "import-tar", "dst", tar_archive)
|
||||
files = cmd(archiver, "list", "dst", "--format", "{path}{NL}").splitlines()
|
||||
assert set(files) == {"foobar", "bar", "foo2", "foo/bar", "."}
|
||||
|
@ -136,7 +136,7 @@ def test_import_tar_with_dotdot(archivers, request):
|
|||
# Contains this file:
|
||||
# ../../../../etc/shadow
|
||||
tar_archive = os.path.join(os.path.dirname(__file__), "dotdot_path.tar")
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
with pytest.raises(ValueError, match="unexpected '..' element in path '../../../../etc/shadow'"):
|
||||
cmd(archiver, "import-tar", "dst", tar_archive, exit_code=2)
|
||||
|
||||
|
@ -146,7 +146,7 @@ def test_import_tar_gz(archivers, request, tar_format="GNU"):
|
|||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path, create_hardlinks=False) # hardlinks become separate files
|
||||
os.unlink("input/flagfile")
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
cmd(archiver, "create", "src", "input")
|
||||
cmd(archiver, "export-tar", "src", "simple.tgz", f"--tar-format={tar_format}")
|
||||
cmd(archiver, "import-tar", "dst", "simple.tgz")
|
||||
|
@ -174,7 +174,7 @@ def test_import_concatenated_tar_with_ignore_zeros(archivers, request):
|
|||
# Clean up for assert_dirs_equal.
|
||||
os.unlink("the_rest.tar")
|
||||
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
cmd(archiver, "import-tar", "--ignore-zeros", "dst", "input/concatenated.tar")
|
||||
# Clean up for assert_dirs_equal.
|
||||
os.unlink("input/concatenated.tar")
|
||||
|
@ -199,7 +199,7 @@ def test_import_concatenated_tar_without_ignore_zeros(archivers, request):
|
|||
with open("the_rest.tar", "rb") as the_rest:
|
||||
concatenated.write(the_rest.read())
|
||||
os.unlink("the_rest.tar")
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
cmd(archiver, "import-tar", "dst", "input/concatenated.tar")
|
||||
|
||||
with changedir(archiver.output_path):
|
||||
|
@ -212,7 +212,7 @@ def test_import_concatenated_tar_without_ignore_zeros(archivers, request):
|
|||
def test_roundtrip_pax_borg(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
create_test_files(archiver.input_path)
|
||||
cmd(archiver, "rcreate", "--encryption=none")
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
cmd(archiver, "create", "src", "input")
|
||||
cmd(archiver, "export-tar", "src", "simple.tar", "--tar-format=BORG")
|
||||
cmd(archiver, "import-tar", "dst", "simple.tar")
|
||||
|
|
|
@ -18,7 +18,7 @@ def test_transfer(archivers, request):
|
|||
original_location, input_path = archiver.repository_location, archiver.input_path
|
||||
|
||||
def check_repo():
|
||||
listing = cmd(archiver, "rlist", "--short")
|
||||
listing = cmd(archiver, "repo-list", "--short")
|
||||
assert "arch1" in listing
|
||||
assert "arch2" in listing
|
||||
listing = cmd(archiver, "list", "--short", "arch1")
|
||||
|
@ -29,14 +29,14 @@ def check_repo():
|
|||
create_test_files(input_path)
|
||||
archiver.repository_location = original_location + "1"
|
||||
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION)
|
||||
cmd(archiver, "create", "arch1", "input")
|
||||
cmd(archiver, "create", "arch2", "input")
|
||||
check_repo()
|
||||
|
||||
archiver.repository_location = original_location + "2"
|
||||
other_repo1 = f"--other-repo={original_location}1"
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION, other_repo1)
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION, other_repo1)
|
||||
cmd(archiver, "transfer", other_repo1, "--dry-run")
|
||||
cmd(archiver, "transfer", other_repo1)
|
||||
cmd(archiver, "transfer", other_repo1, "--dry-run")
|
||||
|
@ -75,12 +75,12 @@ def convert_tz(local_naive, tzoffset, tzinfo):
|
|||
assert os.environ.get("BORG_PASSPHRASE") == "waytooeasyonlyfortests"
|
||||
os.environ["BORG_TESTONLY_WEAKEN_KDF"] = "0" # must use the strong kdf here or it can't decrypt the key
|
||||
|
||||
cmd(archiver, "rcreate", RK_ENCRYPTION, other_repo1, "--from-borg1")
|
||||
cmd(archiver, "repo-create", RK_ENCRYPTION, other_repo1, "--from-borg1")
|
||||
cmd(archiver, "transfer", other_repo1, "--from-borg1")
|
||||
cmd(archiver, "check")
|
||||
|
||||
# check list of archives / manifest
|
||||
rlist_json = cmd(archiver, "rlist", "--json")
|
||||
rlist_json = cmd(archiver, "repo-list", "--json")
|
||||
got = json.loads(rlist_json)
|
||||
with open(os.path.join(dst_dir, "test_meta", "repo_list.json")) as f:
|
||||
expected = json.load(f)
|
||||
|
|
|
@ -29,7 +29,7 @@ def repo_url(request, tmpdir, monkeypatch):
|
|||
|
||||
@pytest.fixture(params=["none", "repokey-aes-ocb"])
|
||||
def repo(request, cmd_fixture, repo_url):
|
||||
cmd_fixture(f"--repo={repo_url}", "rcreate", "--encryption", request.param)
|
||||
cmd_fixture(f"--repo={repo_url}", "repo-create", "--encryption", request.param)
|
||||
return repo_url
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue