diff --git a/Linux/Proxmox/PVE-BackupToPBS/Backup.service b/Linux/Proxmox/PVE-BackupToPBS/Backup.service new file mode 100644 index 0000000..7598d72 --- /dev/null +++ b/Linux/Proxmox/PVE-BackupToPBS/Backup.service @@ -0,0 +1,6 @@ +[Unit] +Description=PVE to PBS Backup + +[Service] +Type=oneshot +ExecStart=/bin/bash /opt/PVEtoPBS.sh \ No newline at end of file diff --git a/Linux/Proxmox/PVE-BackupToPBS/Backup.timer b/Linux/Proxmox/PVE-BackupToPBS/Backup.timer new file mode 100644 index 0000000..ca58663 --- /dev/null +++ b/Linux/Proxmox/PVE-BackupToPBS/Backup.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Scheduled PVE to PBS Backup + +[Timer] +OnCalendar=weekly +Persistent=true + +[Install] +WantedBy=timers.target \ No newline at end of file diff --git a/Linux/Proxmox/PVE-BackupToPBS/BackupScipt.sh b/Linux/Proxmox/PVE-BackupToPBS/BackupScipt.sh new file mode 100644 index 0000000..5751bf9 --- /dev/null +++ b/Linux/Proxmox/PVE-BackupToPBS/BackupScipt.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +#List of files to in/exclude form the backup located /.pxarexclude + +#Scipt config +PBS_Host= +PBS_Datastore= +PBS_User=root@pam! +export PBS_PASSWORD="" +export 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 --keep-hourly --keep-daily --keep-weekly --keep-monthly --keep-yearly +# +# 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 \ No newline at end of file diff --git a/Linux/Proxmox/PVE-BackupToPBS/ReadMe.md b/Linux/Proxmox/PVE-BackupToPBS/ReadMe.md new file mode 100644 index 0000000..8cad580 --- /dev/null +++ b/Linux/Proxmox/PVE-BackupToPBS/ReadMe.md @@ -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/``/PVE-Hosts/PVE-Hostname | DatastoreBackup | +| Creating and purging backups | /datastore/``/PVE-Hosts/PVE-Hostname | DatastorePowerUser | +| Run garbage collection | /datastore/`` | DatastoreAdmin | + +### Source/Inspriration +* https://github.com/DerDanilo/proxmox-stuff/blob/master/prox_config_backup.sh +* https://pbs.proxmox.com/docs/backup-client.html + diff --git a/Linux/Proxmox/PVE-BackupToPBS/pxarexclude b/Linux/Proxmox/PVE-BackupToPBS/pxarexclude new file mode 100644 index 0000000..cd4ea36 --- /dev/null +++ b/Linux/Proxmox/PVE-BackupToPBS/pxarexclude @@ -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-* diff --git a/OVHCloud/SetupAPI-Key_ddns-updater.md b/OVHCloud/SetupAPI-Key_ddns-updater.md new file mode 100644 index 0000000..70e03ea --- /dev/null +++ b/OVHCloud/SetupAPI-Key_ddns-updater.md @@ -0,0 +1,61 @@ +# OVHCloud api DDNS Setup +This system uses OVH's API v1 and [ddns-updater](https://github.com/qdm12/ddns-updater "Lightweight universal DDNS Updater program +") +## Get record ID(s) in preparation for generating the API keys +* First make sure the required `A` and `AAAA` for the (sub)domain exist in OVHCloud's manager. +* Go to OVHCloud API Console's [Auth page]( "OVHCloud API Console"). +* Click `Login with OVHCloud SSO`, and follow the steps. +* Go to OVHCloud API Console's [List record]("OVHCloud API Console"). +* Enter the domain name (without subdomain) under `zoneName`. +* If you want to update a subdomain enter this in `subDomain`. +* Enter `A` in the `fieldType` field +* Click the Blue `EXECUTE` button +* Note the number given in the response field +* If you also want to update IPv6 record enter `AAAA` in the ` fieldType` field +* Click the Blue `EXECUTE` button +* Note the number given in the response field + +## Generating the API keys + +* Go to the OVHCloud [API Key generator]("OVHCloud Auth") +* Enter a Application name (example: "mydomain-subdomain-DDNS"). +* Enter a Application Description (example: "subdomain.mydomain.com DNS Updater"). +* Set Validity to `Unlimited` +* Add the following rights: +``` +GET: /domain/zone//record +PUT: /domain/zone//record/ +PUT: /domain/zone//record/ +POST: /domain/zone//refresh +``` + +## ddns-updater example config +``` +{ + "settings": [ + { + "provider": "ovh", + "mode": "api", + "domain": "quartz.nxdi.nl", + "api_endpoint": "ovh-eu", + "app_key": "", + "app_secret": "", + "consumer_key": "", + "ip_version": "ipv4" + }, + { + "provider": "ovh", + "mode": "api", + "domain": "quartz.nxdi.nl", + "api_endpoint": "ovh-eu", + "app_key": "", + "app_secret": "", + "consumer_key": "", + "ip_version": "ipv6", + "ipv6_suffix": "" + } + ] +} + + +``` \ No newline at end of file