backups

package
v0.22.9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBackupRoute

func AddBackupRoute(w http.ResponseWriter, req *http.Request)

AddBackupRoute godoc @Summary Create a new backup configuration @Description Creates a backup config and initializes the repository if needed. Requires premium licence and non-container mode. @Tags Backups @Accept json @Produce json @Param body body utils.SingleBackupConfig true "Backup configuration" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups [post]

func CheckRepository

func CheckRepository(repository, password string) error

CheckRepository verifies if a repository exists and is valid

func CreateBackupJob

func CreateBackupJob(config BackupConfig, crontab string)

CreateBackupJob creates a backup job configuration

func CreateForgetJob

func CreateForgetJob(config BackupConfig, crontab string)

func CreateRepository

func CreateRepository(repository, password string) error

CreateRepository initializes a new Restic repository

func CreateRestoreJob

func CreateRestoreJob(config RestoreConfig)

CreateRestoreJob creates a restore job configuration

func DeleteByTag

func DeleteByTag(repository string, password string, tag string) error

func DeleteRepository

func DeleteRepository(repository string) error

DeleteRepository removes a Restic repository

func EditBackupRoute

func EditBackupRoute(w http.ResponseWriter, req *http.Request)

EditBackupRoute godoc @Summary Edit an existing backup configuration @Tags Backups @Accept json @Produce json @Param body body utils.SingleBackupConfig true "Updated backup configuration" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Router /api/backups/edit [post]

func EditRepositoryPassword

func EditRepositoryPassword(repository, currentPassword, newPassword string) error

EditRepositoryPassword changes the password of an existing repository

func ExecRestic

func ExecRestic(args []string, env []string) (string, error)

ExecRestic executes a restic command with the given arguments and environment variables. If the command fails due to a stale repository lock (older than 1 month), it automatically unlocks and retries. For newer locks, the error is returned as-is so the user can decide whether to unlock manually.

func ForgetSnapshot

func ForgetSnapshot(repository, password, snapshot string) error

func ForgetSnapshotRoute

func ForgetSnapshotRoute(w http.ResponseWriter, req *http.Request)

ForgetSnapshotRoute godoc @Summary Forget (delete) a specific snapshot from a backup repository @Tags Backups @Produce json @Param name path string true "Backup name" @Param snapshot path string true "Snapshot ID to forget" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups/{name}/{snapshot}/forget [delete]

func GetBackupConfigRoute added in v0.22.0

func GetBackupConfigRoute(w http.ResponseWriter, req *http.Request)

GetBackupConfigRoute godoc @Summary Get a single backup configuration by name @Description Returns a single backup configuration from the server config. @Tags Backups @Produce json @Param name path string true "Backup name" @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Router /api/backups-config/{name} [get]

func InitBackups

func InitBackups()

func ListBackupConfigsRoute added in v0.22.0

func ListBackupConfigsRoute(w http.ResponseWriter, req *http.Request)

ListBackupConfigsRoute godoc @Summary List all backup configurations @Description Returns a map of all backup configurations from the server config, keyed by backup name. @Tags Backups @Produce json @Security BearerAuth @Success 200 {object} utils.APIResponse @Failure 403 {object} utils.HTTPErrorResult @Router /api/backups-config [get]

func ListDirectory

func ListDirectory(repository, password, snapshotID, path string) (string, error)

ListDirectory lists the contents of a directory in a specific snapshot

func ListDirectoryWithFilters

func ListDirectoryWithFilters(repository, password, snapshotID, path string, recursive bool, longFormat bool) (string, error)

ListDirectoryWithFilters lists directory contents with additional filters

func ListFoldersRoute

func ListFoldersRoute(w http.ResponseWriter, req *http.Request)

ListFoldersRoute godoc @Summary List folders in a backup snapshot @Tags Backups @Produce json @Param name path string true "Backup name" @Param snapshot path string true "Snapshot ID" @Param path query string false "Directory path within the snapshot" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups/{name}/{snapshot}/folders [get]

func ListRepos

func ListRepos(w http.ResponseWriter, req *http.Request)

ListRepos godoc @Summary List all backup repositories with their lock status @Tags Backups @Produce json @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Router /api/backups-repository [get]

func ListSnapshots

func ListSnapshots(repository, password string) (string, error)

