backups

package
v0.0.0-...-792b534 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FreePlanBackupConstraints = &BackupConstraints{
	Create: &BackupCreateConstraints{
		TotalMaxMessages:          1000,
		MinPerChannel:             1,
		DefaultPerChannel:         100,
		JpegReencodeQuality:       75,
		GuildAssetReencodeQuality: 85,
	},
	Restore: &BackupRestoreConstraints{
		RoleDeleteSleep:    1 * timex.Second,
		RoleCreateSleep:    2 * timex.Second,
		ChannelDeleteSleep: 500 * timex.Millisecond,
		ChannelCreateSleep: 500 * timex.Millisecond,
		ChannelEditSleep:   1 * timex.Second,
		SendMessageSleep:   350 * timex.Millisecond,
		HttpClientTimeout:  10 * timex.Second,
		MaxBodySize:        250_000_000,
	},
	MaxServerBackups: 1,
	FileType:         "backup.server",
}

Functions

This section is empty.

Types

type BackupConstraints

type BackupConstraints struct {
	Create           *BackupCreateConstraints
	Restore          *BackupRestoreConstraints
	MaxServerBackups int    // How many backup/restore jobs can run concurrently per server
	FileType         string // The file type to use for backups
}

type BackupCreateConstraints

type BackupCreateConstraints struct {
	TotalMaxMessages          int // The maximum number of messages to backup
	MinPerChannel             int // The minimum number of messages per channel
	DefaultPerChannel         int // The default number of messages per channel
	JpegReencodeQuality       int // The quality to use when reencoding to JPEGs
	GuildAssetReencodeQuality int // The quality to use when reencoding guild assets
}

type BackupCreateOpts

type BackupCreateOpts struct {
	Channels                  []string       `description:"If set, the channels to prune messages from"`
	PerChannel                int            `description:"The number of messages per channel"`
	MaxMessages               int            `description:"The maximum number of messages to backup"`
	BackupMessages            bool           `description:"Whether to backup messages or not"`
	BackupGuildAssets         []string       `description:"What assets to back up"`
	IgnoreMessageBackupErrors bool           `description:"Whether to ignore errors while backing up messages or not and skip these channels"`
	RolloverLeftovers         bool           `description:"Whether to attempt rollover of leftover message quota to another channels or not"`
	SpecialAllocations        map[string]int `description:"Specific channel allocation overrides"`
	Encrypt                   string         `description:"The key to encrypt backups with, if any"`
}

Options that can be set when creatng a backup

type BackupMessage

type BackupMessage struct {
	Message *discordgo.Message `json:"message"`
}

Represents a backed up message

type BackupRestoreConstraints

type BackupRestoreConstraints struct {
	RoleDeleteSleep    timex.Duration // How long to sleep between role deletes
	RoleCreateSleep    timex.Duration // How long to sleep between role creates
	ChannelDeleteSleep timex.Duration // How long to sleep between channel deletes
	ChannelCreateSleep timex.Duration // How long to sleep between channel creates
	ChannelEditSleep   timex.Duration // How long to sleep between channel edits
	SendMessageSleep   timex.Duration // How long to sleep between message sends
	HttpClientTimeout  timex.Duration // How long to wait for HTTP requests to complete
	MaxBodySize        int64          // The maximum size of the backup file to download/use
}

type BackupRestoreOpts

type BackupRestoreOpts struct {
	IgnoreRestoreErrors bool               `description:"Whether to ignore errors while restoring or not and skip these channels/roles"`
	ProtectedChannels   []string           `description:"Channels to protect from being deleted"`
	ProtectedRoles      []string           `description:"Roles to protect from being deleted"`
	BackupSource        string             `description:"The source of the backup"`
	Decrypt             string             `description:"The key to decrypt backups with, if any"`
	ChannelRestoreMode  ChannelRestoreMode `description:"Channel backup restore method. Use 'full' if unsure"`
}

Options that can be set when restoring a backup

type ChannelRestoreMode

type ChannelRestoreMode string
const (
	ChannelRestoreModeFull           ChannelRestoreMode = "full"
	ChannelRestoreModeDiff           ChannelRestoreMode = "diff" // TODO
	ChannelRestoreModeIgnoreExisting ChannelRestoreMode = "ignore_existing"
)

type ServerBackupCreate

type ServerBackupCreate struct {
	// Constraints, this is auto-set by the job on jobserver and hence not configurable in this mode.
	Constraints *BackupConstraints

	// Backup options
	Options BackupCreateOpts
}

A job to create backup a server

func (*ServerBackupCreate) Exec

func (t *ServerBackupCreate) Exec(
	l *zap.Logger,
	state jobstate.State,
	progstate jobstate.ProgressState,
) (*types.Output, error)

func (*ServerBackupCreate) Expiry

func (t *ServerBackupCreate) Expiry() *time.Duration

func (*ServerBackupCreate) Fields

func (t *ServerBackupCreate) Fields() map[string]any

func (*ServerBackupCreate) LocalPresets

func (t *ServerBackupCreate) LocalPresets() *interfaces.PresetInfo

func (*ServerBackupCreate) Name

func (t *ServerBackupCreate) Name() string

func (*ServerBackupCreate) Resumable

func (t *ServerBackupCreate) Resumable() bool

func (*ServerBackupCreate) Validate

func (t *ServerBackupCreate) Validate(state jobstate.State) error

type ServerBackupRestore

type ServerBackupRestore struct {
	// Constraints, this is auto-set by the job in jobserver and hence not configurable in this mode.
	Constraints *BackupConstraints

	// Backup options
	Options BackupRestoreOpts
}

A job to restore a backup of a server

func (*ServerBackupRestore) Exec

func (t *ServerBackupRestore) Exec(
	l *zap.Logger,
	state jobstate.State,
	progstate jobstate.ProgressState,
) (*types.Output, error)

func (*ServerBackupRestore) Expiry

func (t *ServerBackupRestore) Expiry() *time.Duration

func (*ServerBackupRestore) Fields

func (t *ServerBackupRestore) Fields() map[string]any

func (*ServerBackupRestore) LocalPresets

func (t *ServerBackupRestore) LocalPresets() *interfaces.PresetInfo

func (*ServerBackupRestore) Name

func (t *ServerBackupRestore) Name() string

func (*ServerBackupRestore) Resumable

func (t *ServerBackupRestore) Resumable() bool

func (*ServerBackupRestore) Validate

func (t *ServerBackupRestore) Validate(state jobstate.State) error

Validate validates the job and sets up state if needed

Jump to

Keyboard shortcuts

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