Documentation
¶
Index ¶
- Constants
- func DropboxContentHash(r io.Reader) (string, error)
- func EncodeChecksum(sum []byte) string
- func ForgetServerSnapshots(ctx context.Context, serverUUID string) error
- func IsOctetStream(value string) bool
- type AdapterType
- type ArchiveDetails
- type Backup
- func (b *Backup) Checksum() ([]byte, error)
- func (b *Backup) Details(ctx context.Context, parts []remote.BackupPart) (*ArchiveDetails, error)
- func (b *Backup) Identifier() string
- func (b *Backup) Ignored() string
- func (b *Backup) Path() string
- func (b *Backup) ServerId() string
- func (b *Backup) SetClient(c remote.Client)
- func (b *Backup) Size() (int64, error)
- type BackupInterface
- type DirectRestorer
- type LocalBackup
- func (b *LocalBackup) Generate(ctx context.Context, fsys *filesystem.Filesystem, ignore string) (*ArchiveDetails, error)
- func (b *LocalBackup) Remove() error
- func (b *LocalBackup) Restore(ctx context.Context, _ io.Reader, callback RestoreCallback) error
- func (b *LocalBackup) WithLogContext(c map[string]interface{})
- type PBSBackup
- func (b *PBSBackup) Checksum() ([]byte, error)
- func (b *PBSBackup) Details(ctx context.Context, parts []remote.BackupPart) (*ArchiveDetails, error)
- func (b *PBSBackup) Generate(ctx context.Context, fsys *filesystem.Filesystem, ignore string) (*ArchiveDetails, error)
- func (b *PBSBackup) Path() string
- func (b *PBSBackup) Remove() error
- func (b *PBSBackup) Restore(ctx context.Context, _ io.Reader, callback RestoreCallback) error
- func (b *PBSBackup) RestoreDirect(ctx context.Context, dest string) error
- func (b *PBSBackup) Size() (int64, error)
- func (b *PBSBackup) SnapshotPath() string
- func (b *PBSBackup) WithLogContext(c map[string]interface{})
- type RangeResumeReader
- type RestoreCallback
- type ResumableBackup
- func (r *ResumableBackup) Generate(ctx context.Context, fsys *filesystem.Filesystem, ignore string) (*ArchiveDetails, error)
- func (r *ResumableBackup) Remove() error
- func (r *ResumableBackup) Restore(ctx context.Context, rd io.Reader, callback RestoreCallback) error
- func (r *ResumableBackup) WithLogContext(c map[string]interface{})
- type S3Backup
- func (s *S3Backup) Generate(ctx context.Context, fsys *filesystem.Filesystem, ignore string) (*ArchiveDetails, error)
- func (s *S3Backup) Remove() error
- func (s *S3Backup) Restore(ctx context.Context, r io.Reader, callback RestoreCallback) error
- func (s *S3Backup) WithLogContext(c map[string]interface{})
Constants ¶
const ( ProtocolContentRange = "content-range" ProtocolDropboxAppend = "dropbox-append" )
const (
// PBSChecksumType is reported to the panel so it can identify PBS snapshots.
PBSChecksumType = "pbs"
)
Variables ¶
This section is empty.
Functions ¶
func DropboxContentHash ¶ added in v1.5.0
DropboxContentHash computes Dropbox's content_hash: the SHA-256 of the concatenated SHA-256 digests of every 4 MiB block of the file. See https://www.dropbox.com/developers/reference/content-hash
func EncodeChecksum ¶ added in v1.4.0
EncodeChecksum is a helper for tests / logging.
func ForgetServerSnapshots ¶ added in v1.4.0
ForgetServerSnapshots removes every PBS snapshot in this server's backup group.
func IsOctetStream ¶ added in v1.5.0
Types ¶
type AdapterType ¶
type AdapterType string
const ( LocalBackupAdapter AdapterType = "wings" S3BackupAdapter AdapterType = "s3" PBSBackupAdapter AdapterType = "pbs" // ResumableBackupAdapter uploads to a provider resumable upload session // (Google Drive, OneDrive, Dropbox) created by the panel. ResumableBackupAdapter AdapterType = "resumable" )
type ArchiveDetails ¶
type ArchiveDetails struct {
Checksum string `json:"checksum"`
ChecksumType string `json:"checksum_type"`
Size int64 `json:"size"`
Parts []remote.BackupPart `json:"parts"`
ContentHash string `json:"content_hash,omitempty"`
}
func (*ArchiveDetails) ToRequest ¶
func (ad *ArchiveDetails) ToRequest(successful bool) remote.BackupRequest
ToRequest returns a request object.
type Backup ¶
type Backup struct {
// The UUID of this backup object. This must line up with a backup from
// the panel instance.
Uuid string `json:"uuid"`
// The UUID of the server the backup is associated with.
ServerUuid string `json:"server_uuid"`
// An array of files to ignore when generating this backup. This should be
// compatible with a standard .gitignore structure.
Ignore string `json:"ignore"`
// contains filtered or unexported fields
}
func (*Backup) Details ¶
func (b *Backup) Details(ctx context.Context, parts []remote.BackupPart) (*ArchiveDetails, error)
Details returns both the checksum and size of the archive currently stored on the disk to the caller.
func (*Backup) Identifier ¶
type BackupInterface ¶
type BackupInterface interface {
// SetClient sets the API request client on the backup interface.
SetClient(remote.Client)
// Identifier returns the UUID of this backup as tracked by the panel
// instance.
Identifier() string
// ServerId returns the UUID of the server the backup is associated with
ServerId() string
// WithLogContext attaches additional context to the log output for this
// backup.
WithLogContext(map[string]interface{})
// Generate creates a backup in whatever the configured source for the
// specific implementation is.
Generate(context.Context, *filesystem.Filesystem, string) (*ArchiveDetails, error)
// Ignored returns the ignored files for this backup instance.
Ignored() string
// Checksum returns a SHA1 checksum for the generated backup.
Checksum() ([]byte, error)
// Size returns the size of the generated backup.
Size() (int64, error)
// Path returns the path to the backup on the machine. This is not always
// the final storage location of the backup, simply the location we're using
// to store it until it is moved to the final spot.
Path() string
// Details returns details about the archive.
Details(context.Context, []remote.BackupPart) (*ArchiveDetails, error)
// Remove removes a backup file.
Remove() error
// Restore is called when a backup is ready to be restored to the disk from
// the given source. Not every backup implementation will support this nor
// will every implementation require a reader be provided.
Restore(context.Context, io.Reader, RestoreCallback) error
}
noinspection GoNameStartsWithPackageName
type DirectRestorer ¶ added in v1.4.0
DirectRestorer restores archive contents straight into a destination directory without requiring a per-file callback (used by PBS pxar restore).
type LocalBackup ¶
type LocalBackup struct {
Backup
}
func LocateLocal ¶
func LocateLocal(client remote.Client, uuid string, suuid string) (*LocalBackup, os.FileInfo, error)
LocateLocal finds the backup for a server and returns the local path. This will obviously only work if the backup was created as a local backup.
func (*LocalBackup) Generate ¶
func (b *LocalBackup) Generate(ctx context.Context, fsys *filesystem.Filesystem, ignore string) (*ArchiveDetails, error)
Generate generates a backup of the selected files and pushes it to the defined location for this instance.
func (*LocalBackup) Remove ¶
func (b *LocalBackup) Remove() error
Remove removes a backup from the system.
func (*LocalBackup) Restore ¶
func (b *LocalBackup) Restore(ctx context.Context, _ io.Reader, callback RestoreCallback) error
Restore will walk over the archive and call the callback function for each file encountered.
func (*LocalBackup) WithLogContext ¶
func (b *LocalBackup) WithLogContext(c map[string]interface{})
WithLogContext attaches additional context to the log output for this backup.
type PBSBackup ¶ added in v1.4.0
type PBSBackup struct {
Backup
// contains filtered or unexported fields
}
PBSBackup streams server files to Proxmox Backup Server via proxmox-backup-client. It does NOT create local tar.gz archives — PBS handles chunking, deduplication, and compression natively.
func LocatePBS ¶ added in v1.4.0
LocatePBS finds an existing PBS snapshot for this panel backup UUID under the server's backup group. Notes on the snapshot store the panel backup UUID.
func LocatePBSBySnapshot ¶ added in v1.4.0
func LocatePBSBySnapshot(client remote.Client, uuid string, suuid string, snapshot string) (*PBSBackup, error)
LocatePBSBySnapshot finds an existing PBS snapshot by its full snapshot path. The snapshot must belong to the requested server backup group.
func (*PBSBackup) Checksum ¶ added in v1.4.0
Checksum returns a SHA1 of the snapshot path for a stable panel checksum field companion; Details() also returns the snapshot path as Checksum with type "pbs".
func (*PBSBackup) Details ¶ added in v1.4.0
func (b *PBSBackup) Details(ctx context.Context, parts []remote.BackupPart) (*ArchiveDetails, error)
Details returns PBS snapshot identity and size for the panel callback.
func (*PBSBackup) Generate ¶ added in v1.4.0
func (b *PBSBackup) Generate(ctx context.Context, fsys *filesystem.Filesystem, ignore string) (*ArchiveDetails, error)
Generate streams the server directory to PBS without creating a local archive.
func (*PBSBackup) Path ¶ added in v1.4.0
Path returns an empty string — PBS backups are not stored as local files.
func (*PBSBackup) Remove ¶ added in v1.4.0
Remove forgets the PBS snapshot associated with this panel backup UUID.
func (*PBSBackup) Restore ¶ added in v1.4.0
Restore is unused for PBS when RestoreDirect is available; it restores into a temporary directory and invokes the callback for compatibility.
func (*PBSBackup) RestoreDirect ¶ added in v1.4.0
RestoreDirect restores the pxar archive for this backup into dest.
func (*PBSBackup) Size ¶ added in v1.4.0
Size returns the logical size reported by PBS for the snapshot.
func (*PBSBackup) SnapshotPath ¶ added in v1.4.0
SnapshotPath returns the resolved PBS snapshot path if known.
func (*PBSBackup) WithLogContext ¶ added in v1.4.0
WithLogContext attaches additional context to the log output for this backup.
type RangeResumeReader ¶ added in v1.5.0
type RangeResumeReader struct {
// contains filtered or unexported fields
}
RangeResumeReader wraps a backup download body. When the body fails before the full content was read and the server advertised byte ranges, it asks for the remainder with "Range: bytes=N-" and continues where it stopped.
func NewRangeResumeReader ¶ added in v1.5.0
func (*RangeResumeReader) Close ¶ added in v1.5.0
func (r *RangeResumeReader) Close() error
type RestoreCallback ¶
RestoreCallback is a generic restoration callback that exists for both local and remote backups allowing the files to be restored.
type ResumableBackup ¶ added in v1.5.0
type ResumableBackup struct {
Backup
// contains filtered or unexported fields
}
ResumableBackup uploads the archive to a resumable upload session that the panel opened with the user's storage provider. Wings only ever receives the session URL and short-lived headers, never the provider's refresh tokens.
func NewResumable ¶ added in v1.5.0
func (*ResumableBackup) Generate ¶ added in v1.5.0
func (r *ResumableBackup) Generate(ctx context.Context, fsys *filesystem.Filesystem, ignore string) (*ArchiveDetails, error)
Generate creates the archive on disk (the same as the S3 adapter, the total size must be known before the session is used), uploads it in chunks and removes the local copy.
func (*ResumableBackup) Remove ¶ added in v1.5.0
func (r *ResumableBackup) Remove() error
func (*ResumableBackup) Restore ¶ added in v1.5.0
func (r *ResumableBackup) Restore(ctx context.Context, rd io.Reader, callback RestoreCallback) error
Restore reads a gzipped tar archive; the router fetches it from download_url.
func (*ResumableBackup) WithLogContext ¶ added in v1.5.0
func (r *ResumableBackup) WithLogContext(c map[string]interface{})
type S3Backup ¶
type S3Backup struct {
Backup
}
func (*S3Backup) Generate ¶
func (s *S3Backup) Generate(ctx context.Context, fsys *filesystem.Filesystem, ignore string) (*ArchiveDetails, error)
Generate creates a new backup on the disk, moves it into the S3 bucket via the provided presigned URL, and then deletes the backup from the disk.
func (*S3Backup) Restore ¶
Restore will read from the provided reader assuming that it is a gzipped tar reader. When a file is encountered in the archive the callback function will be triggered. If the callback returns an error the entire process is stopped, otherwise this function will run until all files have been written.
This restoration uses a workerpool to use up to the number of CPUs available on the machine when writing files to the disk.
func (*S3Backup) WithLogContext ¶
WithLogContext attaches additional context to the log output for this backup.