Initial untested pass at restoring from local backups

This commit is contained in:
Dane Everitt
2021-01-16 18:06:22 -08:00
parent 6a286fb444
commit 7dd0acebc0
6 changed files with 183 additions and 116 deletions

View File

@@ -3,13 +3,15 @@ package backup
import (
"crypto/sha1"
"encoding/hex"
"github.com/apex/log"
"github.com/pterodactyl/wings/api"
"github.com/pterodactyl/wings/config"
"io"
"os"
"path"
"sync"
"emperror.dev/errors"
"github.com/apex/log"
"github.com/pterodactyl/wings/api"
"github.com/pterodactyl/wings/config"
)
type AdapterType string
@@ -19,6 +21,38 @@ const (
S3BackupAdapter AdapterType = "s3"
)
type Request struct {
Adapter AdapterType `json:"adapter"`
Uuid string `json:"uuid"`
Ignore string `json:"ignore"`
}
// AsBackup returns a new backup adapter based on the request value.
func (r *Request) AsBackup() (BackupInterface, error) {
var adapter BackupInterface
switch r.Adapter {
case LocalBackupAdapter:
adapter = &LocalBackup{
Backup{
Uuid: r.Uuid,
Ignore: r.Ignore,
adapter: LocalBackupAdapter,
},
}
case S3BackupAdapter:
adapter = &S3Backup{
Backup: Backup{
Uuid: r.Uuid,
Ignore: r.Ignore,
adapter: S3BackupAdapter,
},
}
default:
return nil, errors.New("server/backup: unsupported adapter type: " + string(r.Adapter))
}
return adapter, nil
}
type ArchiveDetails struct {
Checksum string `json:"checksum"`
ChecksumType string `json:"checksum_type"`