Added PVE-to-PBS-Backup & OVHCloud-DDNS-API-Setup

This commit is contained in:
2024-12-20 23:12:14 +01:00
parent d3bac3f71e
commit cadedc475f
6 changed files with 178 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
[Unit]
Description=PVE to PBS Backup
[Service]
Type=oneshot
ExecStart=/bin/bash /opt/PVEtoPBS.sh

View File

@@ -0,0 +1,9 @@
[Unit]
Description=Scheduled PVE to PBS Backup
[Timer]
OnCalendar=weekly
Persistent=true
[Install]
WantedBy=timers.target

View File

@@ -0,0 +1,55 @@
#!/bin/bash
#List of files to in/exclude form the backup located /.pxarexclude
#Scipt config
PBS_Host=<PBS_IP/Hostname>
PBS_Datastore=<DataStoreName>
PBS_User=root@pam!<APIKeyName>
export PBS_PASSWORD="<APIKey/Password>"
export PBS_FINGERPRINT="<PBS Fingerprint>"
PBS_NameSpace=PVE-Hosts
Run_Purge=false
Purge_DryRun=true
Run_GarbageColletion=false
##end of config
export PBS_LOG=info #Possible values are off, error, warn, info, debug and trace
export PBS_REPOSITORY="$PBS_User@$PBS_Host:$PBS_Datastore"
PVE_Hostname=$(hostname)
PBS_NameSpace=$PBS_NameSpace/"$PVE_Hostname"
echo "Generating package(APT) report"
apt-mark showmanual > /SystemRepport-APT
echo "Generating PVE report"
pvereport 2> /dev/null > /SystemRepport-PVE
echo "Running backup"
proxmox-backup-client backup root.pxar:/ --include-dev /etc/pve --ns $PBS_NameSpace
##Prunne while runing instead of using jobs in PBS
# Docs: https://pbs.proxmox.com/docs/backup-client.html#pruning-and-removing-backups
#
# Prune options --keep-last <N> --keep-hourly <N> --keep-daily <N> --keep-weekly <N> --keep-monthly <N> --keep-yearly <N>
#
# To test and generate a repport set Run_Purge and Purge_DryRun to true
# To use Run_Purge to true Purge_DryRun to false
if $Run_Purge; then
if ! $Purge_DryRun; then
echo purge
proxmox-backup-client prune host/"$PVE_Hostname" --keep-daily 1 --keep-weekly 3 --ns $PBS_NameSpace
else
echo dry
proxmox-backup-client prune host/"$PVE_Hostname" --dry-run --keep-daily 1 --keep-weekly 3 --ns $PBS_NameSpace | tee Pruge-DryRun
fi
fi
if $Run_GarbageColletion; then
proxmox-backup-client garbage-collect
fi
rm /SystemRepport-PVE /SystemRepport-APT

View File

@@ -0,0 +1,31 @@
## Instalation
### PVE Setup
Put the following files on the Proxmox-VE server
* `pxarexclude` as `/.pxarexclude
* `BackupScipt.sh` as `/opt/PVEtoPBS.sh`
* `Backup.service` as `/etc/systemd/system/PVEtoPBS.service`
* `Backup.timer` as `/etc/systemd/system/PVEtoPBS.timer`
Edit `/opt/PVEtoPBS.sh` to configure the backups.
Edit `/etc/systemd/system/PVEtoPBS.timer` to set-up the schedule the backups,
change OnCalendar (examples yearly,monthly,weekly,daily,hourly or *-01-01 00:00:00)
Run `systemctl enable --now PVEtoPBS.timer`.
To run a backup now run `systemctl start PVEtoPBS.service` or `bash /opt/PVEtoPBS.sh`
### PBS Setup
using name space for PVE with nested 1 for hostname,
This is done for permission managment
### Required permission for api token/user
| **Used for?** | **Path** | **Role** |
|------------------------------|---------------------------------------------------|--------------------|
| Basic usage | /system/status | Audit |
| Creating backups | /datastore/`<datastoreName>`/PVE-Hosts/PVE-Hostname | DatastoreBackup |
| Creating and purging backups | /datastore/`<datastoreName>`/PVE-Hosts/PVE-Hostname | DatastorePowerUser |
| Run garbage collection | /datastore/`<datastoreName>` | DatastoreAdmin |
### Source/Inspriration
* https://github.com/DerDanilo/proxmox-stuff/blob/master/prox_config_backup.sh
* https://pbs.proxmox.com/docs/backup-client.html

View File

@@ -0,0 +1,16 @@
*
!/etc
!/etc/**
!/root
!/root/**
!/opt
!/opt/**
!/var/
!/var/lib/
!/var/lib/pve-cluster
!/var/lib/pve-cluster/**
!/usr/
!/usr/share/
!/usr/share/kvm/
!/usr/share/kvm/*.vbios
!/SystemRepport-*