-
Notifications
You must be signed in to change notification settings - Fork 0
STAC-23598: Restoring Stackgraph #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rb3ckers
reviewed
Oct 27, 2025
rb3ckers
reviewed
Oct 27, 2025
rb3ckers
reviewed
Oct 27, 2025
rb3ckers
reviewed
Oct 27, 2025
rb3ckers
reviewed
Oct 27, 2025
rb3ckers
reviewed
Oct 30, 2025
rb3ckers
approved these changes
Oct 30, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds Stackgraph backup/restore functionality to the StackState Backup CLI and introduces a new
layered architecture for better code organization and maintainability.
Architecture Changes
The directory layout has been reorganized to follow a clean layered architecture with explicit dependency
rules. The new structure consists of 4 layers:
internal/foundation/): Core utilities with no internal dependencies (config, logger,output)
internal/clients/): Service client wrappers (Kubernetes, Elasticsearch, S3/Minio)internal/orchestration/): High-level workflows that coordinate multiple services(portforward, scale)
cmd/): User-facing CLI commandsEach layer can only depend on lower layers, preventing circular dependencies and making the codebase more
maintainable and testable.
📖 For detailed architecture documentation, see ARCHITECTURE.md
New Commands
stackgraph listLists available Stackgraph backups from Minio S3 storage.
Example:
stackgraph restoreRestores a Stackgraph backup from Minio S3 storage with automatic deployment scaling and Kubernetes job
orchestration.
Restore Workflow
When you run stackgraph restore, the CLI performs the following steps:
- If --latest flag is specified: Automatically fetches the most recent backup from Minio
- If --archive flag is specified: Uses the explicitly provided archive name
- Warns that restore will PURGE all existing Stackgraph data
- Displays backup file and namespace
- Prompts for confirmation: Do you want to continue? (yes/no):
- Use --yes or -y flag to skip confirmation (useful for automation)
- Identifies and scales down affected deployments to zero replicas
- Waits for all pods to terminate gracefully
- Stores original replica counts for restoration
- ConfigMap: Contains the restore script and configuration
- Secret: Mounts Minio credentials for S3 access
- PersistentVolumeClaim (PVC): Temporary storage for backup data
- Job: Executes the restore operation in a pod with FORCE_DELETE="-force" environment variable
- If --background flag is NOT set:
- If --background flag IS set:
- Restores deployments to their original replica counts
- Automatically triggered after job completion (or immediately if --background is used)
- Kubernetes Job is automatically cleaned up via TTL (10 minutes after completion)
- PVC remains for troubleshooting and is cleaned up in the next restore
Usage
Usage:
sts-backup stackgraph restore [flags]
Flags:
--archive string Specific archive name to restore (e.g., sts-backup-20210216-0300.graph)
--background Run restore job in background without waiting for completion
-h, --help help for restore
--latest Restore from the most recent backup
-y, --yes Skip confirmation prompt
Example 1: Restore with Background Execution (Interactive).
Example 2: Restore Latest Backup with automatic approval
stackgraph check-and-finalizeCheck the status of a background Stackgraph restore job and clean up resources.
Usage
sts-backup stackgraph check-and-finalize --job [--wait] -n
Flags:
Note: This command automatically scales up deployments that were scaled down during restore.
Example: Checking if the job is still running
Example: Waiting for the job to finish