From 1683847e53514f5197e71a814e150fea59e6025d Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Fri, 29 Dec 2023 09:01:13 +0100 Subject: [PATCH 01/11] feat(config): add backend options to config 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> --- Cargo.lock | 1020 ++++++++++++++++++++++++++++++++++---- Cargo.toml | 27 +- config/README.md | 58 ++- config/copy_example.toml | 21 +- config/full.toml | 33 +- config/local.toml | 4 +- config/ovh-hot-cold.toml | 4 +- config/par2.toml | 8 +- config/rustic.toml | 4 +- config/simple.toml | 4 +- src/commands.rs | 5 +- src/commands/backup.rs | 5 +- src/commands/copy.rs | 29 +- src/commands/init.rs | 3 +- src/commands/key.rs | 8 +- src/commands/repoinfo.rs | 4 +- src/config.rs | 9 +- tests/config.rs | 30 +- 18 files changed, 1084 insertions(+), 192 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d828cbef0..9b39c7647 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,12 +196,52 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" +[[package]] +name = "async-compat" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f68a707c1feb095d8c07f8a65b9f506b117d30af431cab89374357de7c11461b" +dependencies = [ + "futures-core", + "futures-io", + "once_cell", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "async-trait" +version = "0.1.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "awaitable" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70af449c9a763cb655c6a1e5338b42d99c67190824ff90658c1e30be844c0775" +dependencies = [ + "awaitable-error", + "cfg-if 1.0.0", +] + +[[package]] +name = "awaitable-error" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5b3469636cdf8543cceab175efca534471f36eee12fb8374aba00eb5e7e7f8a" + [[package]] name = "backoff" version = "0.4.0" @@ -213,6 +253,18 @@ dependencies = [ "rand", ] +[[package]] +name = "backon" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1a6197b2120bb2185a267f6515038558b019e92b832bb0320e96d66268dcf9" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "pin-project", + "tokio", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -242,9 +294,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "binrw" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a1b8720bedc0a503fd5c90bef3fbdc397144ac7efcc5610b30bde08083d7495" +checksum = "173901312e9850391d4d7c1318c4e099fdc037d61870fca427429830efdb4e5f" dependencies = [ "array-init", "binrw_derive", @@ -253,9 +305,9 @@ dependencies = [ [[package]] name = "binrw_derive" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0741a1b1a70a36a1e7fb0316bba0828f6487a3b6e577353cf974b59fbbb92081" +checksum = "cb515fdd6f8d3a357c8e19b8ec59ef53880807864329b1cb1cba5c53bf76557e" dependencies = [ "either", "owo-colors", @@ -307,6 +359,12 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.5.0" @@ -353,9 +411,9 @@ checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" [[package]] name = "cachedir" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e236bf5873ea57ec2877445297f4da008916bfae51567131acfc54a073d694f3" +checksum = "4703f3937077db8fa35bee3c8789343c1aec2585f0146f09d658d4ccc0e8d873" dependencies = [ "tempfile", ] @@ -395,8 +453,10 @@ checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-targets 0.48.5", ] @@ -412,9 +472,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.8" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d" dependencies = [ "clap_builder", "clap_derive", @@ -422,9 +482,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.8" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" dependencies = [ "anstream", "anstyle", @@ -491,6 +551,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "concurrent_arena" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c529c2d4ecc249ae15d317c9a8b9e7d86f87e80d4417de6cfa8f4d6030f37daf" +dependencies = [ + "arc-swap", + "parking_lot", + "triomphe", +] + [[package]] name = "console" version = "0.15.7" @@ -586,9 +657,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -630,9 +701,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" dependencies = [ "cfg-if 1.0.0", ] @@ -789,6 +860,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] @@ -813,6 +885,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_destructure2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac4b68190bad25c00b64ea19767b2321a037fc0e5bea7563d5d8e35e04b19c95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -864,6 +947,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", "subtle", ] @@ -921,6 +1005,15 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "dlv-list" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] + [[package]] name = "duct" version = "0.13.6" @@ -986,18 +1079,18 @@ dependencies = [ [[package]] name = "enum-map" -version = "2.7.1" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed40247825a1a0393b91b51d475ea1063a6cbbf0847592e7f13fb427aca6a716" +checksum = "6866f3bfdf8207509a033af1a75a7b08abda06bbaaeae6669323fd5a097df2e9" dependencies = [ "enum-map-derive", ] [[package]] name = "enum-map-derive" -version = "0.15.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7933cd46e720348d29ed1493f89df9792563f272f96d8f13d18afe03b32f8cb8" +checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", @@ -1053,16 +1146,22 @@ checksum = "f69037fe1b785e84986b4f2cbcf647381876a00671d25ceef715d7812dd7e1dd" [[package]] name = "filetime" -version = "0.2.22" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.3.5", - "windows-sys 0.48.0", + "redox_syscall", + "windows-sys 0.52.0", ] +[[package]] +name = "flagset" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a7e408202050813e6f1d9addadcaafef3dca7530c7ddfb005d4081cce6779" + [[package]] name = "flate2" version = "1.0.28" @@ -1081,9 +1180,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1103,6 +1202,21 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" +[[package]] +name = "futures" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.29" @@ -1110,6 +1224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -1118,6 +1233,17 @@ version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +[[package]] +name = "futures-executor" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.29" @@ -1147,12 +1273,19 @@ version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + [[package]] name = "futures-util" version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ + "futures-channel", "futures-core", "futures-io", "futures-macro", @@ -1191,8 +1324,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if 1.0.0", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -1209,15 +1344,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", "bstr", - "fnv", "log", - "regex", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -1281,6 +1416,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "http" version = "0.2.11" @@ -1390,9 +1534,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1400,17 +1544,16 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +checksum = "747ad1b4ae841a78e8aba0d63adbfbeaea26b517b63705d47856b73015d27060" dependencies = [ + "crossbeam-deque", "globset", - "lazy_static", "log", "memchr", - "regex", + "regex-automata 0.4.3", "same-file", - "thread_local", "walkdir", "winapi-util", ] @@ -1465,6 +1608,21 @@ dependencies = [ "generic-array", ] +[[package]] +name = "insta" +version = "1.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d64600be34b2fcfc267740a243fa7744441bb4947a619ac4e5bb6507f35fbfc" +dependencies = [ + "console", + "lazy_static", + "linked-hash-map", + "serde", + "similar", + "toml 0.5.11", + "yaml-rust", +] + [[package]] name = "instant" version = "0.1.12" @@ -1489,15 +1647,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" -[[package]] -name = "itertools" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.12.0" @@ -1553,11 +1702,29 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "9.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7ea04a7c5c055c175f189b6dc6ba036fd62306b58c66c9f6389036c503a3f4" +dependencies = [ + "base64", + "js-sys", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] [[package]] name = "libc" @@ -1565,6 +1732,12 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "libmimalloc-sys" version = "0.1.35" @@ -1583,9 +1756,15 @@ checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ "bitflags 2.4.1", "libc", - "redox_syscall 0.4.1", + "redox_syscall", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.11" @@ -1617,6 +1796,16 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if 1.0.0", + "digest", +] + [[package]] name = "memchr" version = "2.6.4" @@ -1710,6 +1899,66 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.17" @@ -1717,6 +1966,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -1755,9 +2005,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -1766,35 +2016,174 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "option-ext" -version = "0.2.0" +name = "opendal" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +checksum = "c04ac25bc94e2b572a0f41bcc650cb39dd09255efce72b68eb5dc188b018c52a" +dependencies = [ + "anyhow", + "async-compat", + "async-trait", + "backon", + "base64", + "bytes", + "chrono", + "dirs", + "flagset", + "futures", + "http", + "log", + "md-5", + "once_cell", + "openssh", + "openssh-sftp-client", + "parking_lot", + "percent-encoding", + "pin-project", + "quick-xml 0.30.0", + "reqsign", + "reqwest", + "serde", + "serde_json", + "sha2", + "tokio", + "uuid", +] [[package]] -name = "os_pipe" -version = "1.1.4" +name = "openssh" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" +checksum = "8274f2bf1fc3785406a3ff07c92c15590c00e84efb883da77b671562ca9a6115" dependencies = [ + "dirs", "libc", - "windows-sys 0.48.0", + "once_cell", + "shell-escape", + "tempfile", + "thiserror", + "tokio", + "tokio-pipe", ] [[package]] -name = "overload" -version = "0.1.1" +name = "openssh-sftp-client" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +checksum = "5111bd8df89c0c7e64bf815710cafb05eff787f82e335244035ba685cf829b47" +dependencies = [ + "bytes", + "derive_destructure2", + "futures-core", + "once_cell", + "openssh", + "openssh-sftp-client-lowlevel", + "openssh-sftp-error", + "pin-project", + "scopeguard", + "tokio", + "tokio-io-utility", + "tokio-util", + "tracing", +] [[package]] -name = "owo-colors" +name = "openssh-sftp-client-lowlevel" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a84f1a52761901fcf5b10885544085348a872e57294531ec9188145d9a83042" +dependencies = [ + "awaitable", + "bytes", + "concurrent_arena", + "derive_destructure2", + "openssh-sftp-error", + "openssh-sftp-protocol", + "pin-project", + "tokio", + "tokio-io-utility", +] + +[[package]] +name = "openssh-sftp-error" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a5aea093d714df10186f481a6003e3f906f6fc8360c026737a841f4f182996" +dependencies = [ + "awaitable-error", + "openssh", + "openssh-sftp-protocol-error", + "ssh_format_error", + "thiserror", + "tokio", +] + +[[package]] +name = "openssh-sftp-protocol" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf38532d784978966f95d241226223823f351d5bb2a4bebcf6b20b9cb1e393e0" +dependencies = [ + "bitflags 2.4.1", + "num-derive", + "num-traits", + "openssh-sftp-protocol-error", + "serde", + "ssh_format", + "vec-strings", +] + +[[package]] +name = "openssh-sftp-protocol-error" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0719269eb3f037866ae07ec89cb44ed2c1d63b72b2390cef8e1aa3016a956ff8" +dependencies = [ + "serde", + "thiserror", + "vec-strings", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "ordered-multimap" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4d6a8c22fc714f0c2373e6091bf6f5e9b37b1bc0b1184874b7e0a4e303d318f" +dependencies = [ + "dlv-list", + "hashbrown 0.14.2", +] + +[[package]] +name = "os_pipe" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "owo-colors" version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" @@ -1828,7 +2217,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.4.1", + "redox_syscall", "smallvec", "windows-targets 0.48.5", ] @@ -1852,11 +2241,50 @@ dependencies = [ "hmac", ] +[[package]] +name = "pem" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" +dependencies = [ + "base64", + "serde", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] [[package]] name = "pin-project-lite" @@ -1870,6 +2298,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + [[package]] name = "pkcs8" version = "0.10.2" @@ -1973,6 +2412,26 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quick-xml" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" version = "1.0.33" @@ -2032,15 +2491,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -2105,11 +2555,49 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "relative-path" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" + +[[package]] +name = "reqsign" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce87f66ba6c6acef277a729f989a0eca946cb9ce6a15bcc036bda0f72d4b9fd" +dependencies = [ + "anyhow", + "async-trait", + "base64", + "chrono", + "form_urlencoded", + "getrandom", + "hex", + "hmac", + "home", + "http", + "jsonwebtoken", + "log", + "once_cell", + "percent-encoding", + "quick-xml 0.31.0", + "rand", + "reqwest", + "rsa", + "rust-ini", + "serde", + "serde_json", + "sha1", + "sha2", + "tokio", +] + [[package]] name = "reqwest" -version = "0.11.22" +version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ "base64", "bytes", @@ -2185,11 +2673,70 @@ dependencies = [ "cc", "getrandom", "libc", - "spin", + "spin 0.9.8", "untrusted", "windows-sys 0.48.0", ] +[[package]] +name = "rsa" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ef35bf3e7fe15a53c4ab08a998e42271eab13eb0db224126bc7bc4c4bad96d" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rstest" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97eeab2f3c0a199bc4be135c36c924b6590b88c377d416494288c14f2db30199" +dependencies = [ + "futures", + "futures-timer", + "rstest_macros", + "rustc_version", +] + +[[package]] +name = "rstest_macros" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d428f8247852f894ee1be110b375111b586d4fa431f6c46e64ba5a0dcccbe605" +dependencies = [ + "cfg-if 1.0.0", + "glob", + "proc-macro2", + "quote", + "regex", + "relative-path", + "rustc_version", + "syn 2.0.39", + "unicode-ident", +] + +[[package]] +name = "rust-ini" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0698206bcb8882bf2a9ecb4c1e7785db57ff052297085a6efd4fe42302068a" +dependencies = [ + "cfg-if 1.0.0", + "ordered-multimap", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2223,7 +2770,8 @@ dependencies = [ "gethostname", "humantime", "indicatif", - "itertools 0.12.0", + "insta", + "itertools", "jemallocator-global", "libc", "log", @@ -2232,27 +2780,71 @@ dependencies = [ "once_cell", "pretty_assertions", "rhai", + "rstest", + "rustic_backend", "rustic_core", "rustic_testing", "self_update", "semver", "serde", "serde_json", + "serde_path_to_error", "serde_with", "simplelog", "tempfile", "thiserror", "toml 0.8.8", + "toml_edit", +] + +[[package]] +name = "rustic_backend" +version = "0.1.0" +dependencies = [ + "aho-corasick", + "anyhow", + "backoff", + "binrw", + "bytes", + "cached", + "clap", + "derive_setters", + "displaydoc", + "filetime", + "hex", + "humantime", + "ignore", + "itertools", + "log", + "merge", + "nix", + "once_cell", + "opendal", + "rand", + "rayon", + "reqwest", + "rustic_core", + "serde", + "serde-aux", + "serde_derive", + "serde_json", + "serde_with", + "shell-words", + "strum", + "strum_macros", + "thiserror", + "tokio", + "url", + "walkdir", ] [[package]] name = "rustic_core" version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5932066f9e144fc15043c4e0b9a82bfa16c83910243318bdafbb38496c1518a" dependencies = [ "aes256ctr_poly1305aes", "aho-corasick", + "anyhow", "backoff", "binrw", "bytes", @@ -2277,10 +2869,11 @@ dependencies = [ "humantime", "ignore", "integer-sqrt", - "itertools 0.11.0", + "itertools", "log", "merge", "nix", + "opendal", "pariter", "path-dedot", "rand", @@ -2487,7 +3080,7 @@ dependencies = [ "hyper", "indicatif", "log", - "quick-xml", + "quick-xml 0.23.1", "regex", "reqwest", "self-replace", @@ -2510,18 +3103,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde-aux" -version = "4.2.0" +version = "4.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3dfe1b7eb6f9dcf011bd6fad169cdeaae75eda0d61b1a99a3f015b41b0cae39" +checksum = "184eba62ebddb71658697c8b08822edee89970bf318c5362189f0de27f85b498" dependencies = [ "chrono", "serde", @@ -2530,9 +3123,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -2550,6 +3143,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +dependencies = [ + "itoa", + "serde", +] + [[package]] name = "serde_spanned" version = "0.6.4" @@ -2600,6 +3203,17 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest", +] + [[package]] name = "sha2" version = "0.10.8" @@ -2640,12 +3254,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "shell-escape" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" + [[package]] name = "shell-words" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "signature" version = "2.0.0" @@ -2653,6 +3282,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fe458c98333f9c8152221191a77e2a44e8325d0193484af2e9421a53019e57d" dependencies = [ "digest", + "rand_core", +] + +[[package]] +name = "similar" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" + +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", ] [[package]] @@ -2716,6 +3364,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "spin" version = "0.9.8" @@ -2732,6 +3386,32 @@ dependencies = [ "der", ] +[[package]] +name = "ssh_format" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24ab31081d1c9097c327ec23550858cb5ffb4af6b866c1ef4d728455f01f3304" +dependencies = [ + "bytes", + "serde", + "ssh_format_error", +] + +[[package]] +name = "ssh_format_error" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be3c6519de7ca611f71ef7e8a56eb57aa1c818fecb5242d0a0f39c83776c210c" +dependencies = [ + "serde", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -2843,7 +3523,7 @@ checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if 1.0.0", "fastrand 2.0.1", - "redox_syscall 0.4.1", + "redox_syscall", "rustix", "windows-sys 0.48.0", ] @@ -2867,20 +3547,26 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "thin-vec" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" + [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "83a48fd946b02c0a526b2e9481c8e2a17755e47039164a86c4070446e3a4614d" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3" dependencies = [ "proc-macro2", "quote", @@ -2964,10 +3650,43 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", + "signal-hook-registry", "socket2 0.5.5", + "tokio-macros", "windows-sys 0.48.0", ] +[[package]] +name = "tokio-io-utility" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d672654d175710e52c7c41f6aec77c62b3c0954e2a7ebce9049d1e94ed7c263" +dependencies = [ + "bytes", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tokio-pipe" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f213a84bffbd61b8fa0ba8a044b4bbe35d471d0b518867181e82bd5c15542784" +dependencies = [ + "libc", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" @@ -3007,6 +3726,7 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -3113,6 +3833,17 @@ dependencies = [ "tracing-log 0.2.0", ] +[[package]] +name = "triomphe" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +dependencies = [ + "arc-swap", + "serde", + "stable_deref_trait", +] + [[package]] name = "try-lock" version = "0.2.4" @@ -3176,9 +3907,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -3197,12 +3928,32 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +dependencies = [ + "getrandom", + "serde", +] + [[package]] name = "valuable" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vec-strings" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8509489e2a7ee219522238ad45fd370bec6808811ac15ac6b07453804e77659" +dependencies = [ + "serde", + "thin-vec", +] + [[package]] name = "version_check" version = "0.9.4" @@ -3396,6 +4147,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -3426,6 +4186,21 @@ dependencies = [ "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -3438,6 +4213,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -3450,6 +4231,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -3462,6 +4249,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -3474,6 +4267,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -3486,6 +4285,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -3498,6 +4303,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -3510,6 +4321,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winnow" version = "0.5.19" @@ -3550,6 +4367,15 @@ dependencies = [ "glob", ] +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "yansi" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index cc8a8a6e8..39d79c754 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,7 @@ rustdoc-args = ["--document-private-items", "--generate-link-to-definition"] [dependencies] abscissa_core = { workspace = true } +rustic_backend = { workspace = true } rustic_core = { workspace = true } # errors @@ -63,6 +64,7 @@ log = { workspace = true } # serialization serde = { workspace = true } serde_json = { workspace = true } +serde_path_to_error = { workspace = true } serde_with = { workspace = true } # other dependencies @@ -84,7 +86,7 @@ humantime = { workspace = true } indicatif = { workspace = true } itertools = { workspace = true } jemallocator-global = { version = "0.3.2", optional = true } -mimalloc = { version = "0.1.39", default_features = false, optional = true } +mimalloc = { version = "0.1.39", default-features = false, optional = true } rhai = { workspace = true } simplelog = { workspace = true } @@ -92,17 +94,25 @@ simplelog = { workspace = true } abscissa_core = { workspace = true, features = ["testing"] } aho-corasick = { workspace = true } dircmp = { workspace = true } +insta = { version = "1.34.0", features = ["toml"] } once_cell = { workspace = true } pretty_assertions = { workspace = true } +rstest = { workspace = true } rustic_testing = { path = "crates/rustic_testing" } tempfile = { workspace = true } -toml = { workspace = true } +toml = { workspace = true, features = ["parse", "preserve_order"] } +toml_edit = { workspace = true, features = ["serde"] } [target.'cfg(not(windows))'.dependencies] libc = "0.2.150" [workspace.dependencies] -rustic_core = { version = "0.1.2", features = ["cli"] } -abscissa_core = { version = "0.7.0", default-features = false, features = ["application"] } +rustic_core = { path = "../rustic_core/crates/core", version = "0.1.2", features = ["cli"] } +rustic_backend = { path = "../rustic_core/crates/backends", version = "0.1.0", features = ["cli"] } +# rustic_core = { version = "0.1.2", features = ["cli"] } + +abscissa_core = { version = "0.7.0", default-features = false, features = [ + "application", +] } # logging log = "0.4" @@ -116,6 +126,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"] } # other dependencies aho-corasick = "1.1.2" @@ -145,7 +157,7 @@ quickcheck = "1" quickcheck_macros = "1" tempfile = "3.8" pretty_assertions = "1.4" -toml = "0.8" +toml = { version = "0.8", features = ["parse", "preserve_order"] } dircmp = "0.2" # cargo-binstall support @@ -200,6 +212,11 @@ lto = true debug-assertions = false codegen-units = 1 +# Faster insta testing runs +[profile.dev.package] +insta = { opt-level = 3 } +similar = { opt-level = 3 } + # Allows quick RPM file generation, if "cargo-generate-rpm" is installed: # cargo build --release; cargo generate-rpm # will result in a file like target/generate-rpm/rustic-rs-0.6.1-1.x86_64.rpm diff --git a/config/README.md b/config/README.md index 7790f4c1f..aa7b162bd 100644 --- a/config/README.md +++ b/config/README.md @@ -64,14 +64,26 @@ rustic. config file as a possible source of errors if you encounter problems. They could possibly shadow other values that you have already set. +### Backend Options + +| Attribute | Description | Default Value | Example Value | Environment Variable | +| ---------- | ------------------------------------- | ------------- | ------------- | -------------------- | +| repository | The path to the repository. Required. | Not set | "/tmp/rustic" | RUSTIC_REPOSITORY | +| repo-hot | The path to the hot repository. | Not set | | RUSTIC_REPO_HOT | + +### Backend Options (Additional) + +| Attribute | Description | Default Value | Example Value | +| ------------------- | ---------------------------------------------------------------------- | ------------- | ------------------------------ | +| post-create-command | Command to execute after creating a snapshot in the **local backend**. | Not set | "par2create -qq -n1 -r5 %file" | +| post-delete-command | Command to execute after deleting a snapshot in the **local backend**. | Not set | "sh -c \"rm -f %file*.par2\"" | + ### Repository Options | Attribute | Description | Default Value | Example Value | Environment Variable | | ---------------- | ---------------------------------------------------------- | ------------------------ | ---------------------- | ----------------------- | | cache-dir | Path to the cache directory. | ~/.cache/rustic/$REPO_ID | ~/.cache/my_own_cache/ | RUSTIC_CACHE_DIR | | no-cache | If true, disables caching. | false | | RUSTIC_NO_CACHE | -| repository | The path to the repository. Required. | Not set | "/tmp/rustic" | RUSTIC_REPOSITORY | -| repo-hot | The path to the hot repository. | Not set | | RUSTIC_REPO_HOT | | password | The password for the repository. | Not set | "mySecretPassword" | RUSTIC_PASSWORD | | password-file | Path to a file containing the password for the repository. | Not set | | RUSTIC_PASSWORD_FILE | | password-command | Command to retrieve the password for the repository. | Not set | | RUSTIC_PASSWORD_COMMAND | @@ -79,13 +91,6 @@ possibly shadow other values that you have already set. | warm-up-command | Command to warm up the repository. | Not set | | | | warm-up-wait | The wait time for warming up the repository. | Not set | | | -### Repository Options (Additional) - -| Attribute | Description | Default Value | Example Value | -| ------------------- | ------------------------------------------------------------------ | ------------- | ------------------------------ | -| post-create-command | Command to execute after creating a snapshot in the local backend. | Not set | "par2create -qq -n1 -r5 %file" | -| post-delete-command | Command to execute after deleting a snapshot in the local backend. | Not set | "sh -c \"rm -f %file*.par2\"" | - ### Snapshot-Filter Options | Attribute | Description | Default Value | Example Value | @@ -160,17 +165,24 @@ source-individual section. **Note**: Copy-targets are simply repositories with the same defaults as within the repository section. -| Attribute | Description | Default Value | Example Value | -| ------------------- | ---------------------------------------------------------------------- | ------------------------ | ---------------------- | -| cache-dir | Path to the cache directory for the target repository. | ~/.cache/rustic/$REPO_ID | ~/.cache/my_own_cache/ | -| no-cache | If true, disables caching for the target repository. | false | | -| password | The password for the target repository. | Not set | | -| password-file | Path to a file containing the password for the target repository. | Not set | | -| password-command | Command to retrieve the password for the target repository. | Not set | | -| post-create-command | Command to execute after creating a snapshot in the target repository. | Not set | | -| post-delete-command | Command to execute after deleting a snapshot in the target repository. | Not set | | -| repository | The path or URL to the target repository. | Not set | | -| repo-hot | The path or URL to the hot target repository. | Not set | | -| warm-up | If true, warms up the target repository by file access. | Not set | | -| warm-up-command | Command to warm up the target repository. | Not set | | -| warm-up-wait | The wait time for warming up the target repository. | Not set | | +#### Copy Target Backends + +| Attribute | Description | Default Value | Example Value | +| ------------------- | ---------------------------------------------------------------------- | ------------- | ------------------------------ | +| repository | The path or URL to the target repository. | Not set | | +| repo-hot | The path or URL to the hot target repository. | Not set | | +| post-create-command | Command to execute after creating a snapshot in the **local backend**. | Not set | "par2create -qq -n1 -r5 %file" | +| post-delete-command | Command to execute after deleting a snapshot in the **local backend**. | Not set | "sh -c \"rm -f %file*.par2\"" | + +#### Copy Target Options + +| Attribute | Description | Default Value | Example Value | +| ---------------- | ----------------------------------------------------------------- | ------------------------ | ---------------------- | +| cache-dir | Path to the cache directory for the target repository. | ~/.cache/rustic/$REPO_ID | ~/.cache/my_own_cache/ | +| no-cache | If true, disables caching for the target repository. | false | | +| password | The password for the target repository. | Not set | | +| password-file | Path to a file containing the password for the target repository. | Not set | | +| password-command | Command to retrieve the password for the target repository. | Not set | | +| warm-up | If true, warms up the target repository by file access. | Not set | | +| warm-up-command | Command to warm up the target repository. | Not set | | +| warm-up-wait | The wait time for warming up the target repository. | Not set | | diff --git a/config/copy_example.toml b/config/copy_example.toml index 1e7e67df1..f7c571a48 100644 --- a/config/copy_example.toml +++ b/config/copy_example.toml @@ -4,18 +4,27 @@ # See "rustic copy --help" for options how to select or filter snapshots to copy. # [repository] specified the source repository -[repository] +[backend] repository = "/tmp/repo" + +# [repository] specified the source repository +[repository] password = "test" # you can specify multiple targets -[[copy.targets]] -repository = "/tmp/repo2" +[[copy]] +[[copy.options]] password = "test" no-cache = true -[[copy.targets]] -repository = "rclone:ovh:backup" -repo-hot = "clone:ovh:backup-hot" +[[copy.backend]] +repository = "/tmp/repo2" + +[[copy]] +[[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" diff --git a/config/full.toml b/config/full.toml index c28ca65ec..21ab96631 100644 --- a/config/full.toml +++ b/config/full.toml @@ -21,10 +21,20 @@ dry-run = false # This is only an example how to set an rclone env variable. Default: No variables are defined. RCLONE_XXX = "true" -# Repository options: These options define which backend to use and which password to use. -[repository] +# Backend options: These options define which backend to use and which password to use. +[backend] repository = "/repo/rustic" # Must be set repo-hot = "/my/hot/repo" # Default: not 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] # one of the three password options must be set password = "mySecretPassword" password-file = "/my/password.txt" @@ -36,13 +46,6 @@ warm-up = false warm-up-command = "warmup.sh %id" # Default: not set warm-up-wait = "10min" # Default: not set -# Additional repository options - depending on backend. These can be only set in the config file. -[repository.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 - # Snapshot-filter options: These options apply to all commands that use snapshot filters [snapshot-filter] filter-host = ["host2", "host2"] # Default: no host filter @@ -150,9 +153,8 @@ keep-within-yearly = "10 years" # Multiple targets are available for the copy command. Each specify a repository with exactly identical options as in # the [repository] section. -[[copy.targets]] -repository = "/repo/rustic" # Must be set -repo-hot = "/my/hot/repo" # Default: not set +[[copy]] +[[copy.options]] # one of the three password options must be set password = "mySecretPassword" password-file = "/my/password.txt" @@ -164,6 +166,11 @@ warm-up = false warm-up-command = "warmup.sh %id" # Default: not set warm-up-wait = "10min" # Default: not set -[[copy.targets]] +[[copy.backend]] +repository = "/repo/rustic" # Must be set +repo-hot = "/my/hot/repo" # Default: not set + +[[copy]] +[[copy.backend]] repository = "/repo/rustic2" # Must be set # ... diff --git a/config/local.toml b/config/local.toml index 9b378e821..a119ea813 100644 --- a/config/local.toml +++ b/config/local.toml @@ -3,8 +3,10 @@ # backup usage: "rustic -P local backup # cleanup: "rustic -P local forget --prune # -[repository] +[backend] repository = "/backup/rustic" + +[repository] password-file = "/root/key-rustic" no-cache = true # no cache needed for local repository diff --git a/config/ovh-hot-cold.toml b/config/ovh-hot-cold.toml index ee490b0d1..03db4caa6 100644 --- a/config/ovh-hot-cold.toml +++ b/config/ovh-hot-cold.toml @@ -4,9 +4,11 @@ # backup usage: "rustic -P ovh-hot-cold backup # cleanup: "rustic -P ovh-hot-cold forget --prune # -[repository] +[backend] repository = "rclone:ovh:backup-home" repo-hot = "rclone:ovh:backup-home-hot" + +[repository] password-file = "/root/key-rustic-ovh" cache-dir = "/var/lib/cache/rustic" # explicitly specify cache dir for remote repository warm-up = true # cold storage needs warm-up, just trying to access a file is sufficient to start the warm-up diff --git a/config/par2.toml b/config/par2.toml index 55ad07cb5..4f9f5948b 100644 --- a/config/par2.toml +++ b/config/par2.toml @@ -2,14 +2,16 @@ # error correction files using par2create to a local repository. # The commands can use the variable %file, %type and %id which are replaced by the filename, the # file type and the file id before calling the command. -[repository] +[backend] repository = "/tmp/repo" -password = "test" -[repository.options] +[backend.options] # after saving a file in the repo, this command is called post-create-command = "par2create -qq -n1 -r5 %file" # after removing a file from the repo, this command is called. # Note that we want to use a "*" in the rm command, hence we have to call sh to resolve the wildcard! post-delete-command = "sh -c \"rm -f %file*.par2\"" + +[repository] +password = "test" diff --git a/config/rustic.toml b/config/rustic.toml index 850821984..b5e6acc0e 100644 --- a/config/rustic.toml +++ b/config/rustic.toml @@ -10,9 +10,11 @@ log-level = "debug" log-file = "/log/rustic.log" +[backend] +repository = "/tmp/rustic" + # repository options: These options define which backend to use and which password to use. [repository] -repository = "/tmp/rustic" password = "mySecretPassword" # snapshot-filter options: These options apply to all commands that use snapshot filters diff --git a/config/simple.toml b/config/simple.toml index 72acb8fc2..a1e78d3de 100644 --- a/config/simple.toml +++ b/config/simple.toml @@ -1,3 +1,5 @@ -[repository] +[backend] repository = "/tmp/repo" + +[repository] password = "test" diff --git a/src/commands.rs b/src/commands.rs index 50460378d..d319abbe2 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -243,7 +243,10 @@ impl Configurable for EntryPoint { /// [`RepositoryErrorKind::FromSplitError`]: crate::error::RepositoryErrorKind::FromSplitError fn open_repository(config: &Arc) -> Result> { let po = config.global.progress_options; - let repo = Repository::new_with_progress(&config.repository, po)?; + + let backends = config.backend.to_backends()?; + + let repo = Repository::new_with_progress(&config.repository, backends, po)?; match repo.password()? { // if password is given, directly return the result of find_key_in_backend and don't retry Some(pass) => { diff --git a/src/commands/backup.rs b/src/commands/backup.rs index 6dbf570ec..3a8f23b3b 100644 --- a/src/commands/backup.rs +++ b/src/commands/backup.rs @@ -130,9 +130,10 @@ impl Runnable for BackupCmd { impl BackupCmd { fn inner_run(&self) -> Result<()> { let config = RUSTIC_APP.config(); + let backends = config.backend.to_backends()?; let po = config.global.progress_options; - let repo = Repository::new_with_progress(&config.repository, po)?; + let repo = Repository::new_with_progress(&config.repository, backends, po)?; // Initialize repository if --init is set and it is not yet initialized let repo = if self.init && repo.config_id()?.is_none() { if config.global.dry_run { @@ -224,7 +225,7 @@ impl BackupCmd { .ignore_save_opts(opts.ignore_save_opts) .ignore_filter_opts(opts.ignore_filter_opts) .dry_run(config.global.dry_run); - let snap = repo.backup(&backup_opts, source.clone(), opts.snap_opts.to_snapshot()?)?; + let snap = repo.backup(&backup_opts, &source, opts.snap_opts.to_snapshot()?)?; if opts.json { let mut stdout = std::io::stdout(); diff --git a/src/commands/copy.rs b/src/commands/copy.rs index fb7d5afd4..d178177e6 100644 --- a/src/commands/copy.rs +++ b/src/commands/copy.rs @@ -8,9 +8,10 @@ use anyhow::{bail, Result}; use log::{error, info}; use merge::Merge; +use rustic_backend::BackendOptions; use serde::Deserialize; -use rustic_core::{CopySnapshot, Id, KeyOptions, Repository, RepositoryOptions}; +use rustic_core::{overwrite, CopySnapshot, Id, KeyOptions, Repository, RepositoryOptions}; /// `copy` subcommand #[derive(clap::Parser, Command, Debug)] @@ -30,10 +31,14 @@ pub(crate) struct CopyCmd { /// Target repository options #[derive(Default, Clone, Debug, Deserialize, Merge)] -pub struct Targets { +pub struct TargetOptions { /// Target repositories - #[merge(strategy = merge::vec::overwrite_empty)] - targets: Vec, + #[merge(strategy = overwrite)] + options: RepositoryOptions, + + /// Backend options + #[merge(strategy = overwrite)] + backend: BackendOptions, } impl Runnable for CopyCmd { @@ -49,8 +54,8 @@ impl CopyCmd { fn inner_run(&self) -> Result<()> { let config = RUSTIC_APP.config(); - if config.copy.targets.is_empty() { - status_err!("no [[copy.targets]] section in config file found!"); + if config.copy.is_empty() { + status_err!("no [[copy]] section in config file found!"); RUSTIC_APP.shutdown(Shutdown::Crash); } @@ -64,9 +69,15 @@ impl CopyCmd { snapshots.sort_unstable(); let poly = repo.config().poly()?; - for target_opt in &config.copy.targets { - let repo_dest = - Repository::new_with_progress(target_opt, config.global.progress_options)?; + for target_opt in &config.copy { + let repo_dest = { + let backends = target_opt.backend.to_backends()?; + Repository::new_with_progress( + &target_opt.options, + backends, + config.global.progress_options, + )? + }; let repo_dest = if self.init && repo_dest.config_id()?.is_none() { if config.global.dry_run { diff --git a/src/commands/init.rs b/src/commands/init.rs index d770e62db..146a22265 100644 --- a/src/commands/init.rs +++ b/src/commands/init.rs @@ -33,9 +33,10 @@ impl Runnable for InitCmd { impl InitCmd { fn inner_run(&self) -> Result<()> { let config = RUSTIC_APP.config(); + let backends = config.backend.to_backends()?; let po = config.global.progress_options; - let repo = Repository::new_with_progress(&config.repository, po)?; + let repo = Repository::new_with_progress(&config.repository, backends, po)?; // Note: This is again checked in repo.init_with_password(), however we want to inform // users before they are prompted to enter a password diff --git a/src/commands/key.rs b/src/commands/key.rs index f00cede3e..310fb414f 100644 --- a/src/commands/key.rs +++ b/src/commands/key.rs @@ -60,10 +60,14 @@ impl AddCmd { // create new "artificial" repo using the given password options let repo_opts = RepositoryOptions { password_file: self.new_password_file.clone(), - repository: Some(String::new()), // fake repository to make Repository::new() not bail ..Default::default() }; - let repo_newpass = Repository::new(&repo_opts)?; + // TODO: fake repository to make Repository::new() not bail?? + // String::new() was passed before!? + // Should we implemented default on RepositoryBackends? + // And make .repository optional? + let backends = config.backend.to_backends()?; + let repo_newpass = Repository::new(&repo_opts, backends)?; let pass = repo_newpass .password() diff --git a/src/commands/repoinfo.rs b/src/commands/repoinfo.rs index 887c42976..fbf6ae68d 100644 --- a/src/commands/repoinfo.rs +++ b/src/commands/repoinfo.rs @@ -50,11 +50,13 @@ impl RepoInfoCmd { fn inner_run(&self) -> Result<()> { let config = RUSTIC_APP.config(); + let backends = config.backend.to_backends()?; + let infos = Infos { files: (!self.only_index) .then(|| { let po = config.global.progress_options; - let repo = Repository::new_with_progress(&config.repository, po)?; + let repo = Repository::new_with_progress(&config.repository, backends, po)?; repo.infos_files() }) .transpose()?, diff --git a/src/config.rs b/src/config.rs index 254669924..67285c0b9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,11 +18,12 @@ use abscissa_core::FrameworkError; use clap::Parser; use itertools::Itertools; use log::Level; +use rustic_backend::BackendOptions; use rustic_core::RepositoryOptions; use serde::{Deserialize, Serialize}; use crate::{ - commands::{backup::BackupCmd, copy::Targets, forget::ForgetOptions}, + commands::{backup::BackupCmd, copy::TargetOptions, forget::ForgetOptions}, config::progress_options::ProgressOptions, filtering::SnapshotFilter, }; @@ -40,6 +41,9 @@ pub struct RusticConfig { #[clap(flatten, next_help_heading = "Global options")] pub global: GlobalOptions, + #[clap(flatten, next_help_heading = "Backend options")] + pub backend: BackendOptions, + /// Repository options #[clap(flatten, next_help_heading = "Repository options")] pub repository: RepositoryOptions, @@ -54,7 +58,8 @@ pub struct RusticConfig { /// Copy options #[clap(skip)] - pub copy: Targets, + #[merge(strategy = merge::vec::overwrite_empty)] + pub copy: Vec, /// Forget options #[clap(skip)] diff --git a/tests/config.rs b/tests/config.rs index 0993067ea..cfbf17657 100644 --- a/tests/config.rs +++ b/tests/config.rs @@ -1,31 +1,15 @@ //! Configuration file tests -use log::LevelFilter; +use anyhow::Result; +use rstest::*; use rustic_rs::RusticConfig; -use std::{error::Error, fs, path::PathBuf, str::FromStr}; +use std::{fs, path::PathBuf}; -type Result = std::result::Result>; - -fn get_config_file_path() -> PathBuf { - ["config", "full.toml"].iter().collect() -} -/// Ensure `full.toml` parses as a valid config file -#[test] -fn parse_full_toml_example() -> Result<()> { - let output = std::process::Command::new("cargo") - .args(["locate-project", "--workspace", "--message-format", "plain"]) - .output()?; - let root = PathBuf::from_str(String::from_utf8(output.stdout)?.as_str())?; - let root_dir = root.parent().unwrap(); - let config_path = root_dir.join(get_config_file_path()); +/// Ensure `configs` parse as a valid config files +#[rstest] +fn test_parse_rustic_configs_is_ok(#[files("config/*.toml")] config_path: PathBuf) -> Result<()> { let toml_string = fs::read_to_string(config_path)?; - let config: RusticConfig = toml::from_str(&toml_string)?; - - assert_eq!( - LevelFilter::from_str(config.global.log_level.unwrap().as_str())?, - LevelFilter::Info - ); - assert!(!config.global.dry_run); + let _ = toml::from_str::(&toml_string)?; Ok(()) } From cea65ca58ebd6699166aeef9d9bc1a247ab5f8b8 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:20:41 +0100 Subject: [PATCH 02/11] chore: update lockfile Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- Cargo.lock | 657 ++++++----------------------------------------------- 1 file changed, 67 insertions(+), 590 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a715b99be..1a3320a51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,52 +196,12 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" -[[package]] -name = "async-compat" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f68a707c1feb095d8c07f8a65b9f506b117d30af431cab89374357de7c11461b" -dependencies = [ - "futures-core", - "futures-io", - "once_cell", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "async-trait" -version = "0.1.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "awaitable" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70af449c9a763cb655c6a1e5338b42d99c67190824ff90658c1e30be844c0775" -dependencies = [ - "awaitable-error", - "cfg-if 1.0.0", -] - -[[package]] -name = "awaitable-error" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5b3469636cdf8543cceab175efca534471f36eee12fb8374aba00eb5e7e7f8a" - [[package]] name = "backoff" version = "0.4.0" @@ -253,18 +213,6 @@ dependencies = [ "rand", ] -[[package]] -name = "backon" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1a6197b2120bb2185a267f6515038558b019e92b832bb0320e96d66268dcf9" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "pin-project", - "tokio", -] - [[package]] name = "backtrace" version = "0.3.69" @@ -359,12 +307,6 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.5.0" @@ -454,10 +396,8 @@ checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", - "js-sys", "num-traits", "serde", - "wasm-bindgen", "windows-targets 0.48.5", ] @@ -512,7 +452,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -552,17 +492,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "concurrent_arena" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c529c2d4ecc249ae15d317c9a8b9e7d86f87e80d4417de6cfa8f4d6030f37daf" -dependencies = [ - "arc-swap", - "parking_lot", - "triomphe", -] - [[package]] name = "console" version = "0.15.7" @@ -779,7 +708,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -827,7 +756,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -849,7 +778,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -859,7 +788,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] @@ -884,17 +812,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "derive_destructure2" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac4b68190bad25c00b64ea19767b2321a037fc0e5bea7563d5d8e35e04b19c95" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -917,7 +834,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -946,7 +863,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", - "const-oid", "crypto-common", "subtle", ] @@ -1001,7 +917,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -1074,18 +990,7 @@ version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6866f3bfdf8207509a033af1a75a7b08abda06bbaaeae6669323fd5a097df2e9" dependencies = [ - "enum-map-derive 0.17.0", -] - -[[package]] -name = "enum-map-derive" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.43", + "enum-map-derive", ] [[package]] @@ -1096,7 +1001,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -1158,12 +1063,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "flagset" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a7e408202050813e6f1d9addadcaafef3dca7530c7ddfb005d4081cce6779" - [[package]] name = "flate2" version = "1.0.28" @@ -1204,14 +1103,29 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ - "futures-channel", "futures-core", + "futures-sink", ] [[package]] @@ -1220,6 +1134,17 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.30" @@ -1234,7 +1159,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -1249,6 +1174,12 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + [[package]] name = "futures-util" version = "0.3.30" @@ -1294,10 +1225,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] @@ -1386,15 +1315,6 @@ dependencies = [ "digest", ] -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "http" version = "0.2.11" @@ -1681,29 +1601,11 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonwebtoken" -version = "9.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7ea04a7c5c055c175f189b6dc6ba036fd62306b58c66c9f6389036c503a3f4" -dependencies = [ - "base64", - "js-sys", - "pem", - "ring", - "serde", - "serde_json", - "simple_asn1", -] - [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin 0.5.2", -] [[package]] name = "libc" @@ -1853,66 +1755,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "num-bigint" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-bigint-dig" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" -dependencies = [ - "byteorder", - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand", - "smallvec", - "zeroize", -] - -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.17" @@ -1920,7 +1762,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -1969,135 +1810,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "opendal" -version = "0.43.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c04ac25bc94e2b572a0f41bcc650cb39dd09255efce72b68eb5dc188b018c52a" -dependencies = [ - "anyhow", - "async-compat", - "async-trait", - "backon", - "base64", - "bytes", - "chrono", - "dirs", - "flagset", - "futures", - "http", - "log", - "md-5", - "once_cell", - "openssh", - "openssh-sftp-client", - "parking_lot", - "percent-encoding", - "pin-project", - "quick-xml 0.30.0", - "reqsign", - "reqwest", - "serde", - "serde_json", - "sha2", - "tokio", - "uuid", -] - -[[package]] -name = "openssh" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8274f2bf1fc3785406a3ff07c92c15590c00e84efb883da77b671562ca9a6115" -dependencies = [ - "dirs", - "libc", - "once_cell", - "shell-escape", - "tempfile", - "thiserror", - "tokio", - "tokio-pipe", -] - -[[package]] -name = "openssh-sftp-client" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5111bd8df89c0c7e64bf815710cafb05eff787f82e335244035ba685cf829b47" -dependencies = [ - "bytes", - "derive_destructure2", - "futures-core", - "once_cell", - "openssh", - "openssh-sftp-client-lowlevel", - "openssh-sftp-error", - "pin-project", - "scopeguard", - "tokio", - "tokio-io-utility", - "tokio-util", - "tracing", -] - -[[package]] -name = "openssh-sftp-client-lowlevel" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a84f1a52761901fcf5b10885544085348a872e57294531ec9188145d9a83042" -dependencies = [ - "awaitable", - "bytes", - "concurrent_arena", - "derive_destructure2", - "openssh-sftp-error", - "openssh-sftp-protocol", - "pin-project", - "tokio", - "tokio-io-utility", -] - -[[package]] -name = "openssh-sftp-error" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a5aea093d714df10186f481a6003e3f906f6fc8360c026737a841f4f182996" -dependencies = [ - "awaitable-error", - "openssh", - "openssh-sftp-protocol-error", - "ssh_format_error", - "thiserror", - "tokio", -] - -[[package]] -name = "openssh-sftp-protocol" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf38532d784978966f95d241226223823f351d5bb2a4bebcf6b20b9cb1e393e0" -dependencies = [ - "bitflags 2.4.1", - "num-derive", - "num-traits", - "openssh-sftp-protocol-error", - "serde", - "ssh_format", - "vec-strings", -] - -[[package]] -name = "openssh-sftp-protocol-error" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0719269eb3f037866ae07ec89cb44ed2c1d63b72b2390cef8e1aa3016a956ff8" -dependencies = [ - "serde", - "thiserror", - "vec-strings", -] - [[package]] name = "openssl-probe" version = "0.1.5" @@ -2110,16 +1822,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" -[[package]] -name = "ordered-multimap" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4d6a8c22fc714f0c2373e6091bf6f5e9b37b1bc0b1184874b7e0a4e303d318f" -dependencies = [ - "dlv-list", - "hashbrown 0.14.2", -] - [[package]] name = "os_pipe" version = "1.1.5" @@ -2195,25 +1897,6 @@ dependencies = [ "hmac", ] -[[package]] -name = "pem" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" -dependencies = [ - "base64", - "serde", -] - -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -2232,17 +1915,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkcs1" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" -dependencies = [ - "der", - "pkcs8", - "spki", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -2330,9 +2002,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a293318316cf6478ec1ad2a21c49390a8d5b5eae9fab736467d93fbc0edc29c5" +checksum = "2dd5e8a1f1029c43224ad5898e50140c2aebb1705f19e67c918ebf5b9e797fe1" dependencies = [ "unicode-ident", ] @@ -2346,26 +2018,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "quick-xml" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" -dependencies = [ - "memchr", - "serde", -] - -[[package]] -name = "quick-xml" -version = "0.31.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" -dependencies = [ - "memchr", - "serde", -] - [[package]] name = "quote" version = "1.0.34" @@ -2495,38 +2147,6 @@ version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" -[[package]] -name = "reqsign" -version = "0.14.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce87f66ba6c6acef277a729f989a0eca946cb9ce6a15bcc036bda0f72d4b9fd" -dependencies = [ - "anyhow", - "async-trait", - "base64", - "chrono", - "form_urlencoded", - "getrandom", - "hex", - "hmac", - "home", - "http", - "jsonwebtoken", - "log", - "once_cell", - "percent-encoding", - "quick-xml 0.31.0", - "rand", - "reqwest", - "rsa", - "rust-ini", - "serde", - "serde_json", - "sha1", - "sha2", - "tokio", -] - [[package]] name = "reqwest" version = "0.11.23" @@ -2595,7 +2215,7 @@ checksum = "853977598f084a492323fe2f7896b4100a86284ee8473612de60021ea341310f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -2607,31 +2227,11 @@ dependencies = [ "cc", "getrandom", "libc", - "spin 0.9.8", + "spin", "untrusted", "windows-sys 0.48.0", ] -[[package]] -name = "rsa" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ef35bf3e7fe15a53c4ab08a998e42271eab13eb0db224126bc7bc4c4bad96d" -dependencies = [ - "const-oid", - "digest", - "num-bigint-dig", - "num-integer", - "num-traits", - "pkcs1", - "pkcs8", - "rand_core", - "signature", - "spki", - "subtle", - "zeroize", -] - [[package]] name = "rstest" version = "0.18.2" @@ -2657,20 +2257,10 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.39", + "syn 2.0.44", "unicode-ident", ] -[[package]] -name = "rust-ini" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0698206bcb8882bf2a9ecb4c1e7785db57ff052297085a6efd4fe42302068a" -dependencies = [ - "cfg-if 1.0.0", - "ordered-multimap", -] - [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2737,7 +2327,6 @@ version = "0.1.0" dependencies = [ "aho-corasick", "anyhow", - "backoff", "binrw", "bytes", "cached", @@ -2753,10 +2342,8 @@ dependencies = [ "merge", "nix", "once_cell", - "opendal", "rand", "rayon", - "reqwest", "rustic_core", "serde", "serde-aux", @@ -2796,7 +2383,7 @@ dependencies = [ "displaydoc", "dunce", "enum-map", - "enum-map-derive 0.15.0", + "enum-map-derive", "filetime", "gethostname", "hex", @@ -2807,7 +2394,6 @@ dependencies = [ "log", "merge", "nix", - "opendal", "pariter", "path-dedot", "rand", @@ -3014,7 +2600,7 @@ dependencies = [ "hyper", "indicatif", "log", - "quick-xml 0.23.1", + "quick-xml", "regex", "reqwest", "self-replace", @@ -3063,14 +2649,14 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9" dependencies = [ "itoa", "ryu", @@ -3134,7 +2720,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -3177,27 +2763,12 @@ dependencies = [ "winapi", ] -[[package]] -name = "shell-escape" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" - [[package]] name = "shell-words" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - [[package]] name = "signature" version = "2.2.0" @@ -3208,6 +2779,12 @@ dependencies = [ "rand_core", ] +[[package]] +name = "similar" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" + [[package]] name = "simplelog" version = "0.12.1" @@ -3259,12 +2836,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -3281,32 +2852,6 @@ dependencies = [ "der", ] -[[package]] -name = "ssh_format" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24ab31081d1c9097c327ec23550858cb5ffb4af6b866c1ef4d728455f01f3304" -dependencies = [ - "bytes", - "serde", - "ssh_format_error", -] - -[[package]] -name = "ssh_format_error" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be3c6519de7ca611f71ef7e8a56eb57aa1c818fecb5242d0a0f39c83776c210c" -dependencies = [ - "serde", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" @@ -3335,7 +2880,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -3357,9 +2902,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.43" +version = "2.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +checksum = "92d27c2c202598d05175a6dd3af46824b7f747f8d8e9b14c623f19fa5069735d" dependencies = [ "proc-macro2", "quote", @@ -3442,12 +2987,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "thin-vec" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" - [[package]] name = "thiserror" version = "1.0.53" @@ -3465,7 +3004,7 @@ checksum = "3dcf4a824cce0aeacd6f38ae6f24234c8e80d68632338ebaa1443b5df9e29e19" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -3549,37 +3088,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "tokio-io-utility" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d672654d175710e52c7c41f6aec77c62b3c0954e2a7ebce9049d1e94ed7c263" -dependencies = [ - "bytes", - "tokio", -] - -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "tokio-pipe" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f213a84bffbd61b8fa0ba8a044b4bbe35d471d0b518867181e82bd5c15542784" -dependencies = [ - "libc", - "tokio", -] - [[package]] name = "tokio-rustls" version = "0.24.1" @@ -3673,7 +3181,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] @@ -3726,17 +3234,6 @@ dependencies = [ "tracing-log 0.2.0", ] -[[package]] -name = "triomphe" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" -dependencies = [ - "arc-swap", - "serde", - "stable_deref_trait", -] - [[package]] name = "try-lock" version = "0.2.5" @@ -3821,32 +3318,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "uuid" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" -dependencies = [ - "getrandom", - "serde", -] - [[package]] name = "valuable" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" -[[package]] -name = "vec-strings" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8509489e2a7ee219522238ad45fd370bec6808811ac15ac6b07453804e77659" -dependencies = [ - "serde", - "thin-vec", -] - [[package]] name = "version_check" version = "0.9.4" @@ -3908,7 +3385,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", "wasm-bindgen-shared", ] @@ -3942,7 +3419,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4294,7 +3771,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.43", + "syn 2.0.44", ] [[package]] From 4eeb8d841429fef8c3417bb2982408c20e9291f7 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:21:25 +0100 Subject: [PATCH 03/11] fix: fix parsing of `[[copy]]` section Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- config/copy_example.toml | 14 +++++++++----- config/full.toml | 16 ++++++++++------ src/commands/copy.rs | 21 +++++++++++++++------ 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/config/copy_example.toml b/config/copy_example.toml index f7c571a48..c346dca45 100644 --- a/config/copy_example.toml +++ b/config/copy_example.toml @@ -11,20 +11,24 @@ repository = "/tmp/repo" [repository] password = "test" -# you can specify multiple targets +# you can specify multiple copy targets [[copy]] -[[copy.options]] +# First copy target +[copy.options] +# Optional, but one of the three password options must be set +# either on CLI, in the config file or in the environment variables password = "test" no-cache = true -[[copy.backend]] +[copy.backend] repository = "/tmp/repo2" [[copy]] -[[copy.options]] +# 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]] +[copy.backend] repository = "rclone|ovh:backup" repo-hot = "rclone|ovh:backup-hot" diff --git a/config/full.toml b/config/full.toml index 21ab96631..6d65121c0 100644 --- a/config/full.toml +++ b/config/full.toml @@ -151,11 +151,14 @@ keep-withing-quarter-yearly = "0 year" keep-withing-half-yearly = "1 year" keep-within-yearly = "10 years" -# Multiple targets are available for the copy command. Each specify a repository with exactly identical options as in -# the [repository] section. +# Multiple targets are available for the copy command. +# Each specify a repository with exactly identical options as in +# the [repository] and [backend] section. [[copy]] -[[copy.options]] -# one of the three password options must be set +# First copy target +[copy.options] +# Optional, but one of the three password options must be set +# either on CLI, in the config file or in the environment variables password = "mySecretPassword" password-file = "/my/password.txt" password-command = "my_command.sh" @@ -166,11 +169,12 @@ warm-up = false warm-up-command = "warmup.sh %id" # Default: not set warm-up-wait = "10min" # Default: not set -[[copy.backend]] +[copy.backend] repository = "/repo/rustic" # Must be set repo-hot = "/my/hot/repo" # Default: not set [[copy]] -[[copy.backend]] +# Second copy target +[copy.backend] repository = "/repo/rustic2" # Must be set # ... diff --git a/src/commands/copy.rs b/src/commands/copy.rs index d178177e6..22caf1388 100644 --- a/src/commands/copy.rs +++ b/src/commands/copy.rs @@ -34,7 +34,7 @@ pub(crate) struct CopyCmd { pub struct TargetOptions { /// Target repositories #[merge(strategy = overwrite)] - options: RepositoryOptions, + options: Option, /// Backend options #[merge(strategy = overwrite)] @@ -72,11 +72,20 @@ impl CopyCmd { for target_opt in &config.copy { let repo_dest = { let backends = target_opt.backend.to_backends()?; - Repository::new_with_progress( - &target_opt.options, - backends, - config.global.progress_options, - )? + + if let Some(options) = &target_opt.options { + Repository::new_with_progress( + &options, + backends, + config.global.progress_options, + )? + } else { + Repository::new_with_progress( + &RepositoryOptions::default(), + backends, + config.global.progress_options, + )? + } }; let repo_dest = if self.init && repo_dest.config_id()?.is_none() { From 10b7c1cf2c609cce7d717c5ed082c44171bc13af Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:27:53 +0100 Subject: [PATCH 04/11] docs(config): fix some more descriptions Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- config/copy_example.toml | 4 ++-- config/full.toml | 5 +++-- config/local.toml | 4 +++- config/ovh-hot-cold.toml | 2 +- config/par2.toml | 1 + config/rustic.toml | 3 ++- config/simple.toml | 2 ++ 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/config/copy_example.toml b/config/copy_example.toml index c346dca45..cce1c30bc 100644 --- a/config/copy_example.toml +++ b/config/copy_example.toml @@ -3,11 +3,11 @@ # If the config file is named "copy_example.toml", run "rustic -P copy_example copy" to copy all snapshots. # See "rustic copy --help" for options how to select or filter snapshots to copy. -# [repository] specified the source repository +# [backend] specifies the backend for a repository [backend] repository = "/tmp/repo" -# [repository] specified the source repository +# [repository] specifies the options for a repository [repository] password = "test" diff --git a/config/full.toml b/config/full.toml index 6d65121c0..7a08c9860 100644 --- a/config/full.toml +++ b/config/full.toml @@ -21,7 +21,7 @@ dry-run = false # This is only an example how to set an rclone env variable. Default: No variables are defined. RCLONE_XXX = "true" -# Backend options: These options define which backend to use and which password to use. +# Backend options: These options define which backend to use. [backend] repository = "/repo/rustic" # Must be set repo-hot = "/my/hot/repo" # Default: not set @@ -35,7 +35,8 @@ timeout = "10min" # Only rest/rclone backend # Repository options: These options define which repository settings and passwords to use. [repository] -# one of the three password options must be set +# 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" password-command = "my_command.sh" diff --git a/config/local.toml b/config/local.toml index a119ea813..febefa6b3 100644 --- a/config/local.toml +++ b/config/local.toml @@ -2,10 +2,12 @@ # # backup usage: "rustic -P local backup # cleanup: "rustic -P local forget --prune -# + +# Backend options: These options define which backend to use. [backend] repository = "/backup/rustic" +# Repository options: These options define which repository settings and passwords to use. [repository] password-file = "/root/key-rustic" no-cache = true # no cache needed for local repository diff --git a/config/ovh-hot-cold.toml b/config/ovh-hot-cold.toml index 03db4caa6..7bdbddeca 100644 --- a/config/ovh-hot-cold.toml +++ b/config/ovh-hot-cold.toml @@ -3,7 +3,7 @@ # # backup usage: "rustic -P ovh-hot-cold backup # cleanup: "rustic -P ovh-hot-cold forget --prune -# + [backend] repository = "rclone:ovh:backup-home" repo-hot = "rclone:ovh:backup-home-hot" diff --git a/config/par2.toml b/config/par2.toml index 4f9f5948b..c9f38e240 100644 --- a/config/par2.toml +++ b/config/par2.toml @@ -13,5 +13,6 @@ post-create-command = "par2create -qq -n1 -r5 %file" # Note that we want to use a "*" in the rm command, hence we have to call sh to resolve the wildcard! post-delete-command = "sh -c \"rm -f %file*.par2\"" +# Repository options: These options define which repository settings and passwords to use. [repository] password = "test" diff --git a/config/rustic.toml b/config/rustic.toml index b5e6acc0e..d4d3720bc 100644 --- a/config/rustic.toml +++ b/config/rustic.toml @@ -10,10 +10,11 @@ log-level = "debug" log-file = "/log/rustic.log" +# Backend options: These options define which backend to use. [backend] repository = "/tmp/rustic" -# repository options: These options define which backend to use and which password to use. +# Repository options: These options define which backend to use and which password to use. [repository] password = "mySecretPassword" diff --git a/config/simple.toml b/config/simple.toml index a1e78d3de..25115e4c2 100644 --- a/config/simple.toml +++ b/config/simple.toml @@ -1,5 +1,7 @@ +# Backend options: These options define which backend to use. [backend] repository = "/tmp/repo" +# Repository options: These options define which repository settings and passwords to use. [repository] password = "test" From 1ec83f68214e67e4ca4cc490b6522231608e69b7 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Tue, 2 Jan 2024 13:31:52 +0100 Subject: [PATCH 05/11] WIP Temp settings Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com> --- Cargo.lock | 624 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 8 +- 2 files changed, 625 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a3320a51..a39087ac9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,12 +196,52 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" +[[package]] +name = "async-compat" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f68a707c1feb095d8c07f8a65b9f506b117d30af431cab89374357de7c11461b" +dependencies = [ + "futures-core", + "futures-io", + "once_cell", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "async-trait" +version = "0.1.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531b97fb4cd3dfdce92c35dedbfdc1f0b9d8091c8ca943d6dae340ef5012d514" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.44", +] + [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "awaitable" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70af449c9a763cb655c6a1e5338b42d99c67190824ff90658c1e30be844c0775" +dependencies = [ + "awaitable-error", + "cfg-if 1.0.0", +] + +[[package]] +name = "awaitable-error" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5b3469636cdf8543cceab175efca534471f36eee12fb8374aba00eb5e7e7f8a" + [[package]] name = "backoff" version = "0.4.0" @@ -213,6 +253,18 @@ dependencies = [ "rand", ] +[[package]] +name = "backon" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1a6197b2120bb2185a267f6515038558b019e92b832bb0320e96d66268dcf9" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "pin-project", + "tokio", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -307,6 +359,12 @@ version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.5.0" @@ -396,8 +454,10 @@ checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", "serde", + "wasm-bindgen", "windows-targets 0.48.5", ] @@ -492,6 +552,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "concurrent_arena" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c529c2d4ecc249ae15d317c9a8b9e7d86f87e80d4417de6cfa8f4d6030f37daf" +dependencies = [ + "arc-swap", + "parking_lot", + "triomphe", +] + [[package]] name = "console" version = "0.15.7" @@ -788,6 +859,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", + "pem-rfc7468", "zeroize", ] @@ -812,6 +884,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive_destructure2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac4b68190bad25c00b64ea19767b2321a037fc0e5bea7563d5d8e35e04b19c95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.44", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -863,6 +946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", "subtle", ] @@ -920,6 +1004,15 @@ dependencies = [ "syn 2.0.44", ] +[[package]] +name = "dlv-list" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] + [[package]] name = "duct" version = "0.13.7" @@ -1063,6 +1156,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "flagset" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a7e408202050813e6f1d9addadcaafef3dca7530c7ddfb005d4081cce6779" + [[package]] name = "flate2" version = "1.0.28" @@ -1225,8 +1324,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if 1.0.0", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -1315,6 +1416,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "http" version = "0.2.11" @@ -1601,11 +1711,29 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonwebtoken" +version = "9.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7ea04a7c5c055c175f189b6dc6ba036fd62306b58c66c9f6389036c503a3f4" +dependencies = [ + "base64", + "js-sys", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin 0.5.2", +] [[package]] name = "libc" @@ -1613,6 +1741,12 @@ version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + [[package]] name = "libmimalloc-sys" version = "0.1.35" @@ -1671,6 +1805,16 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if 1.0.0", + "digest", +] + [[package]] name = "memchr" version = "2.7.1" @@ -1755,6 +1899,66 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.17" @@ -1762,6 +1966,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -1810,6 +2015,135 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "opendal" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c04ac25bc94e2b572a0f41bcc650cb39dd09255efce72b68eb5dc188b018c52a" +dependencies = [ + "anyhow", + "async-compat", + "async-trait", + "backon", + "base64", + "bytes", + "chrono", + "dirs", + "flagset", + "futures", + "http", + "log", + "md-5", + "once_cell", + "openssh", + "openssh-sftp-client", + "parking_lot", + "percent-encoding", + "pin-project", + "quick-xml 0.30.0", + "reqsign", + "reqwest", + "serde", + "serde_json", + "sha2", + "tokio", + "uuid", +] + +[[package]] +name = "openssh" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8274f2bf1fc3785406a3ff07c92c15590c00e84efb883da77b671562ca9a6115" +dependencies = [ + "dirs", + "libc", + "once_cell", + "shell-escape", + "tempfile", + "thiserror", + "tokio", + "tokio-pipe", +] + +[[package]] +name = "openssh-sftp-client" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5111bd8df89c0c7e64bf815710cafb05eff787f82e335244035ba685cf829b47" +dependencies = [ + "bytes", + "derive_destructure2", + "futures-core", + "once_cell", + "openssh", + "openssh-sftp-client-lowlevel", + "openssh-sftp-error", + "pin-project", + "scopeguard", + "tokio", + "tokio-io-utility", + "tokio-util", + "tracing", +] + +[[package]] +name = "openssh-sftp-client-lowlevel" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a84f1a52761901fcf5b10885544085348a872e57294531ec9188145d9a83042" +dependencies = [ + "awaitable", + "bytes", + "concurrent_arena", + "derive_destructure2", + "openssh-sftp-error", + "openssh-sftp-protocol", + "pin-project", + "tokio", + "tokio-io-utility", +] + +[[package]] +name = "openssh-sftp-error" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a5aea093d714df10186f481a6003e3f906f6fc8360c026737a841f4f182996" +dependencies = [ + "awaitable-error", + "openssh", + "openssh-sftp-protocol-error", + "ssh_format_error", + "thiserror", + "tokio", +] + +[[package]] +name = "openssh-sftp-protocol" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf38532d784978966f95d241226223823f351d5bb2a4bebcf6b20b9cb1e393e0" +dependencies = [ + "bitflags 2.4.1", + "num-derive", + "num-traits", + "openssh-sftp-protocol-error", + "serde", + "ssh_format", + "vec-strings", +] + +[[package]] +name = "openssh-sftp-protocol-error" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0719269eb3f037866ae07ec89cb44ed2c1d63b72b2390cef8e1aa3016a956ff8" +dependencies = [ + "serde", + "thiserror", + "vec-strings", +] + [[package]] name = "openssl-probe" version = "0.1.5" @@ -1822,6 +2156,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-multimap" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4d6a8c22fc714f0c2373e6091bf6f5e9b37b1bc0b1184874b7e0a4e303d318f" +dependencies = [ + "dlv-list", + "hashbrown 0.14.3", +] + [[package]] name = "os_pipe" version = "1.1.5" @@ -1897,12 +2241,51 @@ dependencies = [ "hmac", ] +[[package]] +name = "pem" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" +dependencies = [ + "base64", + "serde", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.44", +] + [[package]] name = "pin-project-lite" version = "0.2.13" @@ -1915,6 +2298,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + [[package]] name = "pkcs8" version = "0.10.2" @@ -2018,6 +2412,26 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quick-xml" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" version = "1.0.34" @@ -2147,6 +2561,38 @@ version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" +[[package]] +name = "reqsign" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce87f66ba6c6acef277a729f989a0eca946cb9ce6a15bcc036bda0f72d4b9fd" +dependencies = [ + "anyhow", + "async-trait", + "base64", + "chrono", + "form_urlencoded", + "getrandom", + "hex", + "hmac", + "home", + "http", + "jsonwebtoken", + "log", + "once_cell", + "percent-encoding", + "quick-xml 0.31.0", + "rand", + "reqwest", + "rsa", + "rust-ini", + "serde", + "serde_json", + "sha1", + "sha2", + "tokio", +] + [[package]] name = "reqwest" version = "0.11.23" @@ -2227,11 +2673,31 @@ dependencies = [ "cc", "getrandom", "libc", - "spin", + "spin 0.9.8", "untrusted", "windows-sys 0.48.0", ] +[[package]] +name = "rsa" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e5124fcb30e76a7e79bfee683a2746db83784b86289f6251b54b7950a0dfc" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rstest" version = "0.18.2" @@ -2261,6 +2727,16 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "rust-ini" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0698206bcb8882bf2a9ecb4c1e7785db57ff052297085a6efd4fe42302068a" +dependencies = [ + "cfg-if 1.0.0", + "ordered-multimap", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -2327,12 +2803,14 @@ version = "0.1.0" dependencies = [ "aho-corasick", "anyhow", + "backoff", "binrw", "bytes", "cached", "clap", "derive_setters", "displaydoc", + "dunce", "filetime", "hex", "humantime", @@ -2342,8 +2820,10 @@ dependencies = [ "merge", "nix", "once_cell", + "opendal", "rand", "rayon", + "reqwest", "rustic_core", "serde", "serde-aux", @@ -2600,7 +3080,7 @@ dependencies = [ "hyper", "indicatif", "log", - "quick-xml", + "quick-xml 0.23.1", "regex", "reqwest", "self-replace", @@ -2723,6 +3203,17 @@ dependencies = [ "syn 2.0.44", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest", +] + [[package]] name = "sha2" version = "0.10.8" @@ -2763,12 +3254,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "shell-escape" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" + [[package]] name = "shell-words" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + [[package]] name = "signature" version = "2.2.0" @@ -2785,6 +3291,18 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "simplelog" version = "0.12.1" @@ -2836,6 +3354,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "spin" version = "0.9.8" @@ -2852,6 +3376,32 @@ dependencies = [ "der", ] +[[package]] +name = "ssh_format" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24ab31081d1c9097c327ec23550858cb5ffb4af6b866c1ef4d728455f01f3304" +dependencies = [ + "bytes", + "serde", + "ssh_format_error", +] + +[[package]] +name = "ssh_format_error" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be3c6519de7ca611f71ef7e8a56eb57aa1c818fecb5242d0a0f39c83776c210c" +dependencies = [ + "serde", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -2987,6 +3537,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "thin-vec" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" + [[package]] name = "thiserror" version = "1.0.53" @@ -3084,10 +3640,43 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", + "signal-hook-registry", "socket2", + "tokio-macros", "windows-sys 0.48.0", ] +[[package]] +name = "tokio-io-utility" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d672654d175710e52c7c41f6aec77c62b3c0954e2a7ebce9049d1e94ed7c263" +dependencies = [ + "bytes", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.44", +] + +[[package]] +name = "tokio-pipe" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f213a84bffbd61b8fa0ba8a044b4bbe35d471d0b518867181e82bd5c15542784" +dependencies = [ + "libc", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.24.1" @@ -3234,6 +3823,17 @@ dependencies = [ "tracing-log 0.2.0", ] +[[package]] +name = "triomphe" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +dependencies = [ + "arc-swap", + "serde", + "stable_deref_trait", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -3318,12 +3918,32 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +dependencies = [ + "getrandom", + "serde", +] + [[package]] name = "valuable" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vec-strings" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8509489e2a7ee219522238ad45fd370bec6808811ac15ac6b07453804e77659" +dependencies = [ + "serde", + "thin-vec", +] + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 410da3e67..6b0542630 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,13 +107,11 @@ toml_edit = { workspace = true, features = ["serde"] } [target.'cfg(not(windows))'.dependencies] libc = "0.2.150" [workspace.dependencies] -rustic_core = { path = "../rustic_core/crates/core", version = "0.1.2", features = ["cli"] } -rustic_backend = { path = "../rustic_core/crates/backends", version = "0.1.0", features = ["cli"] } +rustic_core = { path = "../rustic_core/crates/core", features = ["cli"] } +rustic_backend = { path = "../rustic_core/crates/backends" } # rustic_core = { version = "0.1.2", features = ["cli"] } -abscissa_core = { version = "0.7.0", default-features = false, features = [ - "application", -] } +abscissa_core = { version = "0.7.0", default-features = false, features = ["application"] } # logging log = "0.4" From bc49b6745ef68ac2c647e7ed51d48f027996520b Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Sun, 14 Jan 2024 06:51:56 +0100 Subject: [PATCH 06/11] key add: Add additional options --- src/commands/key.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/commands/key.rs b/src/commands/key.rs index 310fb414f..89837c1aa 100644 --- a/src/commands/key.rs +++ b/src/commands/key.rs @@ -9,7 +9,7 @@ use anyhow::Result; use dialoguer::Password; use log::info; -use rustic_core::{KeyOptions, Repository, RepositoryOptions}; +use rustic_core::{KeyOptions, RepositoryOptions}; /// `key` subcommand #[derive(clap::Parser, Command, Debug)] @@ -27,10 +27,18 @@ enum KeySubCmd { #[derive(clap::Parser, Debug)] pub(crate) struct AddCmd { + /// New password + #[clap(long)] + pub(crate) new_password: Option, + /// File from which to read the new password #[clap(long)] pub(crate) new_password_file: Option, + /// Command to get the new password from + #[clap(long)] + pub(crate) new_password_command: Option, + /// Key options #[clap(flatten)] pub(crate) key_opts: KeyOptions, @@ -57,20 +65,16 @@ impl AddCmd { let repo = open_repository(&config)?; - // create new "artificial" repo using the given password options - let repo_opts = RepositoryOptions { + // create new Repository options which just contain password information + let pass_opts = RepositoryOptions { + password: self.new_password.clone(), password_file: self.new_password_file.clone(), + password_command: self.new_password_command.clone(), ..Default::default() }; - // TODO: fake repository to make Repository::new() not bail?? - // String::new() was passed before!? - // Should we implemented default on RepositoryBackends? - // And make .repository optional? - let backends = config.backend.to_backends()?; - let repo_newpass = Repository::new(&repo_opts, backends)?; - - let pass = repo_newpass - .password() + + let pass = pass_opts + .evaluate_password() .map_err(|err| err.into()) .transpose() .unwrap_or_else(|| -> Result<_> { From 78343aa36456df7c72d9bd077028f95fa62d2efa Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Sun, 14 Jan 2024 06:55:15 +0100 Subject: [PATCH 07/11] fix path --- Cargo.lock | 110 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a39087ac9..752fb2ae6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -132,9 +132,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.5" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" +checksum = "4cd2405b3ac1faab2990b74d728624cd9fd115651fcecc7c2d8daf01376275ba" dependencies = [ "anstyle", "anstyle-parse", @@ -180,9 +180,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca87830a3e3fb156dc96cfbd31cb620265dd053be734723f22b760d6cc3c3051" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "arc-swap" @@ -217,7 +217,7 @@ checksum = "531b97fb4cd3dfdce92c35dedbfdc1f0b9d8091c8ca943d6dae340ef5012d514" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -379,9 +379,9 @@ checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" [[package]] name = "cached" -version = "0.46.1" +version = "0.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c8c50262271cdf5abc979a5f76515c234e764fa025d1ba4862c0f0bcda0e95" +checksum = "69b0116662497bc24e4b177c90eaf8870e39e2714c3fcfa296327a93f593fc21" dependencies = [ "cached_proc_macro", "cached_proc_macro_types", @@ -473,9 +473,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.12" +version = "4.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d" +checksum = "58e54881c004cec7895b0068a0a954cd5d62da01aef83fa35b1e594497bf5445" dependencies = [ "clap_builder", "clap_derive", @@ -483,9 +483,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.12" +version = "4.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" +checksum = "59cb82d7f531603d2fd1f507441cdd35184fa81beff7bd489570de7f773460bb" dependencies = [ "anstream", "anstyle", @@ -512,7 +512,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -658,11 +658,10 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.10" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2" +checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" dependencies = [ - "cfg-if 1.0.0", "crossbeam-utils", ] @@ -779,7 +778,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -827,7 +826,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -849,7 +848,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -892,7 +891,7 @@ checksum = "ac4b68190bad25c00b64ea19767b2321a037fc0e5bea7563d5d8e35e04b19c95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -917,7 +916,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -1001,7 +1000,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -1094,7 +1093,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -1258,7 +1257,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -1544,9 +1543,9 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747ad1b4ae841a78e8aba0d63adbfbeaea26b517b63705d47856b73015d27060" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" dependencies = [ "crossbeam-deque", "globset", @@ -2017,9 +2016,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "opendal" -version = "0.43.0" +version = "0.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c04ac25bc94e2b572a0f41bcc650cb39dd09255efce72b68eb5dc188b018c52a" +checksum = "bc0ad72f7b44ca4ae59d27ea151fdc6f37305cf6efe099bdaedbb30ec34579c0" dependencies = [ "anyhow", "async-compat", @@ -2031,6 +2030,7 @@ dependencies = [ "dirs", "flagset", "futures", + "getrandom", "http", "log", "md-5", @@ -2283,7 +2283,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -2396,9 +2396,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.73" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dd5e8a1f1029c43224ad5898e50140c2aebb1705f19e67c918ebf5b9e797fe1" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] @@ -2434,9 +2434,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a37c9326af5ed140c86a46655b5278de879853be5573c01df185b6f49a580a" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -2661,7 +2661,7 @@ checksum = "853977598f084a492323fe2f7896b4100a86284ee8473612de60021ea341310f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -2723,7 +2723,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.44", + "syn 2.0.48", "unicode-ident", ] @@ -3103,9 +3103,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] @@ -3123,20 +3123,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] name = "serde_json" -version = "1.0.109" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -3200,7 +3200,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -3430,7 +3430,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -3452,9 +3452,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.44" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d27c2c202598d05175a6dd3af46824b7f747f8d8e9b14c623f19fa5069735d" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -3545,22 +3545,22 @@ checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" [[package]] name = "thiserror" -version = "1.0.53" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2cd5904763bad08ad5513ddbb12cf2ae273ca53fa9f68e843e236ec6dfccc09" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.53" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcf4a824cce0aeacd6f38ae6f24234c8e80d68632338ebaa1443b5df9e29e19" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -3664,7 +3664,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -3770,7 +3770,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] @@ -4005,7 +4005,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", "wasm-bindgen-shared", ] @@ -4039,7 +4039,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4391,7 +4391,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.44", + "syn 2.0.48", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6b0542630..a82e8df68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -108,7 +108,7 @@ toml_edit = { workspace = true, features = ["serde"] } libc = "0.2.150" [workspace.dependencies] rustic_core = { path = "../rustic_core/crates/core", features = ["cli"] } -rustic_backend = { path = "../rustic_core/crates/backends" } +rustic_backend = { path = "../rustic_core/crates/backend" } # rustic_core = { version = "0.1.2", features = ["cli"] } abscissa_core = { version = "0.7.0", default-features = false, features = ["application"] } From 9096ee11cacd165a66c0d304f552de7f89fbffa5 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Sun, 14 Jan 2024 13:52:25 +0100 Subject: [PATCH 08/11] copy: Use target profile --- config/copy_example.toml | 22 +--- config/full.toml | 31 +----- src/commands.rs | 6 +- src/commands/copy.rs | 211 ++++++++++++++++++++------------------- src/config.rs | 15 ++- 5 files changed, 126 insertions(+), 159 deletions(-) diff --git a/config/copy_example.toml b/config/copy_example.toml index cce1c30bc..de5f8aeb4 100644 --- a/config/copy_example.toml +++ b/config/copy_example.toml @@ -11,24 +11,6 @@ repository = "/tmp/repo" [repository] password = "test" +[copy] # you can specify multiple copy targets -[[copy]] -# First copy target -[copy.options] -# Optional, but one of the three password options must be set -# either on CLI, in the config file or in the environment variables -password = "test" -no-cache = true - -[copy.backend] -repository = "/tmp/repo2" - -[[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" +target-profiles = ["local", "ovh-hot-cold"] diff --git a/config/full.toml b/config/full.toml index 7a08c9860..2e9b1e936 100644 --- a/config/full.toml +++ b/config/full.toml @@ -152,30 +152,7 @@ keep-withing-quarter-yearly = "0 year" keep-withing-half-yearly = "1 year" keep-within-yearly = "10 years" -# Multiple targets are available for the copy command. -# Each specify a repository with exactly identical options as in -# the [repository] and [backend] section. -[[copy]] -# First copy target -[copy.options] -# Optional, but one of the three password options must be set -# either on CLI, in the config file or in the environment variables -password = "mySecretPassword" -password-file = "/my/password.txt" -password-command = "my_command.sh" -no-cache = false -cache-dir = "/my/rustic/cachedir" # Default: Applications default cache dir, e.g. ~/.cache/rustic -# use either warm-up (warm-up by file access) or warm-up-command to specify warming up -warm-up = false -warm-up-command = "warmup.sh %id" # Default: not set -warm-up-wait = "10min" # Default: not set - -[copy.backend] -repository = "/repo/rustic" # Must be set -repo-hot = "/my/hot/repo" # Default: not set - -[[copy]] -# Second copy target -[copy.backend] -repository = "/repo/rustic2" # Must be set -# ... +# copy options +[copy] +init = false # initialize target repository if it doesn't exist +target-profiles = ["target_profile1", "target_profile2"] # Default: empty diff --git a/src/commands.rs b/src/commands.rs index 9f7642463..e3eab4dd7 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -164,13 +164,13 @@ impl Configurable for EntryPoint { // collect logs during merging as we start the logger *after* merging let mut merge_logs = Vec::new(); - + let mut log_fn = |level, message| merge_logs.push((level, message)); // get global options from command line / env and config file if config.global.use_profile.is_empty() { - config.merge_profile("rustic", &mut merge_logs, Level::Info)?; + config.merge_profile("rustic", &mut log_fn, Level::Info)?; } else { for profile in &config.global.use_profile.clone() { - config.merge_profile(profile, &mut merge_logs, Level::Warn)?; + config.merge_profile(profile, &mut log_fn, Level::Warn)?; } } diff --git a/src/commands/copy.rs b/src/commands/copy.rs index 22caf1388..036c15bb3 100644 --- a/src/commands/copy.rs +++ b/src/commands/copy.rs @@ -1,46 +1,45 @@ //! `copy` subcommand - use crate::{ - commands::open_repository, helpers::table_with_titles, status_err, Application, RUSTIC_APP, + commands::open_repository, helpers::table_with_titles, status_err, Application, RusticConfig, + RUSTIC_APP, }; use abscissa_core::{Command, Runnable, Shutdown}; use anyhow::{bail, Result}; -use log::{error, info}; +use log::{error, info, log, warn, Level}; use merge::Merge; -use rustic_backend::BackendOptions; use serde::Deserialize; -use rustic_core::{overwrite, CopySnapshot, Id, KeyOptions, Repository, RepositoryOptions}; +use rustic_core::{ + repofile::SnapshotFile, CopySnapshot, Id, IndexedFull, KeyOptions, ProgressBars, Repository, +}; /// `copy` subcommand -#[derive(clap::Parser, Command, Debug)] -pub(crate) struct CopyCmd { +#[derive(clap::Parser, Command, Default, Clone, Debug, Deserialize, Merge)] +pub struct CopyCmd { /// Snapshots to copy. If none is given, use filter options to filter from all snapshots. #[clap(value_name = "ID")] + #[serde(skip)] + #[merge(skip)] ids: Vec, + /// Target profile(s) + #[clap(value_name = "PROFILE")] + #[merge(strategy = merge::vec::overwrite_empty)] + target_profiles: Vec, + /// Initialize non-existing target repositories #[clap(long)] + #[merge(strategy = merge::bool::overwrite_false)] init: bool, /// Key options (when using --init) #[clap(flatten, next_help_heading = "Key options (when using --init)")] + #[serde(skip)] + #[merge(skip)] key_opts: KeyOptions, } -/// Target repository options -#[derive(Default, Clone, Debug, Deserialize, Merge)] -pub struct TargetOptions { - /// Target repositories - #[merge(strategy = overwrite)] - options: Option, - - /// Backend options - #[merge(strategy = overwrite)] - backend: BackendOptions, -} - impl Runnable for CopyCmd { fn run(&self) { if let Err(err) = self.inner_run() { @@ -52,102 +51,112 @@ impl Runnable for CopyCmd { impl CopyCmd { fn inner_run(&self) -> Result<()> { + let mut opts = self.clone(); let config = RUSTIC_APP.config(); + opts.merge(config.copy.clone()); - if config.copy.is_empty() { - status_err!("no [[copy]] section in config file found!"); - RUSTIC_APP.shutdown(Shutdown::Crash); + if opts.target_profiles.is_empty() { + warn!("no targets specified."); + return Ok(()); } let repo = open_repository(&config)?.to_indexed()?; - let mut snapshots = if self.ids.is_empty() { + let mut snapshots = if opts.ids.is_empty() { repo.get_matching_snapshots(|sn| config.snapshot_filter.matches(sn))? } else { - repo.get_snapshots(&self.ids)? + repo.get_snapshots(&opts.ids)? }; // sort for nicer output snapshots.sort_unstable(); - let poly = repo.config().poly()?; - for target_opt in &config.copy { - let repo_dest = { - let backends = target_opt.backend.to_backends()?; - - if let Some(options) = &target_opt.options { - Repository::new_with_progress( - &options, - backends, - config.global.progress_options, - )? - } else { - Repository::new_with_progress( - &RepositoryOptions::default(), - backends, - config.global.progress_options, - )? - } - }; - - let repo_dest = if self.init && repo_dest.config_id()?.is_none() { - if config.global.dry_run { - error!( - "cannot initialize target {} in dry-run mode!", - repo_dest.name - ); - continue; - } - let mut config_dest = repo.config().clone(); - config_dest.id = Id::random(); - let pass = repo_dest.password()?.unwrap(); - repo_dest.init_with_config(&pass, &self.key_opts, config_dest)? - } else { - repo_dest.open()? - }; - - info!("copying to target {}...", repo_dest.name); - if poly != repo_dest.config().poly()? { - bail!("cannot copy to repository with different chunker parameter (re-chunking not implemented)!"); + for target in &opts.target_profiles { + if let Err(err) = copy_to_target(&repo, target, &opts, &snapshots) { + error!("Error copying to {target}: {err}. Continuing..."); } + } + Ok(()) + } +} - let snaps = repo_dest.relevant_copy_snapshots( - |sn| !self.ids.is_empty() || config.snapshot_filter.matches(sn), - &snapshots, - )?; +fn copy_to_target( + repo: &Repository, + target: &str, + opts: &CopyCmd, + snapshots: &[SnapshotFile], +) -> Result<()> { + let config = RUSTIC_APP.config(); + let poly = repo.config().poly()?; + let repo_dest = { + let mut target_opts = RusticConfig::default(); + target_opts.merge_profile( + target, + &mut |level, message| log!(level, "{}", message), + Level::Warn, + )?; + let backends = target_opts.backend.to_backends()?; + Repository::new_with_progress( + &target_opts.repository, + backends, + config.global.progress_options, + )? + }; + + let repo_dest = if opts.init && repo_dest.config_id()?.is_none() { + if config.global.dry_run { + bail!( + "cannot initialize target {} in dry-run mode!", + repo_dest.name + ); + } + let mut config_dest = repo.config().clone(); + config_dest.id = Id::random(); + let pass = repo_dest.password()?.unwrap(); + repo_dest.init_with_config(&pass, &opts.key_opts, config_dest)? + } else { + repo_dest.open()? + }; + + info!("copying to target {}...", repo_dest.name); + if poly != repo_dest.config().poly()? { + bail!("cannot copy to repository with different chunker parameter (re-chunking not implemented)!"); + } - let mut table = - table_with_titles(["ID", "Time", "Host", "Label", "Tags", "Paths", "Status"]); - for CopySnapshot { relevant, sn } in snaps.iter() { - let tags = sn.tags.formatln(); - let paths = sn.paths.formatln(); - let time = sn.time.format("%Y-%m-%d %H:%M:%S").to_string(); - _ = table.add_row([ - &sn.id.to_string(), - &time, - &sn.hostname, - &sn.label, - &tags, - &paths, - &(if *relevant { "to copy" } else { "existing" }).to_string(), - ]); - } - println!("{table}"); - - let count = snaps.iter().filter(|sn| sn.relevant).count(); - if count > 0 { - if config.global.dry_run { - info!("would have copied {count} snapshots."); - } else { - repo.copy( - &repo_dest.to_indexed_ids()?, - snaps - .iter() - .filter_map(|CopySnapshot { relevant, sn }| relevant.then_some(sn)), - )?; - } - } else { - info!("nothing to copy."); - } + let snaps = repo_dest.relevant_copy_snapshots( + |sn| !opts.ids.is_empty() || config.snapshot_filter.matches(sn), + &snapshots, + )?; + + let mut table = table_with_titles(["ID", "Time", "Host", "Label", "Tags", "Paths", "Status"]); + for CopySnapshot { relevant, sn } in snaps.iter() { + let tags = sn.tags.formatln(); + let paths = sn.paths.formatln(); + let time = sn.time.format("%Y-%m-%d %H:%M:%S").to_string(); + _ = table.add_row([ + &sn.id.to_string(), + &time, + &sn.hostname, + &sn.label, + &tags, + &paths, + &(if *relevant { "to copy" } else { "existing" }).to_string(), + ]); + } + println!("{table}"); + + let count = snaps.iter().filter(|sn| sn.relevant).count(); + if count > 0 { + if config.global.dry_run { + info!("would have copied {count} snapshots."); + } else { + repo.copy( + &repo_dest.to_indexed_ids()?, + snaps + .iter() + .filter_map(|CopySnapshot { relevant, sn }| relevant.then_some(sn)), + )?; } - Ok(()) + } else { + info!("nothing to copy."); } + Ok(()) } diff --git a/src/config.rs b/src/config.rs index 67285c0b9..396886edb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -23,7 +23,7 @@ use rustic_core::RepositoryOptions; use serde::{Deserialize, Serialize}; use crate::{ - commands::{backup::BackupCmd, copy::TargetOptions, forget::ForgetOptions}, + commands::{backup::BackupCmd, copy::CopyCmd, forget::ForgetOptions}, config::progress_options::ProgressOptions, filtering::SnapshotFilter, }; @@ -58,8 +58,7 @@ pub struct RusticConfig { /// Copy options #[clap(skip)] - #[merge(strategy = merge::vec::overwrite_empty)] - pub copy: Vec, + pub copy: CopyCmd, /// Forget options #[clap(skip)] @@ -78,29 +77,29 @@ impl RusticConfig { pub fn merge_profile( &mut self, profile: &str, - merge_logs: &mut Vec<(Level, String)>, + log_fn: &mut impl FnMut(Level, String), level_missing: Level, ) -> Result<(), FrameworkError> { let profile_filename = profile.to_string() + ".toml"; let paths = get_config_paths(&profile_filename); if let Some(path) = paths.iter().find(|path| path.exists()) { - merge_logs.push((Level::Info, format!("using config {}", path.display()))); + log_fn(Level::Info, format!("using config {}", path.display())); let mut config = Self::load_toml_file(AbsPathBuf::canonicalize(path)?)?; // if "use_profile" is defined in config file, merge the referenced profiles first for profile in &config.global.use_profile.clone() { - config.merge_profile(profile, merge_logs, Level::Warn)?; + config.merge_profile(profile, log_fn, level_missing)?; } self.merge(config); } else { let paths_string = paths.iter().map(|path| path.display()).join(", "); - merge_logs.push(( + log_fn( level_missing, format!( "using no config file, none of these exist: {}", &paths_string ), - )); + ); }; Ok(()) } From c3d74a65bf07f589b65a2f618fbd808996af3d10 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Tue, 16 Jan 2024 00:45:57 +0100 Subject: [PATCH 09/11] use backend and repository flattened under repository --- config/copy_example.toml | 5 +---- config/full.toml | 20 +++++++++----------- config/local.toml | 5 +---- config/ovh-hot-cold.toml | 4 +--- config/par2.toml | 9 +++------ config/rustic.toml | 5 +---- config/simple.toml | 5 +---- src/commands.rs | 4 ++-- src/commands/backup.rs | 4 ++-- src/commands/copy.rs | 4 ++-- src/commands/init.rs | 4 ++-- src/commands/repoinfo.rs | 5 +++-- src/config.rs | 21 +++++++++++++++------ 13 files changed, 43 insertions(+), 52 deletions(-) diff --git a/config/copy_example.toml b/config/copy_example.toml index de5f8aeb4..c61b66e80 100644 --- a/config/copy_example.toml +++ b/config/copy_example.toml @@ -3,12 +3,9 @@ # If the config file is named "copy_example.toml", run "rustic -P copy_example copy" to copy all snapshots. # See "rustic copy --help" for options how to select or filter snapshots to copy. -# [backend] specifies the backend for a repository -[backend] -repository = "/tmp/repo" - # [repository] specifies the options for a repository [repository] +repository = "/tmp/repo" password = "test" [copy] diff --git a/config/full.toml b/config/full.toml index 2e9b1e936..04d7e4213 100644 --- a/config/full.toml +++ b/config/full.toml @@ -21,20 +21,11 @@ dry-run = false # This is only an example how to set an rclone env variable. Default: No variables are defined. RCLONE_XXX = "true" -# Backend options: These options define which backend to use. -[backend] -repository = "/repo/rustic" # Must be set -repo-hot = "/my/hot/repo" # Default: not 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] +repository = "/repo/rustic" # Must be set +repo-hot = "/my/hot/repo" # Default: not set # Optional, but one of the three password options must be set # either on CLI, in the config file or in environment variables password = "mySecretPassword" @@ -47,6 +38,13 @@ warm-up = false warm-up-command = "warmup.sh %id" # Default: not set warm-up-wait = "10min" # Default: not set +# Additional backend options - depending on backend. These can be only set in the config file. +[repository.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 + # Snapshot-filter options: These options apply to all commands that use snapshot filters [snapshot-filter] filter-host = ["host2", "host2"] # Default: no host filter diff --git a/config/local.toml b/config/local.toml index febefa6b3..ab504102b 100644 --- a/config/local.toml +++ b/config/local.toml @@ -3,12 +3,9 @@ # backup usage: "rustic -P local backup # cleanup: "rustic -P local forget --prune -# Backend options: These options define which backend to use. -[backend] -repository = "/backup/rustic" - # Repository options: These options define which repository settings and passwords to use. [repository] +repository = "/backup/rustic" password-file = "/root/key-rustic" no-cache = true # no cache needed for local repository diff --git a/config/ovh-hot-cold.toml b/config/ovh-hot-cold.toml index 7bdbddeca..67ae85829 100644 --- a/config/ovh-hot-cold.toml +++ b/config/ovh-hot-cold.toml @@ -4,11 +4,9 @@ # backup usage: "rustic -P ovh-hot-cold backup # cleanup: "rustic -P ovh-hot-cold forget --prune -[backend] +[repository] repository = "rclone:ovh:backup-home" repo-hot = "rclone:ovh:backup-home-hot" - -[repository] password-file = "/root/key-rustic-ovh" cache-dir = "/var/lib/cache/rustic" # explicitly specify cache dir for remote repository warm-up = true # cold storage needs warm-up, just trying to access a file is sufficient to start the warm-up diff --git a/config/par2.toml b/config/par2.toml index c9f38e240..55ad07cb5 100644 --- a/config/par2.toml +++ b/config/par2.toml @@ -2,17 +2,14 @@ # error correction files using par2create to a local repository. # The commands can use the variable %file, %type and %id which are replaced by the filename, the # file type and the file id before calling the command. -[backend] +[repository] repository = "/tmp/repo" +password = "test" -[backend.options] +[repository.options] # after saving a file in the repo, this command is called post-create-command = "par2create -qq -n1 -r5 %file" # after removing a file from the repo, this command is called. # Note that we want to use a "*" in the rm command, hence we have to call sh to resolve the wildcard! post-delete-command = "sh -c \"rm -f %file*.par2\"" - -# Repository options: These options define which repository settings and passwords to use. -[repository] -password = "test" diff --git a/config/rustic.toml b/config/rustic.toml index d4d3720bc..6c6612837 100644 --- a/config/rustic.toml +++ b/config/rustic.toml @@ -10,12 +10,9 @@ log-level = "debug" log-file = "/log/rustic.log" -# Backend options: These options define which backend to use. -[backend] -repository = "/tmp/rustic" - # Repository options: These options define which backend to use and which password to use. [repository] +repository = "/tmp/rustic" password = "mySecretPassword" # snapshot-filter options: These options apply to all commands that use snapshot filters diff --git a/config/simple.toml b/config/simple.toml index 25115e4c2..9e9024c4f 100644 --- a/config/simple.toml +++ b/config/simple.toml @@ -1,7 +1,4 @@ -# Backend options: These options define which backend to use. -[backend] -repository = "/tmp/repo" - # Repository options: These options define which repository settings and passwords to use. [repository] +repository = "/tmp/repo" password = "test" diff --git a/src/commands.rs b/src/commands.rs index e3eab4dd7..25a356d2c 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -245,9 +245,9 @@ impl Configurable for EntryPoint { fn open_repository(config: &Arc) -> Result> { let po = config.global.progress_options; - let backends = config.backend.to_backends()?; + let backends = config.repository.backend.to_backends()?; - let repo = Repository::new_with_progress(&config.repository, backends, po)?; + let repo = Repository::new_with_progress(&config.repository.repository, backends, po)?; match repo.password()? { // if password is given, directly return the result of find_key_in_backend and don't retry Some(pass) => { diff --git a/src/commands/backup.rs b/src/commands/backup.rs index 3a8f23b3b..266a67e5d 100644 --- a/src/commands/backup.rs +++ b/src/commands/backup.rs @@ -130,10 +130,10 @@ impl Runnable for BackupCmd { impl BackupCmd { fn inner_run(&self) -> Result<()> { let config = RUSTIC_APP.config(); - let backends = config.backend.to_backends()?; + let backends = config.repository.backend.to_backends()?; let po = config.global.progress_options; - let repo = Repository::new_with_progress(&config.repository, backends, po)?; + let repo = Repository::new_with_progress(&config.repository.repository, backends, po)?; // Initialize repository if --init is set and it is not yet initialized let repo = if self.init && repo.config_id()?.is_none() { if config.global.dry_run { diff --git a/src/commands/copy.rs b/src/commands/copy.rs index 036c15bb3..13b0c7aa6 100644 --- a/src/commands/copy.rs +++ b/src/commands/copy.rs @@ -93,9 +93,9 @@ fn copy_to_target( &mut |level, message| log!(level, "{}", message), Level::Warn, )?; - let backends = target_opts.backend.to_backends()?; + let backends = target_opts.repository.backend.to_backends()?; Repository::new_with_progress( - &target_opts.repository, + &target_opts.repository.repository, backends, config.global.progress_options, )? diff --git a/src/commands/init.rs b/src/commands/init.rs index 146a22265..7a743194f 100644 --- a/src/commands/init.rs +++ b/src/commands/init.rs @@ -33,10 +33,10 @@ impl Runnable for InitCmd { impl InitCmd { fn inner_run(&self) -> Result<()> { let config = RUSTIC_APP.config(); - let backends = config.backend.to_backends()?; + let backends = config.repository.backend.to_backends()?; let po = config.global.progress_options; - let repo = Repository::new_with_progress(&config.repository, backends, po)?; + let repo = Repository::new_with_progress(&config.repository.repository, backends, po)?; // Note: This is again checked in repo.init_with_password(), however we want to inform // users before they are prompted to enter a password diff --git a/src/commands/repoinfo.rs b/src/commands/repoinfo.rs index fbf6ae68d..9b87b4015 100644 --- a/src/commands/repoinfo.rs +++ b/src/commands/repoinfo.rs @@ -50,13 +50,14 @@ impl RepoInfoCmd { fn inner_run(&self) -> Result<()> { let config = RUSTIC_APP.config(); - let backends = config.backend.to_backends()?; + let backends = config.repository.backend.to_backends()?; let infos = Infos { files: (!self.only_index) .then(|| { let po = config.global.progress_options; - let repo = Repository::new_with_progress(&config.repository, backends, po)?; + let repo = + Repository::new_with_progress(&config.repository.repository, backends, po)?; repo.infos_files() }) .transpose()?, diff --git a/src/config.rs b/src/config.rs index 396886edb..458a390f6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -41,12 +41,8 @@ pub struct RusticConfig { #[clap(flatten, next_help_heading = "Global options")] pub global: GlobalOptions, - #[clap(flatten, next_help_heading = "Backend options")] - pub backend: BackendOptions, - - /// Repository options - #[clap(flatten, next_help_heading = "Repository options")] - pub repository: RepositoryOptions, + #[clap(flatten)] + pub repository: Repository, /// Snapshot filter options #[clap(flatten, next_help_heading = "Snapshot filter options")] @@ -65,6 +61,19 @@ pub struct RusticConfig { pub forget: ForgetOptions, } +#[derive(Clone, Default, Debug, Parser, Deserialize, Merge)] +#[serde(default, rename_all = "kebab-case")] +pub struct Repository { + #[clap(flatten, next_help_heading = "Backend options")] + #[serde(flatten)] + pub backend: BackendOptions, + + /// Repository options + #[clap(flatten, next_help_heading = "Repository options")] + #[serde(flatten)] + pub repository: RepositoryOptions, +} + impl RusticConfig { /// Merge a profile into the current config by reading the corresponding config file. /// Also recursively merge all profiles given within this config file. From 8af0ca419b6baa9de50d53470f73feb0872cd4ac Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Tue, 16 Jan 2024 22:59:37 +0100 Subject: [PATCH 10/11] use cli feature for rustic_backend --- Cargo.lock | 15 --------------- Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 752fb2ae6..b36517b69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2804,32 +2804,22 @@ dependencies = [ "aho-corasick", "anyhow", "backoff", - "binrw", "bytes", - "cached", "clap", "derive_setters", "displaydoc", "dunce", - "filetime", "hex", "humantime", - "ignore", "itertools", "log", "merge", - "nix", - "once_cell", "opendal", "rand", "rayon", "reqwest", "rustic_core", "serde", - "serde-aux", - "serde_derive", - "serde_json", - "serde_with", "shell-words", "strum", "strum_macros", @@ -2844,9 +2834,7 @@ name = "rustic_core" version = "0.1.2" dependencies = [ "aes256ctr_poly1305aes", - "aho-corasick", "anyhow", - "backoff", "binrw", "bytes", "bytesize", @@ -2858,7 +2846,6 @@ dependencies = [ "derivative", "derive_more", "derive_setters", - "directories", "dirs", "displaydoc", "dunce", @@ -2878,7 +2865,6 @@ dependencies = [ "path-dedot", "rand", "rayon", - "reqwest", "scrypt", "serde", "serde-aux", @@ -2888,7 +2874,6 @@ dependencies = [ "sha2", "shell-words", "thiserror", - "url", "walkdir", "xattr", "zstd", diff --git a/Cargo.toml b/Cargo.toml index a82e8df68..e719b03b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -108,7 +108,7 @@ toml_edit = { workspace = true, features = ["serde"] } libc = "0.2.150" [workspace.dependencies] rustic_core = { path = "../rustic_core/crates/core", features = ["cli"] } -rustic_backend = { path = "../rustic_core/crates/backend" } +rustic_backend = { path = "../rustic_core/crates/backend", features = ["cli"] } # rustic_core = { version = "0.1.2", features = ["cli"] } abscissa_core = { version = "0.7.0", default-features = false, features = ["application"] } From aa569496e42d8242e3fd6c5483b45583bb501703 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Tue, 16 Jan 2024 23:29:29 +0100 Subject: [PATCH 11/11] fix clippy lint --- Cargo.lock | 1 - src/commands/copy.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b36517b69..26c863be0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2808,7 +2808,6 @@ dependencies = [ "clap", "derive_setters", "displaydoc", - "dunce", "hex", "humantime", "itertools", diff --git a/src/commands/copy.rs b/src/commands/copy.rs index 13b0c7aa6..faea64a4f 100644 --- a/src/commands/copy.rs +++ b/src/commands/copy.rs @@ -123,7 +123,7 @@ fn copy_to_target( let snaps = repo_dest.relevant_copy_snapshots( |sn| !opts.ids.is_empty() || config.snapshot_filter.matches(sn), - &snapshots, + snapshots, )?; let mut table = table_with_titles(["ID", "Time", "Host", "Label", "Tags", "Paths", "Status"]);