ListSnapshots returns a list of all snapshots in the repository

func ListSnapshotsRoute

func ListSnapshotsRoute(w http.ResponseWriter, req *http.Request)

ListSnapshotsRoute godoc @Summary List snapshots for a specific backup @Tags Backups @Produce json @Param name path string true "Backup name" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups/{name}/snapshots [get]

func ListSnapshotsRouteFromRepo

func ListSnapshotsRouteFromRepo(w http.ResponseWriter, req *http.Request)

ListSnapshotsRouteFromRepo godoc @Summary List all snapshots in a backup repository (all backup tags) @Tags Backups @Produce json @Param name path string true "Backup name (used to resolve repository)" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups-repository/{name}/snapshots [get]

func ListSnapshotsWithFilters

func ListSnapshotsWithFilters(repository, password string, tags []string, host string, path string) (string, error)

ListSnapshotsWithFilters returns a filtered list of snapshots

func RemoveBackupRoute

func RemoveBackupRoute(w http.ResponseWriter, req *http.Request)

RemoveBackupRoute godoc @Summary Remove a backup configuration and its snapshots @Tags Backups @Produce json @Param name path string true "Backup name" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups/{name} [delete]

func RepoStatsRoute added in v0.21.0

func RepoStatsRoute(w http.ResponseWriter, req *http.Request)

RepoStatsRoute godoc @Summary Get repository statistics (size, file count, etc.) @Tags Backups @Produce json @Param name path string true "Backup name (used to resolve repository)" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups-repository/{name}/stats [get]

func RestoreBackupRoute

func RestoreBackupRoute(w http.ResponseWriter, req *http.Request)

RestoreBackupRoute godoc @Summary Restore files from a backup snapshot @Tags Backups @Accept json @Produce json @Param name path string true "Backup name" @Param body body object true "Restore request with snapshotId, target, and optional include paths" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 400 {object} utils.HTTPErrorResult @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups/{name}/restore [post]

func SplitJSONObjects

func SplitJSONObjects(input string) string

SplitJSONObjects splits a string containing multiple JSON objects, respecting quotes

func StatsRepository

func StatsRepository(repository, password string) (string, error)

func StatsRepositorySubfolder

func StatsRepositorySubfolder(repository, password, snapshot, path string) (string, error)

func StatsRepositorySubfolderRoute

func StatsRepositorySubfolderRoute(w http.ResponseWriter, req *http.Request)

StatsRepositorySubfolderRoute godoc @Summary Get restore size stats for a subfolder within a snapshot @Tags Backups @Produce json @Param name path string true "Backup name" @Param snapshot path string true "Snapshot ID" @Param path query string false "Subfolder path within the snapshot" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups/{name}/{snapshot}/subfolder-restore-size [get]

func UnlockRepository added in v0.21.0

func UnlockRepository(repository, password string) error

UnlockRepository removes locks from a restic repository

func UnlockRepositoryRoute added in v0.21.0

func UnlockRepositoryRoute(w http.ResponseWriter, req *http.Request)

UnlockRepositoryRoute godoc @Summary Unlock a backup repository (remove stale locks) @Tags Backups @Produce json @Param name path string true "Backup name" @Security BearerAuth @Success 200 {object} map[string]interface{} @Failure 403 {object} utils.HTTPErrorResult @Failure 404 {object} utils.HTTPErrorResult @Failure 500 {object} utils.HTTPErrorResult @Router /api/backups/{name}/unlock [post]

Types

type BackupConfig

type BackupConfig struct {
	Repository         string
	Password           string
	Source             string
	Name               string
	Tags               []string
	Exclude            []string
	Retention          string
	AutoStopContainers bool
}

type LockInfo added in v0.21.0

type LockInfo struct {
	Time      string `json:"time"`
	Exclusive bool   `json:"exclusive"`
	Hostname  string `json:"hostname"`
	Username  string `json:"username"`
	PID       int    `json:"pid"`
}

func GetLocks added in v0.21.0

func GetLocks(repository, password string) []LockInfo

GetLocks returns lock details for a repository

type RestoreConfig

type RestoreConfig struct {
	Repository         string
	Password           string
	SnapshotID         string
	Target             string
	Name               string
	Include            []string
	OriginalSource     string
	AutoStopContainers bool
}

Jump to

Keyboard shortcuts

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