certbotbot
Reference documentation for a modular Bash project
Loading...
Searching...
No Matches
Functions
backup.bash File Reference

Performs guarded, opt-in dated S3 backup publication. More...

Functions

int certbotbot_backup_error (String message, String status)
 Report a static backup failure without exposing AWS or secret data.
 
int certbotbot_backup_scope (String current)
 Build nonsecret v1 metadata binding the current key and UTC date.
 
int certbotbot_backup_head (String workspace, String bucket, String key)
 Inspect one exact key and return seven bounded tab-delimited fields.
 
int certbotbot_backup_head_valid (String row, String expected_size)
 Validate the S3 v1 managed-object identity and payload length.
 
int certbotbot_backup_prepare (String workspace, String bucket, String current, String backup)
 Validate destination and conditional-write capability before current PUT.
 
int certbotbot_backup_publish (String workspace, String bucket, String backup, String candidate, String content_type)
 Write and verify the identical validated current candidate.
 

Detailed Description

Performs guarded, opt-in dated S3 backup publication.

Implements ADR-033. The selected existing archive remains authoritative. This module verifies managed metadata, conditions every backup PUT on the exact destination's prior identity, and confirms the resulting object size and metadata through HEAD. It never lists, deletes or migrates objects. S3 metadata is untrusted; IAM protections and externally serialized writers are essential. No two-object transaction is promised.

Function Documentation

◆ certbotbot_backup_error()

int certbotbot_backup_error ( String  message,
String  status 
)

Report a static backup failure without exposing AWS or secret data.

Parameters
messageFixed nonsecret diagnostic text.
status64 for local settings, 69 for inspection, 74 for partial PUT.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Fixed diagnostic text.
Return values
64Local configuration error.
69Uncertain remote preflight.
74Current accepted but backup failed/uncertain.

◆ certbotbot_backup_head()

int certbotbot_backup_head ( String  workspace,
String  bucket,
String  key 
)

Inspect one exact key and return seven bounded tab-delimited fields.

Uses a fixed JMESPath query over S3 metadata, never eval or shell parsing of untrusted expressions. A 404 is available privately to the caller; unknown, malformed or multi-line responses must not authorize mutation.

Parameters
workspaceExisting private workspace.
bucketExact selected bucket.
keyExact resolved backup key.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
AWS stderr stays in private workspace, never exposed.
Returns
REPLY is the parsed text row on success.
Return values
0One bounded nonempty row.
1HeadObject failed, private stderr contains reason.
2Invalid output or occupied private paths.

◆ certbotbot_backup_head_valid()

int certbotbot_backup_head_valid ( String  row,
String  expected_size 
)

Validate the S3 v1 managed-object identity and payload length.

Parameters
rowUntrusted AWS metadata row.
expected_size0 for positive-size preflight or exact post-PUT size.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Nothing is written to STDERR.
Returns
CERTBOTBOT_BACKUP_ETAG for conditional replacement.
Return values
0Identity, nonzero size, and safe ETag are confirmed.
1Unverified, mismatched or malformed fields.

◆ certbotbot_backup_prepare()

int certbotbot_backup_prepare ( String  workspace,
String  bucket,
String  current,
String  backup 
)

Validate destination and conditional-write capability before current PUT.

A 404 plus HeadBucket success authorizes only conditional creation. Present same-date managed metadata authorizes only ETag-conditional replacement. All other identities, CLI capabilities or AWS errors fail before the authoritative current object is modified.

Parameters
workspacePrivate workspace.
bucketCurrent/backup bucket.
currentAuthoritative exact key.
backupValidated dated key.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Static diagnostics only.
Return values
0Guarded backup conditions prepared.
64Invalid local values.
69Missing capability or uncertain destination.

◆ certbotbot_backup_publish()

int certbotbot_backup_publish ( String  workspace,
String  bucket,
String  backup,
String  candidate,
String  content_type 
)

Write and verify the identical validated current candidate.

The current authoritative PUT must already have succeeded. A failed PUT, lost response, conflicting conditional request, missing or uncertain HEAD results in a nonzero partial-success outcome and stops all later work.

Parameters
workspaceCaller-owned private workspace.
bucketSelected existing S3 bucket.
backupFrozen dated key.
candidateExact locally verified candidate file.
content_typeExisting publisher's matching MIME type.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Fixed, nonsecret partial-success diagnostic.
Return values
0Accepted backup PUT and matching HEAD metadata/size.
74Accepted current but failed or uncertain backup publication.

◆ certbotbot_backup_scope()

int certbotbot_backup_scope ( String  current)

Build nonsecret v1 metadata binding the current key and UTC date.

Parameters
currentFrozen authoritative object key.
STDIN
Nothing is read from STDIN.
STDOUT
Nothing is written to STDOUT.
STDERR
Fixed error if SHA256 is unavailable.
Returns
CERTBOTBOT_BACKUP_METADATA and the expected current-key digest.
Return values
0Complete metadata prepared.
64Invalid identity or missing trusted hashing tool.