5
0
mirror of git://git.proxmox.com/git/proxmox-backup.git synced 2025-01-06 13:18:00 +03:00
Commit Graph

7909 Commits

Author SHA1 Message Date
Christian Ebner
46951c103b api: sync: move sync job invocation to server sync module
Moves and refactores the sync_job_do function into the common server
sync module so that it can be reused for both sync directions, pull
and push.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
e898887f54 api: push: implement endpoint for sync in push direction
Expose the sync job in push direction via a dedicated API endpoint,
analogous to the pull direction.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
bcd80bf976 api types/config: add sync-push config type for push sync jobs
In order for sync jobs to be either pull or push jobs, allow to
configure the direction of the job.

Adds an additional config type `sync-push` to the sync job config, to
clearly distinguish sync jobs configured in pull and in push
direction and defines and implements the required `SyncDirection` api
type.

This approach was chosen in order to limit possible misconfiguration,
as unintentionally switching the sync direction could potentially
delete still required snapshots.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
33737196b1 fix #3044: server: implement push support for sync operations
Adds the functionality required to push datastore contents from a
source to a remote target.
This includes syncing of the namespaces, backup groups and snapshots
based on the provided filters as well as removing vanished contents
from the target when requested.

While trying to mimic the pull direction of sync jobs, the
implementation is different as access to the remote must be performed
via the REST API, not needed for the pull job which can access the
local datastore via the filesystem directly.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
a926803b92 api/api-types: refactor api endpoint version, add api types
Add a dedicated api type for the `version` api endpoint and helper
methods for supported feature comparison.
This will be used to detect api incompatibility of older hosts, not
supporting some features.

Use the new api type to refactor the version endpoint and set it as
return type.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
0be5b147d5 datastore: increment deleted group counter when removing group
To correctly account also for the number of deleted backup groups, in
preparation to correctly return the delete statistics when removing
contents via the REST API.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
f982c915f5 api types: implement api type for BackupGroupDeleteStats
Make the `BackupGroupDeleteStats` exposable via the API by implementing
the ApiTypes trait via the api macro invocation and add an additional
field to account for the number of deleted groups.
Further, add a method to add up the statistics.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
d1e5e4533c datastore: move BackupGroupDeleteStats to api types
In preparation for the delete stats to be exposed as return type to
the backup group delete api endpoint.

Also, rename the private field `unremoved_protected` to a better
fitting `protected_snapshots` to be in line with the method names.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
db4f1f64b6 api types: define remote permissions and roles for push sync
Adding the privileges to allow backup, namespace creation and prune
on remote targets, to be used for sync jobs in push direction.

Also adds dedicated roles setting the required privileges.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
da0fd4267a api types: implement remote acl path method for sync job
Add `remote_acl_path` method which generates the acl path from the sync
job configuration. This helper allows to easily generate the acl path
from a given sync job config for privilege checks.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
ae56a50b9d api types: add remote acl path method for BackupNamespace
Add a `remote_acl_path` helper method for creating acl paths for
remote namespaces, to be used by the priv checks on remote datastore
namespaces for e.g. the sync job in push direction.

Factor out the common path extension into a dedicated method.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
aa273905d7 config: acl: allow namespace components for remote datastores
Extend the component limit for ACL paths of `remote` to include
possible namespace components.

This allows to limit the permissions for sync jobs in push direction
to a namespace subset on the remote datastore.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
732d9d7a5f config: acl: refactor acl path component check for datastore
Combine the two if statements checking the datastores ACL path
components, which can be represented more concisely as one.

Further, extend the pre-existing comment to clarify that `datastore`
ACL paths are not limited to the datastore name, but might have
further sub-components specifying the namespace.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
a5e3032d36 client: backup writer: allow push uploading index and chunks
Add a method `upload_index_chunk_info` to be used for uploading an
existing index and the corresponding chunk stream.
Instead of taking an input stream of raw bytes as the
`upload_stream`, this takes a stream of `MergedChunkInfo` object
provided by the local chunk reader of the sync jobs source.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
008b38bfc7 client: backup writer: factor out merged chunk stream upload
In preparation for implementing push support for sync jobs.

