This commit is contained in:
Madzone
2026-09-08 10:33:38 +02:00
parent c56f4c4b7d
commit f85c7c9e52
18 changed files with 5693 additions and 0 deletions
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,73 @@
#!/bin/bash
# Offizielle Quellen nach Distribution:
# Offizielle Debian Cloud-Images
# https://cloud.debian.org/images/cloud/
#
# Die .qcow2-Dateien wählen — Format genericcloud oder nocloud.
#
# https://cloud-images.ubuntu.com/
# .img-Dateien (verkleidetes qcow2-Format) — die cloudimg-Version nehmen.
# Rocky Linux / AlmaLinux
#
# https://rockylinux.org/alternative-images # "Cloud & Container Images"
# AlmaLinux
# https://wiki.almalinux.org/cloud/Generic-cloud.html
# Fedora / CentOS Stream
# https://fedoraproject.org/cloud/download
# https://www.centos.org/download/
#
# Download und direkter Import auf Proxmox:
# Beispiel mit Debian 12!
cd /var/lib/vz/template/
# wget https://cloud.debian.org/images/cloud/trixie/latest/debian-13-generic-amd64.qcow2 .
wget https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2 .
# VM-Template erstellen
qm create 9001 \
--name debian-12-cloudinit \
--memory 2048 \
--cores 2 \
--net0 virtio,bridge=vmbr0 \
--serial0 socket \
--vga serial0 \
--agent enabled=1
# Disk importieren
# qm importdisk 9000 /var/lib/vz/template/debian-13-generic-amd64.qcow2 local-lvm -format qcow2
qm importdisk 9001 /var/lib/vz/template/debian-12-generic-amd64.qcow2 local-lvm -format qcow2
# Importierte Disk anhängen
qm set 9001 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9001-disk-0
# Cloudinit-Drive hinzufügen
qm set 9001 --ide2 local-lvm:cloudinit --boot c --bootdisk scsi0 --serial0 socket --vga serial0
# Boot konfigurieren
qm resize 9001 scsi0 +20G
qm set 9001 --ipconfig0 ip=dhcp
qm set 9001 --sshkey ~/.ssh/id_rsa.pub
qm cloudinit dump 9001 user
qm template 9001
# Template mit Cloud-Init verwenden:
# Template klonen
export vmid=$(pvesh get /cluster/nextid)
# echo $vmid
qm clone 9001 $vmid --name meine-tolle-vm-$vmid --full
# Cloud-Init konfigurieren
qm set $vmid \
--ciuser giom \
--cipassword Inett1nett \
--sshkeys /root/.ssh/authorized_keys \
--ipconfig0 ip=dhcp \
--nameserver 10.1.99.254
# Starten
qm start $vmid
@@ -0,0 +1,34 @@
#!/bin/bash
export lxcid=$(pvesh get /cluster/nextid)
# echo $lxcid
pct create 8$lxcid /mnt/pve/nfs/template/cache/debian-12-standard_12.12-1_amd64.tar.zst \
\
`# Ressourcen` \
--cores 2 \
--memory 2048 \
--swap 512 \
\
`# Storage` \
--storage local-lvm \
--rootfs local-lvm:10 \
\
`# Netzwerk` \
--net0 name=eth0,bridge=vmbr0,ip=dhcp,mtu=1500,firewall=0 \
\
`# DNS` \
--nameserver 10.1.99.254 \
--searchdomain training.inett.de \
\
`# Zugang` \
--password Inett1nett \
--ssh-public-keys /root/.ssh/authorized_keys \
\
`# Privilegien & features` \
--unprivileged 0 \
--features nesting=1 \
\
`# Timezone` \
--timezone Europe/Berlin \
\
`# Tags` \
--tags debian,LXC
@@ -0,0 +1,26 @@
#!/bin/bash
export PBS_PASSWORD=''bcd-ziemlich_geheim_1234 # Token Secret
export PBS_USER_STRING='user@domain!pbs-server-mein_toller_ID' # Token ID
export PBS_SERVER='pbs_server.domain.tld:8007' #PBS SERVER
export PBS_DATASTORE='mein_toller_datastore' # Datastore (im voraus in PBS erstellen !)
export PBS_REPOSITORY="${PBS_USER_STRING}@${PBS_SERVER}:${PBS_DATASTORE}"
export PBS_HOSTNAME="$(hostname -s)"
export PBS_ENCRYPTION_PASSWORD='' # Verschlüsselungspasswort, bleibt leer wenn man ein key lieber verwendet.
backup_json="/pfad/zu/meiner/logdatei.json"
timestamp=$(jq -r '.[] | select(.["backup-id"] == "'"$PBS_HOSTNAME"'") | .["last-backup"]' "$backup_json")
current_timestamp=$(date +%s)
time_diff=$((current_timestamp - timestamp))
four_hours=$((4 * 3600))
# Bin ich in meinem LAN ? Ich will nämlich kein Backup über VPN laufen lassen.
if /usr/sbin/ifconfig | awk '/^en/ { iface = $1; getline; sub("addr:", ""); print iface, $1, $2 }' | grep 10.11.12
then
if [ "$time_diff" -ge "$four_hours" ]; then
/usr/bin/notify-send Backup "Backup zu ${PBS_SERVER} wurde gestartet"
/usr/bin/proxmox-backup-client backup ${PBS_HOSTNAME}.pxar:/home/ --keyfile /pfad/zu/meiner/tollen/verschluesselungskey -ns home --skip-lost-and-found -exclude */.cache/ -exclude */cache/ -exclude */Cache/ && /usr/bin/notify-send Backup "Backup von /home/ ist vollendet."
fi
fi
Binary file not shown.