Skip to content

Commit

Permalink
feat(backup)!: name contains timestamp with microsecs
Browse files Browse the repository at this point in the history
This breaking change makes things more robust,
but you have to rename your backup files by adding
a microseconds suffix, such as `.123456`.

You can do so with

```sh
autoload -U zmv
zmv 'backup-(*).tar.zst' 'backup-${1}.123456.tar.zst'
```
  • Loading branch information
graelo committed Nov 11, 2022
1 parent 9a347e8 commit 6ce10b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/management/archive/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub fn new_backup_filepath<P>(dirpath: P) -> PathBuf
where
P: AsRef<Path>,
{
let timestamp_frag = Local::now().format("%Y%m%dT%H%M%S").to_string();
let timestamp_frag = Local::now().format("%Y%m%dT%H%M%S%.f").to_string();
let backup_filename = format!("backup-{timestamp_frag}.tar.zst");
dirpath.as_ref().join(backup_filename)
}
Expand Down
4 changes: 2 additions & 2 deletions src/management/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Catalog {
async fn parse_backup_filenames<P: AsRef<Path>>(dirpath: P) -> Result<Vec<Backup>> {
let mut backups: Vec<Backup> = vec![];

let pattern = r#".*backup-(\d{8}T\d{6})\.tar\.zst"#;
let pattern = r#".*backup-(\d{8}T\d{6})\.\d{6}\.tar\.zst"#;
let matcher = Regex::new(pattern).unwrap();

let mut entries = fs::read_dir(dirpath.as_ref()).await?;
Expand All @@ -198,7 +198,7 @@ impl Catalog {
if let Some(captures) = matcher.captures(&path.to_string_lossy()) {
let date_str = &captures[1];
let creation_date =
NaiveDateTime::parse_from_str(date_str, "%Y%m%dT%H%M%S").unwrap();
NaiveDateTime::parse_from_str(date_str, "%Y%m%dT%H%M%S%.f").unwrap();
let backup = Backup {
filepath: path.into(),
creation_date,
Expand Down

0 comments on commit 6ce10b0

Please sign in to comment.