Compare commits
No commits in common. "a4a03ca4c502e5e3b763d69521ed7c2c498a0168" and "0eda768c038c6ef8ac87c93e20a92ace73c39f9c" have entirely different histories.
a4a03ca4c5
...
0eda768c03
|
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Added
|
||||
|
||||
* `backup` CLI command
|
||||
* Incremental backups
|
||||
* Chain length describes how many incremental backups to create from the
|
||||
same full backup
|
||||
|
|
@ -17,7 +18,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* Backup layers
|
||||
* Store multiple chains of backups in parallel, configuring each with
|
||||
different parameters (son-father-grandfather principle)
|
||||
* CLI commands for creating, restoring & listing backups
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fmt;
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Represents the changes relative to the previous backup
|
||||
|
|
@ -75,12 +74,3 @@ impl Delta {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Delta {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let added_count: usize = self.added.values().map(|s| s.len()).sum();
|
||||
let removed_count: usize = self.removed.values().map(|s| s.len()).sum();
|
||||
|
||||
write!(f, "+{}-{}", added_count, removed_count)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,8 +127,4 @@ where
|
|||
.get(layer)
|
||||
.map(|manager| manager.restore_backup(start_time))
|
||||
}
|
||||
|
||||
pub fn managers(&self) -> &HashMap<String, Manager<T>> {
|
||||
&self.managers
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,9 +181,4 @@ where
|
|||
|
||||
Err(other("Unknown backup."))
|
||||
}
|
||||
|
||||
/// Get a reference to the underlying chains
|
||||
pub fn chains(&self) -> &Vec<Vec<Backup<T>>> {
|
||||
&self.chains
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ use flate2::Compression;
|
|||
use path::PathExt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fmt;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
|
@ -206,20 +205,3 @@ impl<T: Clone> Backup<T> {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> fmt::Display for Backup<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let letter = match self.type_ {
|
||||
BackupType::Full => 'F',
|
||||
BackupType::Incremental => 'I',
|
||||
};
|
||||
|
||||
write!(
|
||||
f,
|
||||
"{} ({}, {})",
|
||||
self.start_time.format(Backup::FILENAME_FORMAT),
|
||||
letter,
|
||||
self.delta
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use std::path::PathBuf;
|
|||
#[derive(Subcommand)]
|
||||
pub enum BackupCommands {
|
||||
/// List all tracked backups
|
||||
List(BackupListArgs),
|
||||
List,
|
||||
/// Manually create a new backup
|
||||
Create(BackupCreateArgs),
|
||||
/// Restore a backup
|
||||
|
|
@ -28,12 +28,6 @@ pub struct BackupCreateArgs {
|
|||
layer: String,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct BackupListArgs {
|
||||
/// What layer to list
|
||||
layer: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
pub struct BackupRestoreArgs {
|
||||
/// Path to the backup inside the backup directory
|
||||
|
|
@ -47,7 +41,7 @@ impl BackupArgs {
|
|||
pub fn run(&self, cli: &Cli) -> io::Result<()> {
|
||||
match &self.command {
|
||||
BackupCommands::Create(args) => args.run(cli),
|
||||
BackupCommands::List(args) => args.run(cli),
|
||||
BackupCommands::List => Ok(()),
|
||||
BackupCommands::Restore(args) => args.run(cli),
|
||||
}
|
||||
}
|
||||
|
|
@ -126,24 +120,3 @@ impl BackupRestoreArgs {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BackupListArgs {
|
||||
pub fn run(&self, cli: &Cli) -> io::Result<()> {
|
||||
let meta = cli.meta()?;
|
||||
|
||||
for (name, manager) in meta.managers().iter() {
|
||||
println!("{}", name);
|
||||
|
||||
for chain in manager.chains().iter().filter(|c| !c.is_empty()) {
|
||||
let mut iter = chain.iter();
|
||||
println!(" {}", iter.next().unwrap());
|
||||
|
||||
for backup in iter {
|
||||
println!(" {}", backup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue