Documentation
¶
Index ¶
Constants ¶
const ArchiveVersion = "2.0"
ArchiveVersion is the version of the archive layout this server writes and restores. 2.0 stores package data as rows of the generic package tables; the 1.x archives of 0.14 and older carry per-format tables and are not restorable.
const DefaultLeaseTTL = 5 * time.Minute
DefaultLeaseTTL is how long a backup's blob-retention lease survives without a heartbeat (see database.SnapshotReader).
Variables ¶
var ( // ErrBlobMissing reports a blob that the database snapshot lists but whose // bytes the store cannot produce. A backup without it could not be restored, // so the export fails instead of skipping it. ErrBlobMissing = errors.New("blob listed in the database snapshot is missing from storage") // ErrBlobCorrupt reports stored bytes that do not hash to their blob id or // do not have the recorded size. ErrBlobCorrupt = errors.New("stored blob does not match its recorded sha256 or size") // ErrBlobCountMismatch reports an archive that holds fewer blobs than the // snapshot lists. ErrBlobCountMismatch = errors.New("archive holds fewer blobs than the database snapshot lists") )
var ErrInvalidBlobEntry = errors.New("invalid blob entry")
ErrInvalidBlobEntry reports a malformed or untrusted blob entry in an archive.
var ErrMissingBlobSHA256 = errors.New("record has no blob sha256")
ErrMissingBlobSHA256 reports a backed-up record without its blob sha256.
var ErrNoStorageDescriptor = errors.New("format has no storage descriptor")
ErrNoStorageDescriptor reports a repository whose format has no storage descriptor: its package rows cannot be archived or restored, and a backup that silently left them out would look complete.
var ErrRestoreInProgress = errors.New("a restore is already in progress")
ErrRestoreInProgress is returned when a restore is already running (a second restore, or a backup, would interleave with it).
var ErrRestoreIncomplete = errors.New("restore completed with failures")
ErrRestoreIncomplete is returned when a restore finished but some records or blobs could not be restored.
var ErrUnsupportedArchive = errors.New(
"unsupported backup archive: backups of 0.14 and older cannot be restored; " +
"move the data with `oa import` (see docs/getting-started/upgrading.md)",
)
ErrUnsupportedArchive is returned for an archive of another layout version. Data of 0.14 and older moves to this version with `oa import` from the old server, not with a restore (docs/getting-started/upgrading.md).
Functions ¶
This section is empty.
Types ¶
type BackupManifest ¶
type BackupManifest struct {
Version string `json:"version"`
CreatedAt time.Time `json:"created_at"`
Type string `json:"type"`
TableCounts map[string]int `json:"table_counts"`
// SnapshotAt is when the database snapshot every table in the archive was
// read from was taken (all tables describe that one instant).
SnapshotAt time.Time `json:"snapshot_at"`
// BlobCount is the number of blobs the snapshot lists, i.e. how many
// blobs/ entries a full backup holds (it fails rather than write fewer).
BlobCount int `json:"blob_count,omitempty"`
}
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) RestoreInProgress ¶ added in v0.6.0
RestoreInProgress reports whether a restore is running right now.
func (*Engine) RunBackup ¶
RunBackup executes a backup job. It fails the job with ErrRestoreInProgress while a restore is running: the archive would capture a half-restored state.
func (*Engine) RunRestore ¶
RunRestore restores a backup from an archive. Only one restore runs at a time (ErrRestoreInProgress otherwise): restores create rows with server-side ids and keep per-run state, so two interleaved runs would corrupt each other's remaps and failure accounting.
func (*Engine) SetLeaseTTL ¶ added in v0.7.0
SetLeaseTTL sets how long a running backup's blob-retention lease lives without a heartbeat. Zero or negative selects DefaultLeaseTTL.
func (*Engine) SetWorkers ¶ added in v0.15.0
SetWorkers wires the metadata workers so a restore regenerates the generated metadata (deb, maven, rpm, ...) immediately instead of waiting for the next upload; each format's Changed lifecycle hook decides what to refresh.
type EngineStore ¶ added in v0.15.0
type EngineStore interface {
AddBundleItem(ctx context.Context, item *models.ReleaseBundleItem) error
AddGroupMember(ctx context.Context, groupRepoID string, memberRepoID string, priority int) error
AddProjectMember(ctx context.Context, projectID string, userID string, role string) error
AddUserToGroup(ctx context.Context, userID string, groupID string) error
SetGroupDeployTarget(ctx context.Context, groupRepoID string, memberRepoID string) error
BeginBackupSnapshot(ctx context.Context, leaseTTL time.Duration) (database.SnapshotReader, error)
CreateBundlePromotion(ctx context.Context, p *models.BundlePromotion) error
CreateCleanupPolicy(ctx context.Context, policy *models.CleanupPolicy) error
CreateDockerBlob(ctx context.Context, blob *models.DockerBlob) error
CreateDockerManifest(ctx context.Context, m *models.DockerManifest) error
CreateGroup(ctx context.Context, group *models.Group) (*models.Group, error)
CreateLicenseScanResult(ctx context.Context, result *models.LicenseScanResult) error
CreatePermissionTarget(ctx context.Context, target *models.PermissionTarget) (*models.PermissionTarget, error)
CreateProject(ctx context.Context, project *models.Project) error
CreatePromotionPipeline(ctx context.Context, p *models.PromotionPipeline) error
CreateRPMRepo(ctx context.Context, repo *models.RPMRepo) error
CreateReleaseBundle(ctx context.Context, b *models.ReleaseBundle) error
CreateRepository(ctx context.Context, repo *models.Repository) error
CreateSBOMReport(ctx context.Context, report *models.SBOMReport) error
CreateSSOProvider(ctx context.Context, provider *models.SSOProvider) error
CreateSecretScanResult(ctx context.Context, result *models.SecretScanResult) error
CreateStorageBackend(ctx context.Context, backend *models.StorageBackend) error
CreateToken(ctx context.Context, token *models.Token) (*models.Token, error)
CreateUser(ctx context.Context, user *models.User) (*models.User, error)
CreateVulnScanResult(ctx context.Context, result *models.VulnScanResult) error
CreateWebhook(ctx context.Context, wh *models.Webhook) error
EnsureBlob(ctx context.Context, sha256 string, mediaType string, size int64) (string, error)
GetBackupJob(ctx context.Context, id string) (*models.BackupJob, error)
GetOrCreatePermissionAssignment(ctx context.Context, targetID string, principalType string, principalID string) error
GetOrCreateStorageQuota(ctx context.Context, repoID string) (*models.StorageQuota, error)
GetPermissionTargetByName(ctx context.Context, name string) (*models.PermissionTarget, error)
GetRPMRepo(ctx context.Context, repositoryID string) (*models.RPMRepo, error)
MarkRepoStale(ctx context.Context, repositoryID string) error
ReconcileAllStorageUsage(ctx context.Context) (int64, error)
RestorePackageRows(ctx context.Context, set database.PackageRowSet, repoID string, rows []json.RawMessage) (int, error)
SetProjectGroup(ctx context.Context, projectID string, groupID string, role string, createdBy *string) error
SetProjectQuota(
ctx context.Context,
projectID string,
maxSizeBytes int64,
maxArtifactCount int64,
warnThresholdPercent int,
) (*models.ProjectQuota, error)
UpdateBackupJob(ctx context.Context, job *models.BackupJob) error
UpdateRepository(ctx context.Context, repo *models.Repository) error
UpdateStorageQuota(ctx context.Context, quota *models.StorageQuota) error
UpsertAIAnalysis(ctx context.Context, analysis *models.AIAnalysis) error
UpsertBlob(ctx context.Context, sha256 string, blobKey string, sizeBytes int64) (string, error)
UpsertDockerTag(ctx context.Context, tag *models.DockerTag) error
UpsertVEXStatement(ctx context.Context, s *models.VEXStatement) error
}
EngineStore is the part of the database Engine needs.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package backuptest holds test doubles for the backup engine.
|
Package backuptest holds test doubles for the backup engine. |