v3.4.1 de8f68e

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// BackupKind tells database dumps and volume archives apart in metrics.
89type BackupKind string
90
91const (
92	BackupKindDatabase BackupKind = "database"
93	BackupKindVolume   BackupKind = "volume"
94)
95
96// BackupTargetRef identifies one backed-up resource in metrics. Target is
97// the database name for a dump and the declared volume name for an archive.
98type BackupTargetRef struct {
99	Kind    BackupKind
100	App     string
101	Service string
102	Target  string
103}
104
105// BackupRunRecord is the outcome of one backup, as reported to metrics.
106// StartedAt is the start of the run: stored backups are named after it, so
107// a live run and the same backup read back from storage after a restart
108// report the same time.
109type BackupRunRecord struct {
110	BackupTargetRef
111	Succeeded bool
112	Duration  time.Duration
113	SizeBytes int64
114	StartedAt time.Time
115}
116
117// DatabaseBackupJob represents a logical database backup operation.
118type DatabaseBackupJob = BackupJob
119
120// DatabaseBackupResult is returned after a database backup operation completes.
121type DatabaseBackupResult = BackupResult
122
123// RetentionPolicy defines how many backups to keep per schedule tier.
124type RetentionPolicy struct {
125	Hourly  int
126	Daily   int
127	Weekly  int
128	Monthly int
129}
130
131// DatabaseBackupRetentionPolicy defines how many database backups to keep per schedule tier.
132type DatabaseBackupRetentionPolicy = RetentionPolicy
133
134// VolumeBackupRetentionPolicy defines how many volume backup archives to keep.
135type VolumeBackupRetentionPolicy struct {
136	Keep int
137}
138
139// BackupOverride allows per-domain backup configuration.
140type BackupOverride struct {
141	Schedules []BackupSchedule
142	Retention *RetentionPolicy
143}
144
145// BackupConfig is the database backup configuration.
146type BackupConfig struct {
147	Enabled    bool
148	StorageDir string
149	Retention  RetentionPolicy
150	Overrides  map[string]BackupOverride
151}
152
153// DatabaseBackupConfig is the database backup configuration.
154type DatabaseBackupConfig = BackupConfig
155
156// VolumeBackupConfig is the volume backup configuration.
157type VolumeBackupConfig struct {
158	Enabled        bool
159	Schedule       CronSchedule
160	Compression    VolumeBackupCompression
161	Retention      VolumeBackupRetentionPolicy
162	Timeout        time.Duration
163	MaxConcurrency int
164	HelperImage    string
165	VolumePrefix   string
166	S3Bucket       string
167	S3Region       string
168	S3Prefix       string
169	S3Endpoint     string
170	S3PathStyle    bool
171	S3SSEAlgorithm string
172	S3SSEKMSKeyID  string
173	// S3StorageClass is sent with every upload; empty keeps the bucket default.
174	S3StorageClass string
175}
176
177// VolumeBackupJob represents a filesystem archive backup of a named volume.
178type VolumeBackupJob struct {
179	ID string
180	// App is the canonical backup identity: an app name, never a domain.
181	App               string
182	Service           string
183	ContainerName     string
184	ContainerID       string
185	VolumeName        string
186	RuntimeVolumeName string
187	MountPath         string
188	Type              BackupType
189	Status            BackupJobStatus
190	StartedAt         time.Time
191	CompletedAt       time.Time
192	SizeBytes         int64
193	ArtifactRef       string
194	Error             string
195	Metadata          map[string]string
196}
197
198// VolumeBackupTarget identifies one declared volume backup source:
199// app, service, and the declared volume name. RuntimeVolumeName is the
200// runtime volume the archive is exported from, and MountPath is the
201// declared mount path inside that volume.
202type VolumeBackupTarget struct {
203	App               string
204	Service           string
205	VolumeName        string
206	RuntimeVolumeName string
207	MountPath         string
208}
209
210// VolumeArchiveRequest describes a volume archive export request.
211type VolumeArchiveRequest struct {
212	VolumeName  string
213	MountPath   string
214	Compression VolumeBackupCompression
215	HelperImage string
216}
217
218// VolumeArchiveMetadata contains metadata observed while exporting a volume archive.
219type VolumeArchiveMetadata struct {
220	SizeBytes int64
221	Checksum  string
222}
223
224// VolumeArchiveResult contains a readable archive stream and export metadata.
225type VolumeArchiveResult struct {
226	Stream   io.ReadCloser
227	Metadata VolumeArchiveMetadata
228}

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