From 7fcfa5385864f378bc0bc9b9c0369a0fd42b68bd Mon Sep 17 00:00:00 2001 From: Tip ten Brink <75669206+tiptenbrink@users.noreply.github.com> Date: Fri, 3 May 2024 15:25:55 +0200 Subject: [PATCH] start with archive --- Cargo.lock | 88 +++++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 4 +- src/next/archives.rs | 12 ++++++ src/next/mod.rs | 1 + 4 files changed, 102 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f852f4..bc014a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,6 +230,15 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if", +] + [[package]] name = "directories" version = "5.0.1" @@ -269,6 +278,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "eyre" version = "0.6.12" @@ -279,6 +298,28 @@ dependencies = [ "once_cell", ] +[[package]] +name = "filetime" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "windows-sys 0.52.0", +] + +[[package]] +name = "flate2" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "getrandom" version = "0.2.12" @@ -351,9 +392,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libredox" @@ -376,6 +417,12 @@ dependencies = [ "libc", ] +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + [[package]] name = "log" version = "0.4.21" @@ -586,6 +633,19 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "ryu" version = "1.0.16" @@ -708,6 +768,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tar" +version = "0.4.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" +dependencies = [ + "filetime", + "libc", + "xattr", +] + [[package]] name = "test-log" version = "0.2.15" @@ -769,6 +840,7 @@ dependencies = [ "color-eyre", "directories", "duct", + "flate2", "keyring", "once_cell", "relative-path", @@ -776,6 +848,7 @@ dependencies = [ "serde", "serde_json", "spinoff", + "tar", "test-log", "thiserror", "toml", @@ -1075,3 +1148,14 @@ checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" dependencies = [ "memchr", ] + +[[package]] +name = "xattr" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" +dependencies = [ + "libc", + "linux-raw-sys", + "rustix", +] diff --git a/Cargo.toml b/Cargo.toml index 6427aa7..3a29528 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,4 +28,6 @@ color-eyre = "=0.6.3" test-log = { version="=0.2.15", default-features = false, features = ["trace"] } duct = "=0.13.7" camino = "1.1.6" -once_cell = "1.19.0" \ No newline at end of file +once_cell = "1.19.0" +tar = "0.4.40" +flate2 = "1.0.30" \ No newline at end of file diff --git a/src/next/archives.rs b/src/next/archives.rs index e69de29..ddd8340 100644 --- a/src/next/archives.rs +++ b/src/next/archives.rs @@ -0,0 +1,12 @@ +use std::fs::File; +use flate2::Compression; +use flate2::write::GzEncoder; + +fn archive() -> Result<(), ArchiveError> { + let tar_gz = File::create("archive.tar.gz")?; + let enc = GzEncoder::new(tar_gz, Compression::default()); + let mut tar = tar::Builder::new(enc); + tar.append_dir_all("backup/logs", "/var/log")?; + let a = tar.into_inner(); + Ok(()) +} \ No newline at end of file diff --git a/src/next/mod.rs b/src/next/mod.rs index 343e719..687548e 100644 --- a/src/next/mod.rs +++ b/src/next/mod.rs @@ -8,3 +8,4 @@ pub(crate) mod resolve; pub(crate) mod run; pub(crate) mod secrets; pub(crate) mod state; +pub(crate) mod archives; \ No newline at end of file