Skip to content

vss: remove dependency on live system during backup#1452

Merged
pstorz merged 89 commits intobareos:masterfrom
sebsura:dev/ssura/master/get-meta-information-from-vss
Jun 27, 2023
Merged

vss: remove dependency on live system during backup#1452
pstorz merged 89 commits intobareos:masterfrom
sebsura:dev/ssura/master/get-meta-information-from-vss

Conversation

@sebsura
Copy link
Contributor

@sebsura sebsura commented Apr 24, 2023

Thank you for contributing to the Bareos Project!

Sometimes bareos messes up and does not use the correct vss paths to backup data. This PR identifies those situations and fixes them.

This PR also:

  • better supports backups with volume mount points,
  • removes old comments from the windows installer,
  • enables autocomplete for VolStatus = disabled in the update command,
  • changed how st_ctime is calculated on windows,
  • removes support for pre-vista vss clients (bareos did not support those systems for some time now), and
  • made some strides in refactoring the compat layer

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Check backport line
  • Required backport PRs have been created
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
Tests
  • Decision taken that a test is required (if not, then remove this paragraph)
  • The choice of the type of test (unit test or systemtest) is reasonable
  • Testname matches exactly what is being tested
  • On a fail, output of the test leads quickly to the origin of the fault

@sebsura sebsura marked this pull request as draft April 24, 2023 05:07
@sebsura sebsura added the draft label Apr 24, 2023
@sebsura sebsura force-pushed the dev/ssura/master/get-meta-information-from-vss branch from 6cc8923 to 74aa9fd Compare April 25, 2023 08:37
@sebsura sebsura changed the title Remove dependency on live system during backup vss: remove dependency on live system during backup Apr 25, 2023
@sebsura sebsura force-pushed the dev/ssura/master/get-meta-information-from-vss branch from 6a5bb83 to dd3fda9 Compare April 27, 2023 13:56
@sebsura sebsura force-pushed the dev/ssura/master/get-meta-information-from-vss branch 3 times, most recently from e749558 to dabf1bf Compare May 12, 2023 06:42
@sebsura sebsura added the onhold label May 26, 2023
@sebsura sebsura removed the onhold label Jun 6, 2023
@sebsura sebsura force-pushed the dev/ssura/master/get-meta-information-from-vss branch from 26b5a8e to ac89b51 Compare June 6, 2023 06:31
@sebsura sebsura force-pushed the dev/ssura/master/get-meta-information-from-vss branch 2 times, most recently from db7eb0a to 025ee2b Compare June 19, 2023 08:09
@sebsura sebsura removed the draft label Jun 21, 2023
@sebsura sebsura marked this pull request as ready for review June 21, 2023 13:17
@bruno-at-bareos bruno-at-bareos requested a review from pstorz June 22, 2023 09:42
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!

Code looks much cleaner now!

Please fix the following commit comment typos:


880c28c203db8a131d1d9925163cdc29b546198f
-> WaitAndChcekForAsyncOperation
             ^

4ae9c1fb01206055336824516b548f200a406c76
-> We new just use a static object
       ^

4810f67178f4e4352a0ee825c2cba732cb9fec7f
-> Since we gi#e the functions an explicit
              ^

@sebsura sebsura force-pushed the dev/ssura/master/get-meta-information-from-vss branch from 1f60fec to 2c29bd3 Compare June 26, 2023 12:51
@sebsura sebsura requested a review from pstorz June 27, 2023 04:40
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!

@pstorz pstorz force-pushed the dev/ssura/master/get-meta-information-from-vss branch from 2c29bd3 to 505ec79 Compare June 27, 2023 12:09
sebsura added 8 commits June 27, 2023 14:10
Currently we are reading the attributes from the live system.  This
will cause issues if the file is deleted or busy and inaccurate
results if the file was touched in the mean time.
There is zero reason for this variable to exist at all let alone to be
thread specific.  It literally only contains two function pointers
that are always the same and no thread specific data.
For now, if no thread specific variable was set up,
we just return a global variable if it was set up.

This should enable non-main-threads to "interact" with the vss client;
i.e. look up drive -> vss drive translations (which are readonly!).
Currently we only translate filepaths to vss filepaths if we are
compiled without unicode support.  This changes this to be always the
case.
sebsura and others added 27 commits June 27, 2023 14:10
Since our char -> wchar functions cache their results we need to
ensure that
  1) we do not use the same path twice in the same tests after another
  since then we would only test our cache; and
  2) we clear the cache between test runs
1) has to be done manually but 2) can be done by clearing the cache in
the TearDown() of the fixture.  This works because gtest does not
reuse fixtures for tests but instead recreates them for every test.
We should not remove slashes that are preceded by a colon since there
is a big difference for windows between "C:" and "C:\\", "C:/".
We now just use a static object.  The initialization is guaranteed to
be thread safe and will happen on the first call to
InitializeComSecurity().  This slightly changes behaviour: we now do
not retry whenever the previous call failed; since the only way for
InitializeComSecurity() to fail is for the system to run out of
memory (according to the documenentation), this should not be a
concern.
Since strncat can write up to n+1 bytes (n bytes from src + null
terminator), we need to ensure that dest can hold up to that many
bytes!
Another issue is that strcpy may not leave the buffer with a zero
terminator.  To ensure that this is always the case now we just use
strncat twice!
Since codecvt is deprecated since C++17 it was replaced with
FromUtf8/FromUtf16.
Also fix some related comments
Before we used the following schema:

if (use_fallback)
  st_ctime = CreationTime
else
  st_ctime = max(CreationTime, ChangeTime)

We now use this instead to bring it more inline with how its done on
unix-like systems:

if (use_fallback)
  st_ctime = LastWriteTime
else
  st_ctime = ChangeTime
We want to remove trailing slashes _before_ we convert them to vss
paths!
@pstorz pstorz force-pushed the dev/ssura/master/get-meta-information-from-vss branch from 5e59261 to 84c308e Compare June 27, 2023 12:10
@pstorz pstorz merged commit 5cfe96f into bareos:master Jun 27, 2023
@rickmoua
Copy link

rickmoua commented Jan 18, 2024

We are getting this error, it doesn't do to all windows systems but some systems we get this error. " JobId 18896: Fatal error: VSS was not initialized properly." We are using the agent BareOS 21.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments