# README
Kube-Save-Restore
A robust and user-friendly tool for backing up and restoring Kubernetes resources
Introduction • Features • Installation • Usage • Configuration • Contributing • License
Introduction
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.
Features
🔄 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.
Installation
Go Install
go install github.com/chaoscypher/kube-save-restore@latest
Building from Source
-
Clone the repository:
git clone [email protected]: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
Usage
kube-save-restore offers two primary modes: backup
and restore
.
Backup
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.
Restore
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.
Additional Options
- 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
Configuration
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.
Contributing
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 [email protected]: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.
Coding Standards
- 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.
Reporting Issues
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.
License
kube-save-restore is open-source software licensed under the MIT License.
Contact
For any inquiries or support, please open an issue on the GitHub repository.
Made with ❤️ by ChaosCypher