summaryrefslogtreecommitdiff
path: root/src/generation.rs
AgeCommit message (Collapse)AuthorFilesLines
2021-12-31feat: compare schema versions for compatibilityLars Wirzenius1-1/+63
When opening a local generation, check that it's compatible with the current version of Obnam. Sponsored-by: author
2021-12-31docs: add documentation comments to crateLars Wirzenius1-3/+58
Also, make it an error for a public symbol to not be documented. Sponsored-by: author
2021-12-05chore: tidy up things found by newer Rust toolchainLars Wirzenius1-6/+5
Sponsored-by: author
2021-11-27feat! turn errors from backup root directory into errorsLars Wirzenius1-0/+3
Previously an error from, say, a missing backup root directory was reported to the user as a warning. Turn it into an error. However, errors reading a file or directory inside the backup root should still be just a warning. Sponsored-by: author
2021-11-20chore: bump dependency on rusqlite to 0.26.1 and fix breakageLars Wirzenius1-5/+5
Sponsored-by: author
2021-10-24feat! store schema version of generation database in the dbLars Wirzenius1-0/+115
Add a new mandatory database table "meta" to the SQLite database the stores information about the files in a backup generation. The idea is for future versions of the Obnam client to be able to be able to restore from backups made by older -- or newer -- versions of Obnam, as far as is reasonable. Add the `obnam gen-info` command to show information about the generation metadata. Sponsored-by: author
2021-08-09refactor: drop NascentGeneration::insert_iterLars Wirzenius1-31/+12
It was only used by a test function, which is now changed to not use it. Add comment to the test function that it's too complicated and things need refactoring. However, that probably needs to wait for new abstractions. Sponsored-by: author
2021-08-09refactor: use for loop over an iterator instead of .insert_iterLars Wirzenius1-3/+0
This makes the code more explicit, which is good for now, and is a step towards making it all use async. There will be a need to refactor this further with better abstractions, once async works. Sponsored-by: author
2021-08-09refactor: call NascentGeneration::insert from ::insert_iterLars Wirzenius1-4/+1
This is a step towards getting rid of insert_iter entirely, which would make it easier to make `obnam backup` use async. I originally split insert_iter so I could use a single transaction for inserting many rows, but it seems to not be needed for speed after all. I've benchmarked backing up a large file with and without this change, and there's no real difference. I've not benchmarked with a large number of files. Even if there's a performance hit from using multiple transactions, my hope is that by being able to use more CPUs/threads for backing up will outweigh that by far. Sponsored-by: author
2021-08-01refactor: use a struct for GenIdLars Wirzenius1-5/+28
This means a ChunkId can't be used instead. Sponsored-by: author
2021-08-01refactor: add a type alias for generation idsLars Wirzenius1-0/+3
This will make it harder to accidentally use a string. Can still be confused with a chunk id. Sponsored-by: author
2021-07-30cleanup: fix things rustc/clipppy now complain aboutLars Wirzenius1-4/+4
Mostly https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow. Sponsored-by: author
2021-07-28Mark CACHEDIR.TAGs in the databaseAlexander Batischev1-23/+114
In the following commits, we'll use this to check if a tag existed before.
2021-07-21Replace LocalGenerationResult with plain ResultAlexander Batischev1-24/+32
I do not plan to simplify the `T` in the return type of `get_file_and_fileno` because that function is only ever called from inside the module; it doesn't seem worthwhile to introduce a new type there.
2021-07-21Replace NascentResult with plain ResultAlexander Batischev1-5/+3
2021-07-21backup_run: replace tuple with a structAlexander Batischev1-4/+4
2021-07-21Replace BackupResult with plain ResultAlexander Batischev1-2/+2
2021-07-05refactor: code to run backups to have less repetitionLars Wirzenius1-1/+9
This should make it easier to introduce async, later.
2021-04-29feat: improve error messagesLars Wirzenius1-8/+8
All unclear error messages should now be clearer. For example, all the ones related to a file mention the file name and the attempted operation that failed.
2021-04-26Port chunkids() to the iterator APIAlexander Batischev1-10/+17
2021-04-26Generalize the machinery to arbitrary result typesAlexander Batischev1-18/+55
2021-04-26Extend the iterator to users of LocalGeneration::files()Alexander Batischev1-2/+2
2021-04-26Use an iterator internally for LocalGenerationAlexander Batischev1-19/+32
This adds the machinery. We have to keep the compiled SQL query while the iterator is in use, so we wrap it in an `SqlResults` struct which the iterator borrows.
2021-04-26Expose fallibility of individual SQL resultsAlexander Batischev1-6/+14
`LocalGeneration::sql::files()` runs an SQL query, iterates over the results and collects the rows into a `Vec`. This can fail at any step: the query might fail to run, or one of the rows might fail to be fetched or processed. Right now, we lump all those failures into a `Result` that wraps the whole return value. This is only possible because we process each row before returning. Once `Vec` is replaced by an iterator, we won't have that luxury anymore, so we now wrap each individual element into its own `Result` (as well as wrapping the whole vector into a `Result` of its own).
2021-04-06chore: clean up unnecessary use of ? based on clippy reportsLars Wirzenius1-6/+6
2021-03-27refactor: drop unused lifetime annotationLars Wirzenius1-1/+1
2021-03-27refactor: drop unnecessary conversions to the same typeLars Wirzenius1-1/+1
2021-03-27refactor: avoid confusing function name from_strLars Wirzenius1-1/+1
2021-03-12feat: show warnings for any problems backing up filesLars Wirzenius1-5/+14
Previously, we either ignored it or aborted the backup. Neither is good. Now we ignore the problem, except to show a warning at the end of the backup run.
2021-02-04refactor: have per-module error enumsLars Wirzenius1-22/+61
This means that a function that parses step bindings can't return an error that the document is missing a title. Such an error return would be nonsensical, and we use the Rust type system to prevent it, at a small cost of being a bit verbose. Additional benefit is that the library portion of Obnam doesn't return anyhow::Result values anymore.
2021-01-05refactor: add BackedUpFile to avoid using a tupleLars Wirzenius1-4/+34
The struct is easier to use right.
2021-01-05refactor: move policy on whether to back up a file into a moduleLars Wirzenius1-2/+2
This commit also splits up the src/cmd/backup.rs module into other, smaller, more cohesive modules that are easier to understand and use.
2021-01-04refactor: add a type alias for file identifiers in generationsLars Wirzenius1-15/+18
2021-01-04feat! record whether file was backed up and why, in a generationLars Wirzenius1-22/+31
This changes SQL schema.
2021-01-04feat: add an index for chunk ids lookupsLars Wirzenius1-0/+1
2021-01-01feat: use SQL to look up information for a file, by filenameLars Wirzenius1-14/+24
This speeds things up a lot compared to iterating over all files.
2021-01-01feat! use signed 64 bit integers as file numbers, file countsLars Wirzenius1-17/+15
2021-01-01refactor: move SQL use into sub-moduleLars Wirzenius1-58/+92
This keeps all the SQL related functions closer together, making it easier to make changes to them.
2020-12-31feat: incremental backupLars Wirzenius1-0/+32
This uses the previous, latest generation as a guideline to see what is new or changed.
2020-12-31refactor: add LocalGeneration type for read-only operationsLars Wirzenius1-55/+59
This splits the use of NascentGeneration to more cohesive "new generation being built" versus "existing generation being restored".
2020-12-30feat: add GenerationListLars Wirzenius1-0/+1
Various part of Obnam will need to deal with lists of generations. Abstract this.
2020-12-30feat! store and show timestamp for each backup generationLars Wirzenius1-2/+3
This changes the output format of "obnam list".
2020-12-27add FinishedGenerationLars Wirzenius1-1/+30
2020-12-27refactor: rename Generation to NascentGenerationLars Wirzenius1-4/+4
New name is more descriptive.
2020-12-11feat! store file metadata as JSONLars Wirzenius1-24/+11
This avoids having to add extra columns when we add more metadata support. This may be worth re-thinking later, once things stabilize.
2020-11-23feat: progress reporting to backups and restoresLars Wirzenius1-18/+37
2020-11-10feat: restore a generationLars Wirzenius1-5/+57
2020-11-09fix: minor fixes found by clippyLars Wirzenius1-1/+1
2020-11-08feat: add Generation to represent data in a backup generationLars Wirzenius1-0/+94
The data is stored in an SQLite database file.