1 /* LBS: An LFS-inspired filesystem backup system
2 * Copyright (C) 2007 Michael Vrable
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.
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
13 #ifndef _LBS_LOCALDB_H
14 #define _LBS_LOCALDB_H
24 void Open(const char *path, const char *snapshot_name,
25 const char *snapshot_scheme, double intent);
27 void StoreObject(const ObjectReference& ref,
28 const std::string &checksum, int64_t size, double age);
29 ObjectReference FindObject(const std::string &checksum, int64_t size);
30 bool IsOldObject(const std::string &checksum, int64_t size, double *age,
32 bool IsAvailable(const ObjectReference &ref);
33 void UseObject(const ObjectReference& ref);
35 void SetSegmentChecksum(const std::string &segment, const std::string &path,
36 const std::string &checksum, int size);
37 bool GetSegmentChecksum(const std::string &segment,
38 std::string *seg_path, std::string *seg_checksum);
43 sqlite3_stmt *Prepare(const char *sql);
44 void ReportError(int rc);
45 int64_t SegmentToId(const std::string &segment);
46 std::string IdToSegment(int64_t segmentid);
49 #endif // _LBS_LOCALDB_H