forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.go
56 lines (46 loc) · 1.58 KB
/
backup.go
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
package services
import (
"context"
"sync"
config_proto "www.velocidex.com/golang/velociraptor/config/proto"
"www.velocidex.com/golang/velociraptor/file_store/api"
"www.velocidex.com/golang/vfilter"
)
// Callers may register a backup provider to be included in the backup
type BackupProvider interface {
// The name of this provider
ProviderName() string
// The name of the result saved in the container
Name() []string
// Providers may write result sets into the backup. This will be
// called by the backup service to obtain a channel over which we
// can write the backup file (named in Name() above).
BackupResults(
ctx context.Context,
wg *sync.WaitGroup) (<-chan vfilter.Row, error)
// This is the opposite of backup - it allows a provider to
// recover from an existing backup. Typcially providers need to
// clear their data and read new data from this channel. The
// provider may return stats about its operation.
Restore(ctx context.Context, in <-chan vfilter.Row) (BackupStat, error)
}
// Alows each provider to report the stats of the most recent
// operation.
type BackupStat struct {
// Name of provider
Name string
Error error
Message string
}
type BackupService interface {
Register(provider BackupProvider)
RestoreBackup(export_path api.FSPathSpec) ([]BackupStat, error)
CreateBackup(export_path api.FSPathSpec) ([]BackupStat, error)
}
func GetBackupService(config_obj *config_proto.Config) (BackupService, error) {
org_manager, err := GetOrgManager()
if err != nil {
return nil, err
}
return org_manager.Services(config_obj.OrgId).BackupService()
}