backup

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportData

func ImportData(s BackupStore, b *Backup, force bool) error

ImportData inserts backup data into the store in dependency order. If force is false, it refuses to import into a non-empty database. If force is true and the database is non-empty, it wipes all data first.

func Pack

func Pack(files map[string][]byte, passphrase string) ([]byte, error)

Pack creates a tar archive from the file map, compresses with xz, and encrypts with an age passphrase. Returns the encrypted bytes.

func Unpack

func Unpack(data []byte, passphrase string) (map[string][]byte, error)

Unpack decrypts with an age passphrase, decompresses xz, extracts tar, and returns the file map.

Types

type Backup

type Backup struct {
	Version         int                 `json:"version"`
	ExportedAt      time.Time           `json:"exported_at"`
	Users           []BackupUser        `json:"users"`
	Channels        []BackupChannel     `json:"channels"`
	ChannelMembers  map[string][]string `json:"channel_members"`
	Messages        []BackupMessage     `json:"messages"`
	Roles           []BackupRole        `json:"roles"`
	RolePermissions map[string][]string `json:"role_permissions"`
	Settings        map[string]string   `json:"settings"`
	DMs             []BackupDM          `json:"dms"`
}

Backup is the top-level JSON-serializable backup format.

func ExportData

func ExportData(s domain.Store) (*Backup, error)

ExportData reads all data from the store and returns a Backup struct.

type BackupChannel

type BackupChannel struct {
	Name   string `json:"name"`
	Public bool   `json:"public"`
	Type   string `json:"type"`
}

BackupChannel represents a non-DM channel in the backup.

type BackupDM

type BackupDM struct {
	User1       string `json:"user1"`
	User2       string `json:"user2"`
	ChannelName string `json:"channel_name"`
}

BackupDM represents a direct message channel in the backup.

type BackupMessage

type BackupMessage struct {
	ID        int       `json:"id"`
	Channel   string    `json:"channel"`
	From      string    `json:"from"`
	Body      string    `json:"body"`
	ThreadID  *int      `json:"thread_id"`
	Mentions  []string  `json:"mentions"`
	CreatedAt time.Time `json:"created_at"`
}

BackupMessage represents a message in the backup.

type BackupRole

type BackupRole struct {
	Name    string `json:"name"`
	BuiltIn bool   `json:"built_in"`
}

BackupRole represents a role in the backup.

type BackupStore

type BackupStore = domain.BackupStore

BackupStore is an alias for domain.BackupStore, re-exported from this package for backward compatibility with existing callers (cmd/backup, tests). The canonical definition lives in pkg/domain/ports.go so that any reader of the central ports file sees the full production storage contract.

type BackupUser

type BackupUser struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Role     string `json:"role"`
	Type     string `json:"type"`
}

BackupUser represents a user in the backup.

type ObjectInfo

type ObjectInfo struct {
	Key          string
	Size         int64
	LastModified time.Time
}

ObjectInfo describes a backup object in S3.

type S3Config

type S3Config struct {
	Bucket    string
	Region    string
	Endpoint  string
	AccessKey string
	SecretKey string
}

S3Config holds the configuration for connecting to an S3-compatible store.

func (*S3Config) Download

func (c *S3Config) Download(ctx context.Context, key string) ([]byte, error)

Download reads the object at the given key from the configured bucket.

func (*S3Config) List

func (c *S3Config) List(ctx context.Context) ([]ObjectInfo, error)

List returns all objects in the bucket with the "sharkfin-backup-" prefix.

func (*S3Config) Upload

func (c *S3Config) Upload(ctx context.Context, key string, data []byte) error

Upload writes data to the given key in the configured bucket.

func (*S3Config) Validate

func (c *S3Config) Validate() error

Validate checks that all required fields are set.

Jump to

Keyboard shortcuts

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