Skip to content
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

feat(backend)!: Add backend to config and use rustic_backend #977

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

simonsan
Copy link
Contributor

@simonsan simonsan commented Dec 31, 2023

BREAKING CHANGE:

  • Config structure changes

TODO:

  • how to deal with copy in a good way
  • decide on toml table names and structure, I would prefer it as storage and parse the provider, as in here:
- # Backend options: These options define which backend to use.
- [backend]
- repository = "/tmp/repo"
+ # Storage options: These options define which backend to use.
+ [storage]
+ provider = local
+ path = "/tmp/repo"

@simonsan simonsan added A-docs Area: Improvements or additions to documentation A-backends Area: Related to backends in `rustic-core` M-breaking Meta: Breaking change C-refactor Category: Refactoring of already existing code A-config Area: Related to the config file functionality and format labels Dec 31, 2023
src/commands/key.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
@@ -63,6 +64,7 @@ log = { workspace = true }
# serialization
serde = { workspace = true }
serde_json = { workspace = true }
serde_path_to_error = { workspace = true }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: Nice, but didn't really get it to work, could be nice for user facing errors though regarding misconfiguration.

@@ -115,6 +122,8 @@ anyhow = "1"
serde = { version = "1", features = ["serde_derive"] }
serde_with = { version = "3.4", features = ["base64"] }
serde_json = "1"
serde_path_to_error = "0.1.14"
toml_edit = { version = "0.21.0", features = ["serde"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: remove, we have toml and toml_edit here, we only need the high-level crate (toml) for what we currently do.

@simonsan simonsan force-pushed the backend-config branch 2 times, most recently from 69e1941 to 199b6f0 Compare January 1, 2024 08:52
Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>

refactor: commands now use the new backend struct from rustic_backend

Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>

refactor: change config files and implement test to parse all config files with new settings for rustic_backend

Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>

fix: typo

Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>

style: dprint fmt

Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>

testing: use result

Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
Comment on lines 26 to 34
[[copy]]
# Second copy target
[copy.options]
password-file = "/root/key-rustic-ovh"
cache-dir = "/var/lib/cache/rustic" # explicitly specify cache dir for remote repository

[copy.backend]
repository = "rclone|ovh:backup"
repo-hot = "rclone|ovh:backup-hot"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@aawsome I think the naming is a bit off now, so we need to check what is best.

copy.options is essentially copy.repository.options.

Also it may be confusing to have [[copy]] twice, which is the right thing IMHO, because it is an array of backends in the ends, but maybe we can find a different approach, now that we may need to have a breaking change in the config?

config/full.toml Outdated
Comment on lines 24 to 41
# Repository options: These options define which backend to use and which password to use.
[repository]
# Backend options: These options define which backend to use.
[backend]
repository = "/repo/rustic" # Must be set
repo-hot = "/my/hot/repo" # Default: not set
# one of the three password options must be set

# Additional backend options - depending on backend. These can be only set in the config file.
[backend.options]
post-create-command = "par2create -qq -n1 -r5 %file" # Only local backend; Default: not set
post-delete-command = "sh -c \"rm -f %file*.par2\"" # Only local backend; Default: not set
retry = "default" # Only rest/rclone backend; Allowed values: "false"/"off", "default" or number of retries
timeout = "10min" # Only rest/rclone backend

# Repository options: These options define which repository settings and passwords to use.
[repository]
# Optional, but one of the three password options must be set
# either on CLI, in the config file or in environment variables
password = "mySecretPassword"
password-file = "/my/password.txt"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also don't really like the differentiation now:

[backend]
repository = ""
repo-hot = ""

[backend.options]
[repository]

Maybe we find some better naming there which makes it more clear?

Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
Comment on lines 1 to 3
# Backend options: These options define which backend to use.
[backend]
repository = "/tmp/repo"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
# Backend options: These options define which backend to use.
[backend]
repository = "/tmp/repo"
# Storage options: These options define which backend to use.
[storage]
provider = local
path = "/tmp/repo"

@simonsan simonsan marked this pull request as draft January 28, 2024 17:11
@simonsan simonsan mentioned this pull request Feb 3, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backends Area: Related to backends in `rustic-core` A-config Area: Related to the config file functionality and format A-docs Area: Improvements or additions to documentation C-refactor Category: Refactoring of already existing code M-breaking Meta: Breaking change
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

None yet

2 participants