Factor out the upload stream for merged chunks, which can be reused
to upload the local chunks to a remote target datastore during a
snapshot sync operation in push direction.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
9fbe870d1c client: backup writer: refactor backup and upload stats counters
In preparation for push support in sync jobs.

Extend and move `BackupStats` into `backup_stats` submodule and add
method to create them from `UploadStats`.

Further, introduce `UploadCounters` struct to hold the Arc clones of
the chunk upload statistics counters, simplifying the house keeping.

By bundling the counters into the struct, they can be passed as
single function parameter when factoring out the common stream future
in the subsequent implementation of the chunk upload for sync jobs
in push direction.

Co-developed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
c6648d59c6 sync: extend sync source's list namespaces method by filter callback
Allow to filter namespaces by given callback function. This will be
used to pre-filter the list of namespaces to push to a remote target
for sync jobs in push direction, based on the privs of the sync jobs
local user on the source datastore.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:53 +01:00
Christian Ebner
19a621ab98 sync: pull: optimize backup group sorting
`BackupGroup` implements `cmp::Ord`, so use that implementation for
comparing groups during sorting. Furtuher, only sort the list of
backup groups after filtering, thereby possibly reducing the number
of required comparisons.

No functional changes.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-21 10:14:10 +01:00
Thomas Lamprecht
72fe4cdb79 bump version to 3.2.10-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-19 22:36:44 +01:00
Thomas Lamprecht
73b18b279d cargo: require proxmox-log 0.2.6
To ensure the fix for avoiding printing verbose log levels to stderr,
stdout is included, as that spams the log with the full worker log
tasks.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-19 11:40:06 +01:00
Thomas Lamprecht
4983a3c0ba api: disk list: do not fail but just log error on gathering smart data
I plugged in a USB pen drive and the whole disk list UI became
completely unusable because smartctl fails to handle that device due
to some `Unknown USB bridge [0x090c:0x1000 (0x1100)]` error.

That itself might be improvable, but most often I do not care at all
about smart data, and certainly not enough to make failing gathering
it disallow me from viewing my disks (or the smart data from disks
where it still could be gathered, for that matter!)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-17 20:33:22 +01:00
Hannes Laimer
936ec6b69e disks: add UUID to partition info
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
2024-11-17 20:28:09 +01:00
Dietmar Maurer
01bbaef7fa config: factor out method to get the absolute datastore path
removable datastores will have a PBS-managed mountpoint as path, direct
access to the field needs to be replaced with a helper that can account
for this.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
2024-11-17 19:57:33 +01:00
Hannes Laimer
9ab2e4e710 tools: add disks utility functions
... for mounting and unmounting

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
2024-11-17 19:57:33 +01:00
Thomas Lamprecht
79db26d316 bump version to 3.2.9-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-14 16:40:46 +01:00
Dominik Csapak
2febc83cc0 fix #5233: don't require root for some tape operations
instead, require 'Tape.Write' or 'Tape.Modify' on '/tape' path.
This makes it possible for a TapeOperator to destroy tapes and for a
TapeAdmin to update the tape status, instead of just root@pam.

I opted for the path '/tape' since we don't have a dedicated acl
structure for single tapes, just '/tape/pool' (which does not apply
since not all tapes have to have a pool), '/tape/device' (which is
intended for drives/changers) and '/tape/jobs' (which is for jobs only).

Also we use that path for e.g. move_tape already.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-11-14 15:17:31 +01:00
Thomas Lamprecht
b3675d867f fix #5868: workspace: require rest-server >= 0.8.2
To ensure the recent fixes for the "infinite loop on early connection
abort when trying to detect the TLS handshake" problem is included.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-14 15:15:38 +01:00
Christian Ebner
76504bfcac client: pxar: add debug output for exclude pattern matches
Log the path of directory entries matched by an exclude pattern in
order to more conveniently debug possible issues.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-12 21:23:42 +01:00
Christian Ebner
7465ccd097 client: pxar: perform match pattern check only once
While traversing the filesystem tree, `generate_directory_file_list`
generates the list of entries to include for each directory level,
already matching the entry against the given list of match patterns.

