A robust and user-friendly tool for backing up and restoring Kubernetes resources
Introduction • Features • Installation • Usage • Configuration • Contributing • License
Ever wanted to do an old fashioned backup of your Kubernetes clusters resources? Enter kube-save-restore, your cluster's personal bodyguard. It backs up resources faster than you can say "kubectl", whether you're managing a cozy cluster or a Kubernetes behemoth. Think of it as a time machine for your cluster - minus the paradoxes! Let kube-save-restore protect you from data loss and config mishaps.
🔄 Comprehensive Backup: Capture deployments, services, configmaps, secrets, statefulsets, and more across all namespaces.
🚀 Seamless Restore: Restore your Kubernetes resources with ease, ensuring minimal downtime.
🧪 Dry Run Mode: Validate backup and restore operations without making actual changes.
⚡ Concurrent Processing: Utilize worker pools for efficient handling of multiple resources.
📊 Customizable Logging: Configure log levels and output destinations to suit your monitoring needs.
🛠️ Configuration Flexibility: Easily configure via flags or environment variables.
🧬 Automated Testing: Comprehensive test suite ensuring reliability and stability.
go install github.com/chaoscypher/kube-save-restore@latest
-
Clone the repository:
git clone git@github.com:ChaosCypher/kube-save-restore.git
-
Navigate to the project directory:
cd kube-save-restore
-
Build the binary:
go build -o kube-save-restore
-
Move the binary to your PATH:
sudo mv kube-save-restore /usr/local/bin/
-
Run the binary:
kube-save-restore --help
kube-save-restore offers two primary modes: backup
and restore
.
To create a backup of your Kubernetes resources:
./kube-save-restore --mode=backup --backup-dir=/path/to/backup --dry-run=false --log-level=info
This command will backup all supported resources from all namespaces in your cluster.
To restore your Kubernetes resources from a backup:
./kube-save-restore --mode=restore --restore-dir=/path/to/backup --dry-run=true --log-level=debug
It's recommended to use the --dry-run=true
flag first to verify the restore operation before applying changes.
- Use
--context
to specify a different Kubernetes context. - Set
--log-file
to save logs to a file instead of stdout. - Adjust
--log-level
to control the verbosity of logging.
For a full list of options, run:
./kube-save-restore --help
kube-save-restore can be configured using command-line flags or environment variables:
Flag | Environment Variable | Description |
---|---|---|
--kubeconfig |
KUBECONFIG |
Path to the kubeconfig file |
--context |
KUBE_CONTEXT |
Kubernetes context to use |
--backup-dir |
BACKUP_DIR |
Directory where backups will be stored |
--restore-dir |
RESTORE_DIR |
Directory from where backups will be restored |
--mode |
MODE |
Operation mode: backup or restore |
--dry-run |
DRY_RUN |
Execute a dry run without making any changes |
--log-level |
LOG_LEVEL |
Logging level: debug , info , warn , error |
--log-file |
LOG_FILE |
Path to the log file |
Environment variables take precedence over command-line flags.
We welcome contributions to kube-save-restore! Here's how you can contribute:
-
Fork the Repository: Start by forking the kube-save-restore repository.
-
Clone Your Fork:
git clone git@github.com:YourUsername/kube-save-restore.git
-
Create a Feature Branch:
git checkout -b feature/YourFeature
-
Make Your Changes: Implement your feature or bugfix.
-
Run Tests: Ensure all tests pass:
go test ./...
-
Commit Your Changes:
git commit -m "Add your feature"
-
Push to Your Fork:
git push origin feature/YourFeature
-
Open a Pull Request: Go to the original kube-save-restore repository and open a pull request with your changes.
- Follow Go best practices and idiomatic Go code style.
- Ensure your code is properly formatted using
gofmt
. - Write clear, concise commit messages.
- Include tests for new features or bugfixes.
- Update documentation as necessary.
If you find a bug or have a suggestion for improvement:
- Check the existing issues to avoid duplicates.
- If your issue isn't already listed, open a new issue.
- Clearly describe the problem or suggestion, including steps to reproduce if applicable.
kube-save-restore is open-source software licensed under the MIT License.
For any inquiries or support, please open an issue on the GitHub repository.
Made with ❤️ by ChaosCypher