forked from zbackup/zbackup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup_restorer.hh
66 lines (52 loc) · 1.77 KB
/
backup_restorer.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2012-2014 Konstantin Isakov <[email protected]> and ZBackup contributors, see CONTRIBUTORS
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
#ifndef BACKUP_RESTORER_HH_INCLUDED
#define BACKUP_RESTORER_HH_INCLUDED
#include <stddef.h>
#include <exception>
#include <string>
#include <set>
#undef __DEPRECATED
#include <ext/hash_map>
#include "chunk_storage.hh"
#include "ex.hh"
/// Generic interface to stream data out
class DataSink
{
public:
virtual void saveData( void const * data, size_t size )=0;
virtual ~DataSink() {}
};
/// Generic interface to seekable data output
class SeekableSink
{
public:
virtual void saveData( int64_t position, void const * data, size_t size )=0;
};
namespace __gnu_cxx
{
template<>
struct hash< Bundle::Id >
{
size_t operator()( Bundle::Id v ) const
{ return *((size_t*)(v.blob)); }
};
}
/// Restores the backup
namespace BackupRestorer {
DEF_EX( Ex, "Backup restorer exception", std::exception )
DEF_EX( exTooManyBytesToEmit, "A backup record asks to emit too many bytes", Ex )
DEF_EX( exBytesToMap, "Can't restore bytes to ChunkMap", Ex )
typedef std::set< ChunkId > ChunkSet;
typedef std::vector< std::pair < ChunkId, int64_t > > ChunkPosition;
typedef __gnu_cxx::hash_map< Bundle::Id, ChunkPosition > ChunkMap;
/// Restores the given backup
void restore( ChunkStorage::Reader &, std::string const & backupData,
DataSink *, ChunkSet *, ChunkMap *, SeekableSink * );
/// Restores ChunkMap using seekable output
void restoreMap( ChunkStorage::Reader & chunkStorageReader,
ChunkMap const * chunkMap, SeekableSink *output );
/// Performs restore iterations on backupData
void restoreIterations( ChunkStorage::Reader &, BackupInfo &, std::string &, ChunkSet * );
}
#endif