Track which objects are used in which snapshots in the local database.
[cumulus.git] / localdb.h
1 /* LBS: An LFS-inspired filesystem backup system
2  * Copyright (C) 2007  Michael Vrable
3  *
4  * When creating backup snapshots, maintain a local database of data blocks and
5  * checksums, in addition to the data contents (which may be stored remotely).
6  * This database is consulted when attempting to build incremental snapshots,
7  * as it says which objects can be reused.
8  *
9  * The database is implemented as an SQLite3 database, but this implementation
10  * detail is kept internal to this file, so that the storage format may be
11  * changed later. */
12
13 #ifndef _LBS_LOCALDB_H
14 #define _LBS_LOCALDB_H
15
16 #include <sqlite3.h>
17
18 #include <string>
19
20 #include "ref.h"
21
22 class LocalDb {
23 public:
24     void Open(const char *path, const char *snapshot_name);
25     void Close();
26     void StoreObject(const ObjectReference& ref,
27                      const std::string &checksum, int64_t size);
28     ObjectReference FindObject(const std::string &checksum, int64_t size);
29     void UseObject(const ObjectReference& ref);
30 private:
31     std::string snapshot;
32     sqlite3 *db;
33 };
34
35 #endif // _LBS_LOCALDB_H