backup

package
v1.0.0-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2020 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	sync.Mutex

	TrimPrefix string
	Files      *IncludedFiles
}

func (*Archive) Create

func (a *Archive) Create(dest string, ctx context.Context) error

Creates an archive at dest with all of the files definied in the included files struct.

type ArchiveDetails

type ArchiveDetails struct {
	Checksum string `json:"checksum"`
	Size     int64  `json:"size"`
}

func (*ArchiveDetails) ToRequest

func (ad *ArchiveDetails) ToRequest(successful bool) api.BackupRequest

Returns a request object.

type Backup

type Backup interface {
	// Returns the UUID of this backup as tracked by the panel instance.
	Identifier() string

	// Generates a backup in whatever the configured source for the specific
	// implementation is.
	Backup(*IncludedFiles, string) error

	// Returns a SHA256 checksum for the generated backup.
	Checksum() ([]byte, error)

	// Returns the size of the generated backup.
	Size() (int64, error)

	// 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

	// Returns details about the archive.
	Details() *ArchiveDetails
}

type IncludedFiles

type IncludedFiles struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*IncludedFiles) All

func (i *IncludedFiles) All() map[string]*os.FileInfo

Returns all of the files that were marked as being included.

func (*IncludedFiles) Push

func (i *IncludedFiles) Push(info *os.FileInfo, p string)

Pushes an additional file or folder onto the struct.

type LocalBackup

type LocalBackup struct {
	// The UUID of this backup object. This must line up with a backup from
	// the panel instance.
	Uuid string `json:"uuid"`

	// An array of files to ignore when generating this backup. This should be
	// compatible with a standard .gitignore structure.
	IgnoredFiles []string `json:"ignored_files"`
}

func LocateLocal

func LocateLocal(uuid string) (*LocalBackup, os.FileInfo, error)

Locates 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) Backup

func (b *LocalBackup) Backup(included *IncludedFiles, prefix string) error

Generates a backup of the selected files and pushes it to the defined location for this instance.

func (*LocalBackup) Checksum

func (b *LocalBackup) Checksum() ([]byte, error)

Returns the SHA256 checksum of a backup.

func (*LocalBackup) Details

func (b *LocalBackup) Details() *ArchiveDetails

Returns details of the archive by utilizing two go-routines to get the checksum and the size of the archive.

func (*LocalBackup) Identifier

func (b *LocalBackup) Identifier() string

func (*LocalBackup) Path

func (b *LocalBackup) Path() string

Returns the path for this specific backup.

func (*LocalBackup) Remove

func (b *LocalBackup) Remove() error

Removes a backup from the system.

func (*LocalBackup) Size

func (b *LocalBackup) Size() (int64, error)

Return the size of the generated backup.

type S3Backup

type S3Backup struct {
	// The UUID of this backup object. This must line up with a backup from
	// the panel instance.
	Uuid string

	// An array of files to ignore when generating this backup. This should be
	// compatible with a standard .gitignore structure.
	IgnoredFiles []string
}

func (*S3Backup) Backup

func (s *S3Backup) Backup(included *IncludedFiles, prefix string) error

func (*S3Backup) Checksum

func (s *S3Backup) Checksum() ([]byte, error)

func (*S3Backup) Details

func (s *S3Backup) Details() *ArchiveDetails

func (*S3Backup) Identifier

func (s *S3Backup) Identifier() string

func (*S3Backup) Path

func (s *S3Backup) Path() string

func (*S3Backup) Size

func (s *S3Backup) Size() (int64, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL