added backup script and backed up qnap
This commit is contained in:
68
README-portainer-backup.md
Normal file
68
README-portainer-backup.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# Portainer Stack Backup Script
|
||||
|
||||
This script connects to a Portainer instance and exports all stacks with their configurations, environment variables, and docker-compose files.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- `curl` (usually pre-installed on macOS)
|
||||
- `jq` for JSON processing: `brew install jq`
|
||||
|
||||
## Usage
|
||||
|
||||
1. Make sure the script is executable:
|
||||
```bash
|
||||
chmod +x portainer-backup.sh
|
||||
```
|
||||
|
||||
2. Run the script:
|
||||
```bash
|
||||
./portainer-backup.sh
|
||||
```
|
||||
|
||||
3. When prompted, enter:
|
||||
- Portainer URL (e.g., `http://localhost:9000`)
|
||||
- Username
|
||||
- Password
|
||||
|
||||
Alternatively, you can edit the script and set these variables at the top:
|
||||
```bash
|
||||
PORTAINER_URL="http://your-portainer-url:9000"
|
||||
USERNAME="your-username"
|
||||
PASSWORD="your-password"
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
The script creates a `portainer-stacks-backup` directory containing:
|
||||
|
||||
```
|
||||
portainer-stacks-backup/
|
||||
├── stack-name-1/
|
||||
│ ├── stack-info.json # Complete stack information
|
||||
│ ├── environment-variables.json # Environment variables as JSON
|
||||
│ ├── .env # Environment variables in .env format
|
||||
│ ├── docker-compose.yml # Stack's compose file
|
||||
│ └── metadata.txt # Human-readable metadata
|
||||
├── stack-name-2/
|
||||
│ └── ...
|
||||
```
|
||||
|
||||
## What gets backed up
|
||||
|
||||
For each stack:
|
||||
- Complete stack configuration (JSON format)
|
||||
- Environment variables (both JSON and .env formats)
|
||||
- Docker Compose file content
|
||||
- Metadata (creation date, status, type, etc.)
|
||||
|
||||
## Error Handling
|
||||
|
||||
The script includes error handling for:
|
||||
- Missing dependencies
|
||||
- Authentication failures
|
||||
- Network connectivity issues
|
||||
- API errors
|
||||
|
||||
## Security Note
|
||||
|
||||
The script handles authentication via JWT tokens. Passwords are prompted securely (hidden input) if not set in the script.
|
||||
Reference in New Issue
Block a user