Since this already excludes entries which should not be included in
the archive, the same check in the `add_entry` call is redundant,
as it is executed for each entry which is included in the list
generated by `generate_directory_file_list`.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-12 21:23:39 +01:00
Daniel Kral
974b4527e2 fix #5600: pbs2to3: allow arbitrary newer '-pve' kernels after upgrade
Fixes a bug where `pbs2to3` shows an incorrect warning about an
unexpected running kernel version, where newer kernel versions than 6.5
were marked as unexpected (e.g. "8.6.12-1-pve").

This commit allows arbitrary newer kernel versions that are suffixed
with '-pve' from kernel version 6.2 onward. This is the same behavior as
in other upgrade helpers like `pve7to8` [1] and `pmg7to8` [2].

[1] https://git.proxmox.com/?p=pve-manager.git;a=commit;h=fb59038a8b110b0b0b438ec035fd41dd9d591232
[2] https://git.proxmox.com/?p=pmg-api.git;a=commit;h=9d67a9af218b73027822c9c4665b88e6662e7ef7

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2024-11-12 21:19:22 +01:00
Daniel Kral
65574209ad pbs2to3: add test for kernel version compatibility
Factors the kernel version compatibility check into its own method and
adds test cases for a set of expected and unexpected kernel versions.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2024-11-12 21:19:22 +01:00
Gabriel Goller
1a0229b881 api: parallelize smartctl checks
To improve the performance of the smartctl checks, especially when a lot
of disks are used, parallelize the checks using the `ParallelHandler`.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-11-12 21:17:24 +01:00
Gabriel Goller
b3d9b6d5f1 api: avoid retrieving lsblk result twice
Avoid running `lsblk` twice when executing the `list_disk`
endpoint/command. This and the various other small nits improve the
performance of the endpoint.

Does not really fix, but is related to: #4961.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-11-12 21:17:24 +01:00
Christian Ebner
da82aca849 client: catalog shell: avoid navigating below archive root
Avoid to underflow the catalogs shell position stack by navigating
below the archives root directory into the catalog root. Otherwise
the shell will panic, as the root entry is always expected to be
present.

This threats the archive root directory as being it's own parent
directory, mimicking the behaviour of most common shells.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-12 21:08:27 +01:00
Hannes Laimer
7f193b88ed api: tape: add permission to move_tape endpoint
... so it is usable by non-root users, this came up in support.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
2024-11-12 13:55:15 +01:00
Thomas Lamprecht
720bf707e8 update proxmox-notify crate to 0.5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-11 23:55:25 +01:00
Gabriel Goller
f2ea424cc1 web: disallow datastore in root, add reuse-datastore flag
Disallows creating a datastore in root on the frontend side, by
filtering the '/' path. Add reuse-flag to permit us to open existing
datastores.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-11-11 23:51:06 +01:00
Gabriel Goller
6e101ff757 fix #5439: allow to reuse existing datastore
Disallow creating datastores in non-empty directories. Allow adding
existing datastores via a 'reuse-datastore' checkmark. This only checks
if all the necessary directories (.chunks + subdirectories and .lock)
exist and have the correct permissions. Note that the reuse-datastore
path does not open the datastore, so that we don't drop the
ProcessLocker of an existing datastore.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-11-11 23:51:06 +01:00
Gabriel Goller
27811f3f8f fix #5861: remove min username length in ChangeOwner modal
We allow usernames shorter than 4 characters since this patch [0] in
pbs.

[0]: https://lore.proxmox.com/pbs-devel/20240117142918.264978-1-g.goller@proxmox.com/

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-11-11 11:08:15 +01:00
Wolfgang Bumiller
6391a45b43 bump rest-server to 0.8.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-11-08 12:07:00 +01:00
Christoph Heiss
667797ce2e d/control: bump proxmox-subscription to 0.5
Seems this was forgotten while bumping it in Cargo.toml in dcd863e0.

