mirror of https://github.com/dswd/zvault
Backup::date -> timestamp
This commit is contained in:
parent
afef4004bd
commit
fabfb1dce5
|
@ -5,6 +5,7 @@ This project follows [semantic versioning](http://semver.org).
|
||||||
|
|
||||||
### UNRELEASED
|
### UNRELEASED
|
||||||
* [added] Ability to read/write tar file from/to stdin/stdout
|
* [added] Ability to read/write tar file from/to stdin/stdout
|
||||||
|
* [added] Added date to bundles
|
||||||
* [modified] Logging to stderr
|
* [modified] Logging to stderr
|
||||||
* [fixed] Only print "repairing bundles" if actually repairing bundles
|
* [fixed] Only print "repairing bundles" if actually repairing bundles
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ fn find_reference_backup(repo: &Repository, path: &str) -> Result<Option<(String
|
||||||
matching.push((name, backup));
|
matching.push((name, backup));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matching.sort_by_key(|&(_, ref b)| b.date);
|
matching.sort_by_key(|&(_, ref b)| b.timestamp);
|
||||||
Ok(matching.pop())
|
Ok(matching.pop())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ fn print_backup(backup: &Backup) {
|
||||||
if backup.modified {
|
if backup.modified {
|
||||||
warn!("This backup has been modified");
|
warn!("This backup has been modified");
|
||||||
}
|
}
|
||||||
println!("Date: {}", Local.timestamp(backup.date, 0).to_rfc2822());
|
println!("Date: {}", Local.timestamp(backup.timestamp, 0).to_rfc2822());
|
||||||
println!("Source: {}:{}", backup.host, backup.path);
|
println!("Source: {}:{}", backup.host, backup.path);
|
||||||
println!("Duration: {}", to_duration(backup.duration));
|
println!("Duration: {}", to_duration(backup.duration));
|
||||||
println!("Entries: {} files, {} dirs", backup.file_count, backup.dir_count);
|
println!("Entries: {} files, {} dirs", backup.file_count, backup.dir_count);
|
||||||
|
@ -193,7 +193,7 @@ fn print_backups(backup_map: &HashMap<String, Backup>) {
|
||||||
backups.sort_by_key(|b| b.0);
|
backups.sort_by_key(|b| b.0);
|
||||||
for (name, backup) in backups {
|
for (name, backup) in backups {
|
||||||
println!("{:40} {:>32} {:7} files, {:6} dirs, {:>10}",
|
println!("{:40} {:>32} {:7} files, {:6} dirs, {:>10}",
|
||||||
name, Local.timestamp(backup.date, 0).to_rfc2822(), backup.file_count,
|
name, Local.timestamp(backup.timestamp, 0).to_rfc2822(), backup.file_count,
|
||||||
backup.dir_count, to_file_size(backup.total_data_size));
|
backup.dir_count, to_file_size(backup.total_data_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,11 +89,11 @@ impl Repository {
|
||||||
};
|
};
|
||||||
for (name, backup) in backup_map {
|
for (name, backup) in backup_map {
|
||||||
if name.starts_with(prefix) {
|
if name.starts_with(prefix) {
|
||||||
let date = Local.timestamp(backup.date, 0);
|
let date = Local.timestamp(backup.timestamp, 0);
|
||||||
backups.push((name, date, backup));
|
backups.push((name, date, backup));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
backups.sort_by_key(|backup| -backup.2.date);
|
backups.sort_by_key(|backup| -backup.2.timestamp);
|
||||||
let mut keep = Bitmap::new(backups.len());
|
let mut keep = Bitmap::new(backups.len());
|
||||||
|
|
||||||
fn mark_needed<K: Eq, F: Fn(&DateTime<Local>) -> K>(backups: &[(String, DateTime<Local>, Backup)], keep: &mut Bitmap, max: usize, keyfn: F) {
|
fn mark_needed<K: Eq, F: Fn(&DateTime<Local>) -> K>(backups: &[(String, DateTime<Local>, Backup)], keep: &mut Bitmap, max: usize, keyfn: F) {
|
||||||
|
@ -275,7 +275,7 @@ impl Repository {
|
||||||
backup.root = try!(self.put_inode(&root_inode));
|
backup.root = try!(self.put_inode(&root_inode));
|
||||||
try!(self.flush());
|
try!(self.flush());
|
||||||
let elapsed = Local::now().signed_duration_since(start);
|
let elapsed = Local::now().signed_duration_since(start);
|
||||||
backup.date = start.timestamp();
|
backup.timestamp = start.timestamp();
|
||||||
backup.total_data_size = root_inode.cum_size;
|
backup.total_data_size = root_inode.cum_size;
|
||||||
for &(_, len) in backup.root.iter() {
|
for &(_, len) in backup.root.iter() {
|
||||||
backup.total_data_size += len as u64;
|
backup.total_data_size += len as u64;
|
||||||
|
|
|
@ -81,7 +81,7 @@ pub struct Backup {
|
||||||
pub bundle_count: usize,
|
pub bundle_count: usize,
|
||||||
pub chunk_count: usize,
|
pub chunk_count: usize,
|
||||||
pub avg_chunk_size: f32,
|
pub avg_chunk_size: f32,
|
||||||
pub date: i64,
|
pub timestamp: i64,
|
||||||
pub duration: f32,
|
pub duration: f32,
|
||||||
pub file_count: usize,
|
pub file_count: usize,
|
||||||
pub dir_count: usize,
|
pub dir_count: usize,
|
||||||
|
@ -101,7 +101,7 @@ serde_impl!(Backup(u8?) {
|
||||||
bundle_count: usize => 5,
|
bundle_count: usize => 5,
|
||||||
chunk_count: usize => 6,
|
chunk_count: usize => 6,
|
||||||
avg_chunk_size: f32 => 7,
|
avg_chunk_size: f32 => 7,
|
||||||
date: i64 => 8,
|
timestamp: i64 => 8,
|
||||||
duration: f32 => 9,
|
duration: f32 => 9,
|
||||||
file_count: usize => 10,
|
file_count: usize => 10,
|
||||||
dir_count: usize => 11,
|
dir_count: usize => 11,
|
||||||
|
|
|
@ -164,7 +164,7 @@ impl Repository {
|
||||||
}
|
}
|
||||||
repo = try!(Repository::open(path));
|
repo = try!(Repository::open(path));
|
||||||
let mut backups: Vec<(String, Backup)> = try!(repo.get_all_backups()).into_iter().collect();
|
let mut backups: Vec<(String, Backup)> = try!(repo.get_all_backups()).into_iter().collect();
|
||||||
backups.sort_by_key(|&(_, ref b)| b.date);
|
backups.sort_by_key(|&(_, ref b)| b.timestamp);
|
||||||
if let Some((name, backup)) = backups.pop() {
|
if let Some((name, backup)) = backups.pop() {
|
||||||
info!("Taking configuration from the last backup '{}'", name);
|
info!("Taking configuration from the last backup '{}'", name);
|
||||||
repo.config = backup.config;
|
repo.config = backup.config;
|
||||||
|
|
|
@ -194,7 +194,7 @@ impl Repository {
|
||||||
backup.root = chunks;
|
backup.root = chunks;
|
||||||
try!(self.flush());
|
try!(self.flush());
|
||||||
let elapsed = Local::now().signed_duration_since(start);
|
let elapsed = Local::now().signed_duration_since(start);
|
||||||
backup.date = start.timestamp();
|
backup.timestamp = start.timestamp();
|
||||||
backup.total_data_size = root_inode.cum_size;
|
backup.total_data_size = root_inode.cum_size;
|
||||||
backup.file_count = root_inode.cum_files;
|
backup.file_count = root_inode.cum_files;
|
||||||
backup.dir_count = root_inode.cum_dirs;
|
backup.dir_count = root_inode.cum_dirs;
|
||||||
|
|
Loading…
Reference in New Issue