1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*!
A library for deduplicated and encrypted backups, using repositories as specified in the [`restic repository design`](https://github.com/restic/restic/blob/master/doc/design.rst).
# 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
```rust
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 `clap` and `merge`
features. *This feature is disabled by default*.
- **clap** - Enables a dependency on the `clap` crate and enables parsing from
the commandline. *This feature is disabled by default*.
- **merge** - Enables support for merging multiple values into one, which
enables the `conflate` dependency. 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-server` and `futures` crate.
This enables us to run a `WebDAV` server asynchronously on the commandline.
*This feature is disabled by default*.
*/
// Workspace lints don't seem to work for this?
// formatting args are used for error messages
pub
pub
pub
pub
pub
pub
pub
pub
pub
pub
/// Structs which are saved in JSON or binary format in the repository
pub
/// Virtual File System support - allows to act on the repository like on a file system
// rustic_core Public API
pub use crate::;