]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/backup.rs
switch from failure to anyhow
[proxmox-backup.git] / src / backup.rs
index 2c5f105d74a27ba48c3e2d2b9ca5ea8a4aa958e3..7a2bf1ca6ebb6d097479938b97fc5d5d5f8c02c5 100644 (file)
@@ -1,15 +1,16 @@
-//! This module implements the proxmox backup chunked data storage
+//! This module implements the proxmox backup data storage
 //!
-//! A chunk is simply defined as binary blob. We store them inside a
-//! `ChunkStore`, addressed by the SHA256 digest of the binary
-//! blob. This technology is also known as content-addressable
-//! storage.
+//! Proxmox backup splits large files into chunks, and stores them
+//! deduplicated using a content addressable storage format.
 //!
-//! We store larger files by splitting them into chunks. The resulting
-//! SHA256 digest list is stored as separate index file. The
-//! `DynamicIndex*` format is able to deal with dynamic chunk sizes,
-//! whereas the `FixedIndex*` format is an optimization to store a
-//! list of equal sized chunks.
+//! A chunk is simply defined as binary blob, which is stored inside a
+//! `ChunkStore`, addressed by the SHA256 digest of the binary blob.
+//!
+//! Index files are used to reconstruct the original file. They
+//! basically contain a list of SHA256 checksums. The `DynamicIndex*`
+//! format is able to deal with dynamic chunk sizes, whereas the
+//! `FixedIndex*` format is an optimization to store a list of equal
+//! sized chunks.
 //!
 //! # ChunkStore Locking
 //!
 //!
 //! Not sure if this is better. TODO
 
+use anyhow::{bail, Error};
+
+// Note: .pcat1 => Proxmox Catalog Format version 1
+pub const CATALOG_NAME: &str = "catalog.pcat1.didx";
+
 #[macro_export]
 macro_rules! PROXMOX_BACKUP_PROTOCOL_ID_V1 {
     () =>  { "proxmox-backup-protocol-v1" }
 }
 
-mod crypt_setup;
-pub use crypt_setup::*;
+#[macro_export]
+macro_rules! PROXMOX_BACKUP_READER_PROTOCOL_ID_V1 {
+    () =>  { "proxmox-backup-reader-protocol-v1" }
+}
+
+/// Unix system user used by proxmox-backup-proxy
+pub const BACKUP_USER_NAME: &str = "backup";
+
+/// Return User info for the 'backup' user (``getpwnam_r(3)``)
+pub fn backup_user() -> Result<nix::unistd::User, Error> {
+    match nix::unistd::User::from_name(BACKUP_USER_NAME)? {
+        Some(user) => Ok(user),
+        None => bail!("Unable to lookup backup user."),
+    }
+}
+
+mod file_formats;
+pub use file_formats::*;
+
+mod manifest;
+pub use manifest::*;
+
+mod crypt_config;
+pub use crypt_config::*;
+
+mod key_derivation;
+pub use key_derivation::*;
+
+mod crypt_reader;
+pub use crypt_reader::*;
+
+mod crypt_writer;
+pub use crypt_writer::*;
+
+mod checksum_reader;
+pub use checksum_reader::*;
+
+mod checksum_writer;
+pub use checksum_writer::*;
+
+mod chunker;
+pub use chunker::*;
+
+mod data_blob;
+pub use data_blob::*;
+
+mod data_blob_reader;
+pub use data_blob_reader::*;
+
+mod data_blob_writer;
+pub use data_blob_writer::*;
+
+mod catalog;
+pub use catalog::*;
 
 mod chunk_stream;
 pub use chunk_stream::*;
@@ -116,7 +174,8 @@ pub use chunk_stream::*;
 mod chunk_stat;
 pub use chunk_stat::*;
 
-pub use proxmox_protocol::Chunker;
+mod read_chunk;
+pub use read_chunk::*;
 
 mod chunk_store;
 pub use chunk_store::*;
@@ -133,5 +192,11 @@ pub use dynamic_index::*;
 mod backup_info;
 pub use backup_info::*;
 
+mod prune;
+pub use prune::*;
+
 mod datastore;
 pub use datastore::*;
+
+mod catalog_shell;
+pub use catalog_shell::*;