backup.go RawHistoryFolder

1package domain
2
3import (
4	"io"
5	"time"
6)
7
8// DBType identifies the database engine.
9type DBType string
10
11const (
12	DBTypePostgreSQL DBType = "postgresql"
13	DBTypeUnknown    DBType = "unknown"
14)
15
16// BackupSchedule defines when backups run.
17type BackupSchedule string
18
19const (
20	ScheduleHourly  BackupSchedule = "hourly"
21	ScheduleDaily   BackupSchedule = "daily"
22	ScheduleWeekly  BackupSchedule = "weekly"
23	ScheduleMonthly BackupSchedule = "monthly"
24)
25
26// BackupType distinguishes backup methods.
27type BackupType string
28
29const (
30	BackupTypeLogical       BackupType = "logical"
31	BackupTypeVolumeArchive BackupType = "volume_archive"
32)
33
34// VolumeBackupCompression identifies the archive compression format for volume backups.
35type VolumeBackupCompression string
36
37const (
38	VolumeBackupCompressionGzip VolumeBackupCompression = "gzip"
39	VolumeBackupCompressionZstd VolumeBackupCompression = "zstd"
40)
41
42// BackupJobStatus tracks backup job lifecycle state.
43type BackupJobStatus string
44
45const (
46	BackupStatusPending   BackupJobStatus = "pending"
47	BackupStatusRunning   BackupJobStatus = "running"
48	BackupStatusCompleted BackupJobStatus = "completed"
49	BackupStatusFailed    BackupJobStatus = "failed"
50)
51
52// DatabaseTarget is one declarative database backup target: the app name
53// is the identity, the service and database select the exact declaration
54// inside the app's ACTIVE record. Schedule is the declared backup
55// schedule of that database.
56type DatabaseTarget struct {
57	App         string
58	Service     string
59	Database    string
60	Schedule    BackupSchedule
61	ContainerID string
62}
63
64// BackupJob represents a scheduled or manual backup operation.
65type BackupJob struct {
66	ID string
67	// App is the canonical backup identity: an app name, never a domain.
68	App         string
69	Service     string
70	DBName      string
71	Schedule    BackupSchedule
72	Type        BackupType
73	Status      BackupJobStatus
74	StartedAt   time.Time
75	CompletedAt time.Time
76	SizeBytes   int64
77	FilePath    string
78	Error       string
79	Metadata    map[string]string
80}
81
82// BackupResult is returned after a backup operation completes.
83type BackupResult struct {
84	Job      BackupJob
85	Duration time.Duration
86}
87
88// DatabaseBackupJob represents a logical database backup operation.
89type DatabaseBackupJob = BackupJob
90
91// DatabaseBackupResult is returned after a database backup operation completes.
92type DatabaseBackupResult = BackupResult
93
94// RetentionPolicy defines how many backups to keep per schedule tier.
95type RetentionPolicy struct {
96	Hourly  int
97	Daily   int
98	Weekly  int
99	Monthly int
100}
101
102// DatabaseBackupRetentionPolicy defines how many database backups to keep per schedule tier.
103type DatabaseBackupRetentionPolicy = RetentionPolicy
104
105// VolumeBackupRetentionPolicy defines how many volume backup archives to keep.
106type VolumeBackupRetentionPolicy struct {
107	Keep int
108}
109
110// BackupOverride allows per-domain backup configuration.
111type BackupOverride struct {
112	Schedules []BackupSchedule
113	Retention *RetentionPolicy
114}
115
116// BackupConfig is the database backup configuration.
117type BackupConfig struct {
118	Enabled    bool
119	StorageDir string
120	Retention  RetentionPolicy
121	Overrides  map[string]BackupOverride
122}
123
124// DatabaseBackupConfig is the database backup configuration.
125type DatabaseBackupConfig = BackupConfig
126
127// VolumeBackupConfig is the volume backup configuration.
128type VolumeBackupConfig struct {
129	Enabled        bool
130	Interval       time.Duration
131	Compression    VolumeBackupCompression
132	Retention      VolumeBackupRetentionPolicy
133	Timeout        time.Duration
134	MaxConcurrency int
135	HelperImage    string
136	VolumePrefix   string
137	S3Bucket       string
138	S3Region       string
139	S3Prefix       string
140	S3Endpoint     string
141	S3PathStyle    bool
142	S3SSEAlgorithm string
143	S3SSEKMSKeyID  string
144}
145
146// VolumeBackupJob represents a filesystem archive backup of a named volume.
147type VolumeBackupJob struct {
148	ID string
149	// App is the canonical backup identity: an app name, never a domain.
150	App               string
151	Service           string
152	ContainerName     string
153	ContainerID       string
154	VolumeName        string
155	RuntimeVolumeName string
156	MountPath         string
157	Type              BackupType
158	Status            BackupJobStatus
159	StartedAt         time.Time
160	CompletedAt       time.Time
161	SizeBytes         int64
162	ArtifactRef       string
163	Error             string
164	Metadata          map[string]string
165}
166
167// VolumeBackupTarget identifies one declared volume backup source:
168// app, service, and the declared volume name. RuntimeVolumeName is the
169// runtime volume the archive is exported from, and MountPath is the
170// declared mount path inside that volume.
171type VolumeBackupTarget struct {
172	App               string
173	Service           string
174	VolumeName        string
175	RuntimeVolumeName string
176	MountPath         string
177}
178
179// VolumeArchiveRequest describes a volume archive export request.
180type VolumeArchiveRequest struct {
181	VolumeName  string
182	MountPath   string
183	Compression VolumeBackupCompression
184	HelperImage string
185}
186
187// VolumeArchiveMetadata contains metadata observed while exporting a volume archive.
188type VolumeArchiveMetadata struct {
189	SizeBytes int64
190	Checksum  string
191}
192
193// VolumeArchiveResult contains a readable archive stream and export metadata.
194type VolumeArchiveResult struct {
195	Stream   io.ReadCloser
196	Metadata VolumeArchiveMetadata
197}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close