Update TAG-Struktur: auto-backup + flexible Klassifizierung (env, tenant, backup-server)
- Neue NETBOX-TAGS.md Dokumentation mit kompletter TAG-Strategie - Kestra-Workflow aktualisiert auf auto-backup TAG - GETTING_STARTED.md mit neuem TAG-System aktualisiert - Git-Repo-URL von jonny zu claude geändert - Unterstützt Multiple Tenants/Kunden und Umgebungen
This commit is contained in:
parent
ca16aaddd3
commit
418da4356b
|
|
@ -5,7 +5,7 @@ Schnelleinstieg für MBO-Tech-IT Backup-Automation.
|
|||
## Schritt 1: Repository klonen
|
||||
|
||||
```bash
|
||||
git clone https://gitea.mbo-tech-it.de/jonny/backup-automation.git
|
||||
git clone https://gitea.mbo-tech-it.de/claude/backup-automation.git
|
||||
cd backup-automation
|
||||
```
|
||||
|
||||
|
|
@ -41,32 +41,48 @@ ansible-playbook ansible/playbooks/configure-backup-server.yaml \
|
|||
-e "hetzner_s3_secret_key=$HETZNER_S3_SECRET_KEY"
|
||||
```
|
||||
|
||||
## Schritt 4: Netbox vorbereiten
|
||||
## Schritt 4: Netbox TAGs vorbereiten
|
||||
|
||||
### In Netbox UI:
|
||||
1. Gehe zu **Admin** → **Extras** → **Tags**
|
||||
2. Klicke **Add Tag**
|
||||
3. Setze:
|
||||
- **Name**: `backup`
|
||||
- **Slug**: `backup`
|
||||
- **Color**: Orange
|
||||
### TAGs in Netbox erstellen
|
||||
|
||||
### Systeme taggen:
|
||||
1. Gehe zu **DCIM** → **Devices**
|
||||
2. Für jedes zu backupendes System:
|
||||
- Öffne Device
|
||||
- Unter **Tags** → `backup` hinzufügen
|
||||
- Save
|
||||
**Admin → Customization → Tags** und folgende TAGs anlegen:
|
||||
|
||||
Oder via API:
|
||||
| Name | Slug | Farbe |
|
||||
|------|------|-------|
|
||||
| auto-backup | auto-backup | 🟢 |
|
||||
| env:prod | env-prod | 🔴 |
|
||||
| env:staging | env-staging | 🟡 |
|
||||
| env:dev | env-dev | 🔵 |
|
||||
|
||||
**Erforderlich:** Mindestens `auto-backup`
|
||||
**Optional:** Umgebungs-TAGs, Tenant-TAGs, etc. (siehe `docs/NETBOX-TAGS.md`)
|
||||
|
||||
### Systeme taggen
|
||||
|
||||
**DCIM → Devices** → Gerät öffnen → **Tags** hinzufügen
|
||||
|
||||
**Beispiel Production-Server:**
|
||||
```
|
||||
✓ auto-backup (erforderlich!)
|
||||
✓ env:prod (optional)
|
||||
```
|
||||
|
||||
**Oder via API:**
|
||||
```bash
|
||||
DEVICE_ID=123
|
||||
curl -X PATCH https://netbox.mbo-tech-it.de/api/dcim/devices/$DEVICE_ID/ \
|
||||
-H "Authorization: Token $NETBOX_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"tags": [{"name": "backup"}]}'
|
||||
-d '{
|
||||
"tags": [
|
||||
{"name": "auto-backup"},
|
||||
{"name": "env:prod"}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
**Details zur TAG-Struktur:** Siehe `docs/NETBOX-TAGS.md`
|
||||
|
||||
## Schritt 5: Kestra Workflow einrichten
|
||||
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -0,0 +1,181 @@
|
|||
# Netbox TAG-Struktur für Backup-Automation
|
||||
|
||||
## Übersicht
|
||||
|
||||
Das Backup-System verwendet ein flexibles TAG-System in Netbox zur Identifikation und Klassifizierung von Systemen.
|
||||
|
||||
## TAG-Struktur
|
||||
|
||||
### 1. Basis-TAG: `auto-backup`
|
||||
**Erforderlich** für alle Systeme, die automatisch gebackuped werden sollen.
|
||||
|
||||
- Name: `auto-backup`
|
||||
- Slug: `auto-backup`
|
||||
- Farbe: Grün (#28a745)
|
||||
- Description: "System wird täglich automatisch gebackuped"
|
||||
|
||||
### 2. Umgebungs-TAGs (optional)
|
||||
Kennzeichnet die Umgebung des Systems.
|
||||
|
||||
| TAG | Slug | Farbe | Beschreibung |
|
||||
|-----|------|-------|-------------|
|
||||
| `env:prod` | `env-prod` | Rot (#dc3545) | Production |
|
||||
| `env:staging` | `env-staging` | Gelb (#ffc107) | Staging/Pre-Production |
|
||||
| `env:dev` | `env-dev` | Blau (#0d6efd) | Development |
|
||||
| `env:test` | `env-test` | Grau (#6c757d) | Test |
|
||||
|
||||
### 3. Tenant/Kunden-TAGs (optional)
|
||||
Kennzeichnet welchem Kunden/Tenant ein System gehört.
|
||||
|
||||
```
|
||||
tenant:kunde1
|
||||
tenant:kunde2
|
||||
tenant:meine-domain.de
|
||||
tenant:internal
|
||||
```
|
||||
|
||||
- Slug: `tenant-<name>`
|
||||
- Farbe: Orange (#fd7e14)
|
||||
- Description: "Zugehörigkeit zu Tenant/Kunde"
|
||||
|
||||
### 4. Backup-Server-TAGs (optional)
|
||||
Gibt an, welcher Backup-Server verwendet werden soll.
|
||||
|
||||
```
|
||||
backup-server:primary (Standard Backup-Server)
|
||||
backup-server:secondary (Sekundärer/Fallback Server)
|
||||
backup-server:kunde-dedicated (Kundenspezifischer Server)
|
||||
```
|
||||
|
||||
- Slug: `backup-server-<name>`
|
||||
- Farbe: Lila (#6f42c1)
|
||||
- Description: "Ziel-Backup-Server"
|
||||
|
||||
### 5. Zusätz-TAGs (optional, zukünftig)
|
||||
|
||||
```
|
||||
backup-schedule:hourly (Stündliche Backups)
|
||||
backup-schedule:daily (Tägliche Backups - default)
|
||||
backup-schedule:weekly (Wöchentliche Backups)
|
||||
|
||||
backup-retention:short (7 Tage)
|
||||
backup-retention:medium (4 Wochen)
|
||||
backup-retention:long (12 Monate)
|
||||
|
||||
backup-priority:high (Bevorzugte Ausführung)
|
||||
backup-priority:normal (Standard)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Praktische Beispiele
|
||||
|
||||
### Beispiel 1: Production-System (intern)
|
||||
```
|
||||
auto-backup
|
||||
env:prod
|
||||
backup-server:primary
|
||||
```
|
||||
|
||||
### Beispiel 2: Kundensystem mit eigener Umgebung
|
||||
```
|
||||
auto-backup
|
||||
env:prod
|
||||
tenant:kunde1
|
||||
backup-server:primary
|
||||
backup-retention:long
|
||||
```
|
||||
|
||||
### Beispiel 3: Staging-System
|
||||
```
|
||||
auto-backup
|
||||
env:staging
|
||||
backup-server:secondary
|
||||
```
|
||||
|
||||
### Beispiel 4: Development-System
|
||||
```
|
||||
auto-backup
|
||||
env:dev
|
||||
backup-server:secondary
|
||||
backup-retention:short
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Kestra-Abfragen
|
||||
|
||||
### Standard: Alle auto-backup Systeme
|
||||
```bash
|
||||
/api/dcim/devices/?tag=auto-backup
|
||||
```
|
||||
|
||||
### Mit Filterung (zukünftig erweiterbar)
|
||||
```bash
|
||||
# Nur Production-Systeme
|
||||
/api/dcim/devices/?tag=auto-backup&tag=env:prod
|
||||
|
||||
# Nur Kundensysteme
|
||||
/api/dcim/devices/?tag=auto-backup&tag=tenant:kunde1
|
||||
|
||||
# Alle mit sekundärem Server
|
||||
/api/dcim/devices/?tag=backup-server:secondary
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Setup in Netbox
|
||||
|
||||
### 1. TAGs erstellen
|
||||
|
||||
**Admin → Customization → Tags**
|
||||
|
||||
Erstelle folgende TAGs:
|
||||
|
||||
| Name | Slug | Farbe |
|
||||
|------|------|-------|
|
||||
| auto-backup | auto-backup | 🟢 |
|
||||
| env:prod | env-prod | 🔴 |
|
||||
| env:staging | env-staging | 🟡 |
|
||||
| env:dev | env-dev | 🔵 |
|
||||
| tenant:* | tenant-* | 🟠 |
|
||||
| backup-server:* | backup-server-* | 🟣 |
|
||||
|
||||
### 2. Systems taggen
|
||||
|
||||
**DCIM → Devices** → Gerät öffnen → **Tags** hinzufügen
|
||||
|
||||
Beispiel für einen Production-Webserver:
|
||||
```
|
||||
✓ auto-backup
|
||||
✓ env:prod
|
||||
✓ backup-server:primary
|
||||
```
|
||||
|
||||
### 3. Überprüfung
|
||||
|
||||
```bash
|
||||
# SSH auf einen Server mit Netbox-Zugriff
|
||||
curl -s "https://netbox.mbo-tech-it.de/api/dcim/devices/?tag=auto-backup" \
|
||||
-H "Authorization: Token YOUR_TOKEN" | jq '.results[] | {name, tags}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Zukünftige Erweiterungen
|
||||
|
||||
Das System ist designed für:
|
||||
- ✅ Mehrere Backup-Server
|
||||
- ✅ Mehrere Tenants/Kunden
|
||||
- ✅ Unterschiedliche Umgebungen
|
||||
- ✅ Custom Retention Policies
|
||||
- ✅ Priorisierte Backups
|
||||
- ✅ Stündliche/Wöchentliche/Custom Schedules
|
||||
|
||||
Einfach neue TAGs hinzufügen und Kestra-Workflow erweitern.
|
||||
|
||||
---
|
||||
|
||||
**Version**: 1.0
|
||||
**Datum**: 2026-09-09
|
||||
**Maintainer**: Jonny (MBO-Tech-IT)
|
||||
|
|
@ -12,16 +12,18 @@ triggers:
|
|||
variables:
|
||||
netbox_url: "https://netbox.mbo-tech-it.de"
|
||||
netbox_api_token: "{{ secret('NETBOX_TOKEN') }}"
|
||||
backup_tag: "backup"
|
||||
backup_tag_value: "true"
|
||||
# Basis-TAG für automatische Backups (erforderlich)
|
||||
backup_tag_base: "auto-backup"
|
||||
# Optional: Weitere TAGs können hinzugefügt werden
|
||||
# z.B. env:prod, tenant:kunde1, backup-server:primary
|
||||
ansible_inventory_file: "/tmp/netbox_inventory.ini"
|
||||
git_repo: "https://gitea.mbo-tech-it.de/jonny/backup-automation.git"
|
||||
git_repo: "https://gitea.mbo-tech-it.de/claude/backup-automation.git"
|
||||
|
||||
tasks:
|
||||
# Task 1: Netbox Abfrage
|
||||
# Task 1: Netbox Abfrage - Alle Systems mit "auto-backup" TAG
|
||||
- id: fetch-backup-systems
|
||||
type: io.kestra.plugin.core.http.Request
|
||||
uri: "{{ vars.netbox_url }}/api/dcim/devices/?tag={{ vars.backup_tag }}:{{ vars.backup_tag_value }}&limit=500"
|
||||
uri: "{{ vars.netbox_url }}/api/dcim/devices/?tag={{ vars.backup_tag_base }}&limit=500"
|
||||
headers:
|
||||
Authorization: "Token {{ vars.netbox_api_token }}"
|
||||
method: GET
|
||||
|
|
@ -131,9 +133,9 @@ backup_repo_base=/backup/repos
|
|||
ssh -i ~/.ssh/id_ed25519 backup@{BACKUP_SERVER_HOSTNAME} << 'EOF'
|
||||
source /home/backup/.bashrc
|
||||
|
||||
# Hole Device-Liste aus Netbox
|
||||
# Hole Device-Liste aus Netbox (nur Systems mit auto-backup TAG)
|
||||
DEVICES=$(curl -s -H "Authorization: Token {{ vars.netbox_api_token }}" \
|
||||
"{{ vars.netbox_url }}/api/dcim/devices/?tag=backup:true&limit=500" \
|
||||
"{{ vars.netbox_url }}/api/dcim/devices/?tag={{ vars.backup_tag_base }}&limit=500" \
|
||||
| jq -r '.results[].name')
|
||||
|
||||
for device in $DEVICES; do
|
||||
|
|
|
|||
Loading…
Reference in New Issue