Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we drop the destination file if backup was not successful? #29

Closed
ghost opened this issue Nov 13, 2023 · 3 comments
Closed

Should we drop the destination file if backup was not successful? #29

ghost opened this issue Nov 13, 2023 · 3 comments
Labels
question Further information is requested

Comments

@ghost
Copy link

ghost commented Nov 13, 2023

When adding support for new systems, I also test the negative paths: for example, what happens if the HashiCorp Vault token doesn't have the required permissions or isn't valid at all.

During these tests, due to my oversight in changing the path, I often get an error message saying that the target file already exists.

This brings up the question of whether the destination file should be deleted if the backup process fails. In my opinion, there is no reason to keep it, but I am open to other suggestions.

@ghost ghost added the question Further information is requested label Nov 13, 2023
@a-mesin
Copy link
Member

a-mesin commented Nov 13, 2023

I am for deleting it. It will most probably be malformed or even empty anyways.

@iabudiab
Copy link
Member

I would say, let the user decide.
IMHO, delete-per-default is usually a bad idea. If someone configures the wrong destination unintentionally, then we wouldn't want to delete it without asking 😉

@ghost
Copy link
Author

ghost commented Nov 14, 2023

Three points:

  • We should not allow writing to the destination (folder, file) if it already exists. An error should be thrown after preparation (already the case).
  • I would only remove the file if there was an error while doing the copy AND when there were 0 bytes copied. 0 bytes, because if we consider a plain text backup (e.g. copying a .txt file), even partial backups can be utilized for restoration purposes. We could also add an config flag in advance to avoid the deletion in case of an error (something like noDestinationCleanupOnError = true).
  • And we should also do in the source preparation a validation if the source is accessible. It makes no sense to prepare the destination, if the source is not accessible (this will solve my issue already 😅)
    • In case of filesystem: Can we read from the file/folder (file/folder permissions)? Is there something to backup (file size)?
    • In case of an other system: Doing a ping command to check if system is reachable and if the auth creds are correct.

At the moment our process looks like the following:

  1. Source preparation: In case of the filesystem we open the file (for streaming)
  2. Destination preparation: In case of the filesystem we check if file/folder already exists (if yes we throw an error), we create the file and open it
  3. Do the copy (streaming from source file into the destination file)

Now I would add to the 1th step a accessibility check and a 4th step regarding the cleanup (I think this will be needed in the future anyway to):

  1. Clean up
    • close files/connections
    • remove destination file in case of error and 0 bytes copied

WDYT about these points?

@ghost ghost locked and limited conversation to collaborators Nov 14, 2023
@ghost ghost converted this issue into discussion #30 Nov 14, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants