1 /* Cumulus: Efficient Filesystem Backup to the Cloud
2 * Copyright (C) 2007-2008 The Cumulus Developers
3 * See the AUTHORS file for a list of contributors.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 /* When creating backup snapshots, maintain a local database of data blocks and
21 * checksums, in addition to the data contents (which may be stored remotely).
22 * This database is consulted when attempting to build incremental snapshots,
23 * as it says which objects can be reused.
25 * The database is implemented as an SQLite3 database, but this implementation
26 * detail is kept internal to this file, so that the storage format may be
29 #ifndef _LBS_LOCALDB_H
30 #define _LBS_LOCALDB_H
41 void Open(const char *path, const char *snapshot_name,
42 const char *snapshot_scheme);
44 void StoreObject(const ObjectReference& ref, double age);
45 ObjectReference FindObject(const std::string &checksum, int64_t size);
46 bool IsOldObject(const std::string &checksum, int64_t size, double *age,
48 bool IsAvailable(const ObjectReference &ref);
49 void UseObject(const ObjectReference& ref);
51 std::set<std::string> GetUsedSegments();
52 void SetSegmentMetadata(const std::string &segment, const std::string &path,
53 const std::string &checksum,
54 const std::string &type, int data_size,
56 bool GetSegmentMetadata(const std::string &segment,
57 std::string *seg_path, std::string *seg_checksum);
59 bool LoadChunkSignatures(ObjectReference ref,
60 void **buf, size_t *len,
61 std::string *algorithm);
62 void StoreChunkSignatures(ObjectReference ref,
63 const void *buf, size_t len,
64 const std::string &algorithm);
69 sqlite3_stmt *Prepare(const char *sql);
70 void ReportError(int rc);
71 int64_t SegmentToId(const std::string &segment);
72 std::string IdToSegment(int64_t segmentid);
75 #endif // _LBS_LOCALDB_H