Fixes: dcd863e0 ("bump proxmox-subscription to 0.5.0")
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-08 10:58:48 +01:00
Dietmar Maurer
dcd863e0c9 bump proxmox-subscription to 0.5.0
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-11-07 14:09:15 +01:00
Fabian Grünbichler
faa08f6564 sync: pull: reword last_sync_time resync comment
make it a bit easier to parse and include some examples of what the resync
might be able to pick up.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-11-04 15:13:37 +01:00
Christian Ebner
868ca01a7a sync: pull: simplify logic for source snapshot filtering
Decouple the actual filter logic from the skip reason output logic by
pulling the latter out of the filter closue.

Makes the filtering logic more intuitive.

Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-04 14:45:43 +01:00
Christian Ebner
b752b8cb96 sync: pull: mention why last snapshot of previous sync is resynced
The last snapshot synced during the previous sync job might not have
been fully completed just yet (e.g. backup log still missing,
verification still ongoing, ...).
Explicitley mention the reason and that the resync is therefore
intentional by a comment in the filter logic.

Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-04 14:45:43 +01:00
Christian Ebner
1e36930e0b sync: fix premature return in snapshot skip filter logic
While checking which snapshots to sync, the filter logic incorrectly
included the first snapshot newer that the last synced one
unconditionally, bypassing the transfer last check for that one
snapshot. Following snapshots are correctly handled again.

E.g. of an incorrect sync by excerpt of a task log provided by a user
in the community forum [0], with transfer last set to 1:

```
skipped: 2 snapshot(s) (2024-09-29T18:00:28Z .. 2024-10-20T18:00:29Z) - older than the newest local snapshot
skipped: 5 snapshot(s) (2024-10-28T19:00:28Z .. 2024-11-01T19:00:32Z) - due to transfer-last
sync snapshot vm/110/2024-10-27T19:00:25Z
...
sync snapshot vm/110/2024-11-02T19:00:23Z
```

Not only the last, but the first newer than newest and last were
incorrectly synced.

By dropping the early return, leading to incorrect inclusion of the
snapshot, the transfer last condition is now correctly checked as
well.

Link to the issue reported in the community forum:
[0] https://forum.proxmox.com/threads/156873/

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-11-04 13:03:15 +01:00
Christian Ebner
59243d200e client: catalog shell: drop payload offset in stat output
Drop the payload offset output for the multi line formatting helper,
as the formatting was skewed anyways and the `stat` output is not
intended for debugging.

Commit 51e8fa96 ("client: pxar: include payload offset in entry
listing") introduced the payload offset output for pxar entries
in case of split archives for both, single line and multi line
formatting helpers with debugging prupose.

While the payload offset output is fine for the single line entry
formatting (generates the pxar dump output in debugging mode),
it should not be included in the multi line entry formatting helper,
used to generate the output for the `stat` command of the catalog
shell.

Fixes: 51e8fa96 ("client: pxar: include payload offset in entry listing")

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-10-25 14:22:32 +02:00
Fabian Grünbichler
dd16eabe19 pxar: tools: inline async recursion
this works since rustc 1.77, and makes the code less verbose.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-10-23 16:10:41 +02:00
Christian Ebner
5ddd59e167 client: catalog shell: fallback to accessor for navigation
Make the catalog optional and use the pxar accessor for navigation if
the catalog is not provided.
This allows to use the metadata archive for navigraion, as for split
pxar archives no dedicated catalog is encoded.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2024-10-23 16:10:41 +02:00
Christian Ebner
78e4098eae client: helper to mimic catalog find using metadata archive
Adds helper functions to reimplement the catalog shell functionality
for snapshots being encoded as split pxar archives.

Just as the `CatalogReader`s find method, recursively iterate entries
and call the given callback on all entries matched by the match
patterns, starting from the given parent entry.

The helper has been split into 2 functions for the async recursion to
work.
2024-10-23 16:10:41 +02:00