Expand description
A library for deduplicated and encrypted backups, using repositories as specified in the restic repository design.
§Overview
This section gives a brief overview of the primary types in this crate:
The main type is the Repository type which describes a way to access a repository.
It can be in different states and allows - depending on the state - various high-level
actions to be performed on the repository like listing snapshots, backing up or restoring.
Besides this, various *Option types exist which allow to specify options for accessing a
Repository or for the methods used within a Repository. Those types usually offer
setter methods as well as implement serde::Serialize and serde::Deserialize.
Other main types are typically result types obtained by Repository methods which sometimes
are also needed as input for other Repository method, like computing a PrunePlan and
performing it.
There are also lower level data types which represent the stored repository format or
help accessing/writing it. Those are collected in the repofile module. These types typically
implement serde::Serialize and serde::Deserialize.
§Example - initialize a repository, backup to it and get snapshots
use rustic_backend::BackendOptions;
use rustic_core::{repofile::MasterKey, BackupOptions, ConfigOptions, Credentials,
KeyOptions, PathList, Repository, RepositoryOptions, SnapshotOptions,
};
// Initialize the repository in a temporary dir
let repo_dir = tempfile::tempdir().unwrap();
let repo_opts = RepositoryOptions::default();
// In real life, make sure to save this credential!
let credentials = Credentials::Masterkey(MasterKey::new());
// Initialize Backends
let backends = BackendOptions::default()
.repository(repo_dir.path().to_str().unwrap())
.to_backends()
.unwrap();
let key_opts = KeyOptions::default();
let config_opts = ConfigOptions::default();
let _repo = Repository::new(&repo_opts, &backends)
.unwrap()
.init(&credentials, &key_opts, &config_opts)
.unwrap();
// We could have used _repo directly, but open the repository again to show how to open it...
let repo = Repository::new(&repo_opts, &backends).unwrap().open(&credentials).unwrap();
// Get all snapshots from the repository
let snaps = repo.get_all_snapshots().unwrap();
// Should be zero, as the repository has just been initialized
assert_eq!(snaps.len(), 0);
// Turn repository state to indexed (for backup):
let repo = repo.to_indexed_ids().unwrap();
// Pre-define the snapshot-to-backup
let snap = SnapshotOptions::default()
.add_tags("tag1,tag2").unwrap()
.to_snapshot().unwrap();
// Specify backup options and source
let backup_opts = BackupOptions::default();
let source = PathList::from_string("src").unwrap().sanitize().unwrap();
// run the backup and return the snapshot pointing to the backup'ed data.
let snap = repo.backup(&backup_opts, &source, snap).unwrap();
// assert_eq!(&snap.paths, ["src"]);
// Get all snapshots from the repository
let snaps = repo.get_all_snapshots().unwrap();
// Should now be 1, we just created a snapshot
assert_eq!(snaps.len(), 1);
assert_eq!(snaps[0], snap);§Crate features
This crate exposes a few features for controlling dependency usage.
-
cli - Enables support for CLI features by enabling
clapandmergefeatures. This feature is disabled by default. -
clap - Enables a dependency on the
clapcrate and enables parsing from the commandline. This feature is disabled by default. -
merge - Enables support for merging multiple values into one, which enables the
conflatedependency. This is needed for parsing commandline arguments and merging them into one (e.g.config). This feature is disabled by default. -
webdav - Enables a dependency on the
dav-serverandfuturescrate. This enables us to run aWebDAVserver asynchronously on the commandline. This feature is disabled by default.
Re-exports§
pub use crate::backend::ALL_FILE_TYPES;pub use crate::backend::BytesList;pub use crate::backend::FileType;pub use crate::backend::ReadBackend;pub use crate::backend::ReadSource;pub use crate::backend::ReadSourceEntry;pub use crate::backend::ReadSourceOpen;pub use crate::backend::RepositoryBackends;pub use crate::backend::WriteBackend;pub use crate::backend::childstdout::ChildStdoutSource;pub use crate::backend::decrypt::max_compression_level;pub use crate::backend::ignore::LocalSource;pub use crate::backend::ignore::LocalSourceFilterOptions;pub use crate::backend::ignore::LocalSourceSaveOptions;pub use crate::backend::local_destination::LocalDestination;pub use crate::backend::node::last_modified_node;pub use crate::backend::node::modification::BlockdevOption;pub use crate::backend::node::modification::DevIdOption;pub use crate::backend::node::modification::NodeModification;pub use crate::backend::node::modification::TimeOption;pub use crate::backend::node::modification::XattrOption;pub use crate::backend::stdin::StdinSource;pub use crate::blob::BlobId;pub use crate::blob::DataId;pub use crate::blob::PackedId;pub use crate::blob::tree::FindMatches;pub use crate::blob::tree::FindNode;pub use crate::blob::tree::TreeId;pub use crate::blob::tree::TreeStreamerOptions as LsOptions;pub use crate::blob::tree::excludes::Excludes;pub use crate::blob::tree::rewrite::RewriteTreesOptions;pub use crate::commands::backup::BackupOptions;pub use crate::commands::backup::ParentOptions;pub use crate::commands::check::CheckOptions;pub use crate::commands::check::CheckResults;pub use crate::commands::check::ReadSubsetOption;pub use crate::commands::config::ConfigOptions;pub use crate::commands::copy::CopySnapshot;pub use crate::commands::forget::ForgetGroup;pub use crate::commands::forget::ForgetGroups;pub use crate::commands::forget::ForgetSnapshot;pub use crate::commands::forget::KeepOptions;pub use crate::commands::key::KeyOptions;pub use crate::commands::prune::LimitOption;pub use crate::commands::prune::PruneOptions;pub use crate::commands::prune::PrunePlan;pub use crate::commands::prune::PruneStats;pub use crate::commands::repair::index::RepairIndexOptions;pub use crate::commands::repair::snapshots::RepairSnapshotsOptions;pub use crate::commands::repoinfo::BlobInfo;pub use crate::commands::repoinfo::IndexInfos;pub use crate::commands::repoinfo::PackInfo;pub use crate::commands::repoinfo::RepoFileInfo;pub use crate::commands::repoinfo::RepoFileInfos;pub use crate::commands::restore::FileDirStats;pub use crate::commands::restore::RestoreOptions;pub use crate::commands::restore::RestorePlan;pub use crate::commands::restore::RestoreStats;pub use crate::commands::rewrite::RewriteOptions;pub use crate::error::ErrorKind;pub use crate::error::RusticError;pub use crate::error::RusticResult;pub use crate::error::Severity;pub use crate::error::Status;pub use crate::id::HexId;pub use crate::id::Id;pub use crate::progress::HiddenProgress;pub use crate::progress::NoProgress;pub use crate::progress::NoProgressBars;pub use crate::progress::Progress;pub use crate::progress::ProgressBars;pub use crate::progress::ProgressType;pub use crate::progress::RusticProgress;pub use crate::repofile::snapshotfile::PathList;pub use crate::repofile::snapshotfile::SnapshotOptions;pub use crate::repofile::snapshotfile::StringList;pub use crate::repofile::snapshotfile::grouping::Group;pub use crate::repofile::snapshotfile::grouping::Grouped;pub use crate::repofile::snapshotfile::grouping::SnapshotGroup;pub use crate::repofile::snapshotfile::grouping::SnapshotGroupCriterion;pub use crate::repository::IndexedFull;pub use crate::repository::IndexedFullStatus;pub use crate::repository::IndexedIds;pub use crate::repository::IndexedIdsStatus;pub use crate::repository::IndexedTree;pub use crate::repository::IndexedTreesStatus;pub use crate::repository::Open;pub use crate::repository::OpenStatus;pub use crate::repository::Repository;pub use crate::repository::RepositoryOptions;pub use crate::repository::command_input::CommandInput;pub use crate::repository::command_input::CommandInputErrorKind;pub use crate::repository::credentials::CredentialOptions;pub use crate::repository::credentials::Credentials;pub use jiff;
Modules§
- archiver 🔒
- backend 🔒
- Module for backend related functionality.
- blob 🔒
- chunker 🔒
- commands 🔒
- The commands that can be run by the CLI.
- crypto 🔒
- error 🔒
- Error types and Result module.
- id 🔒
- The
Idtype and related functions - index 🔒
- progress 🔒
- repofile
- Structs which are saved in JSON or binary format in the repository
- repository 🔒
- vfs
- Virtual File System support - allows to act on the repository like on a file system
Macros§
- define_
new_ id_ struct - Generate newtypes for
Ids identifying Repository files - impl_
blobid - Generate newtypes for
Ids identifying packed blobs - impl_
repofile - Generate newtypes for
Ids identifying Repository files implementingRepoFile - impl_
repoid - Generate newtypes for
Ids identifying Repository files
Functions§
- compression_
level_ range - The accepted range of compression levels.