From b4d616a445bf172717693a60eef7f371316fa641 Mon Sep 17 00:00:00 2001 From: kneutron <50146127+kneutron@users.noreply.github.com> Date: Thu, 9 May 2024 18:47:25 -0600 Subject: [PATCH] Add files via upload --- ...me-check-namespace-relative-performance.sh | 6 +++ proxmox/proxmox-backup-veeam-agent-setup.sh | 37 +++++++++++++++++++ proxmox/proxmox-bkp-host-to-pbs.sh | 32 ++++++++++++++++ proxmox/proxmox-grub-rescue-fix.sh | 29 +++++++++++++++ proxmox/proxmox-mount-lxc-ctr-root-on-host.sh | 25 +++++++++++++ proxmox/proxmox-refresh-ctr-templates.sh | 3 ++ proxmox/proxmox-storage-report.sh | 1 + 7 files changed, 133 insertions(+) create mode 100644 proxmox/nvme-check-namespace-relative-performance.sh create mode 100644 proxmox/proxmox-backup-veeam-agent-setup.sh create mode 100644 proxmox/proxmox-bkp-host-to-pbs.sh create mode 100644 proxmox/proxmox-grub-rescue-fix.sh create mode 100644 proxmox/proxmox-mount-lxc-ctr-root-on-host.sh diff --git a/proxmox/nvme-check-namespace-relative-performance.sh b/proxmox/nvme-check-namespace-relative-performance.sh new file mode 100644 index 0000000..6064542 --- /dev/null +++ b/proxmox/nvme-check-namespace-relative-performance.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for d in $(ls -1 /dev/nvme?n1); do + echo $d + nvme id-ns -H $d |grep -i relative +done diff --git a/proxmox/proxmox-backup-veeam-agent-setup.sh b/proxmox/proxmox-backup-veeam-agent-setup.sh new file mode 100644 index 0000000..829e7b2 --- /dev/null +++ b/proxmox/proxmox-backup-veeam-agent-setup.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Install veeam agent for linux for bare-metal backup/restore of root FS + LVM +# 2024.May kneutron + +# NOTE you will also need to download the "veeam Linux Recovery Media" ISO to be able to Restore! +# https://www.veeam.com/download_add_packs/backup-agent-linux-free/recovery-64 + +# HOWTO video: +# REF: https://www.youtube.com/watch?v=g9J-mmoCLTs + +# NOTE - WARNING - veeam only restores rootfs ext4 + LVM structure, does **NOT** restore LVM-thin! +# You still need to backup your VMs! + +# Install veeam agent for linux +apt update + +apt install pve-headers-$(uname -r) squashfs-tools libisoburn1 xorriso +apt-get install linux-headers-$(uname -r) + +# Needs to be already downloaded and in current dir +# https://www.veeam.com/linux-backup-free-download.html?sec=linux-backup-free-download.html&subsec=&part=&item= +dpkg -i veeam-release*deb + +apt update +apt install -y veeam + +# run the backup setup program TUI +veeam + +exit; + +# to start backup job out of schedule: +# veeamconfig job start --name "BackupJob1" + +NOTE veeam does NOT allow restore to a smaller disk - fsarchiver does! +e.g. if you backed up a 256GB boot disk, you cannot restore your root + LVM with veeam to a 128GB disk! diff --git a/proxmox/proxmox-bkp-host-to-pbs.sh b/proxmox/proxmox-bkp-host-to-pbs.sh new file mode 100644 index 0000000..084c267 --- /dev/null +++ b/proxmox/proxmox-bkp-host-to-pbs.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# REF: https://www.reddit.com/r/Proxmox/comments/tfbhp1/newbie_here_what_are_the_benefits_of_proxmox/ +# REF: https://pbs.proxmox.com/docs/backup-client.html +# REF: https://linuxconfig.org/how-to-create-a-backup-with-proxmox-backup-client + +export PBS_REPOSITORY=10.9.1.23:zpbs1 + +date +time proxmox-backup-client backup \ + --include-dev /boot/efi \ + --include-dev /etc/pve \ + root-$(hostname).pxar:/ \ + --repository 10.9.1.23:zpbs1 # : + +date + +exit; + +# root.pxar is name of bkp, / is root dir + +# REF: https://pbs.proxmox.com/docs/backup-client.html + +RESTORE: +Live-restore: This feature can allow you to start a VM when the restore job is started, rather than waiting for it to finish. + +## proxmox-backup-client snapshot list + +# proxmox-backup-client snapshot list --repository 10.9.1.23:zpbs1 + +# proxmox-backup-client restore host/elsa/2019-12-03T09:35:01Z root.pxar /target/path/ +# proxmox-backup-client restore --repository 192.168.122.72:datastore0 host/doc-standardpcq35ich92009/2024-01-11T11:01:49Z etc.pxar /etc diff --git a/proxmox/proxmox-grub-rescue-fix.sh b/proxmox/proxmox-grub-rescue-fix.sh new file mode 100644 index 0000000..454782b --- /dev/null +++ b/proxmox/proxmox-grub-rescue-fix.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# REF: https://pve.proxmox.com/wiki/Recover_From_Grub_Failure + +# TODO EDITME before running if disk devices are different (nvme, etc) +vgscan +vgchange -a y + +#Mount all the filesystems that are already there so we can upgrade/install grub. Your paths may vary depending on your drive configuration. + +mkdir /media/RESCUE +mount /dev/pve/root /media/RESCUE/ + +# EDITME +mount /dev/sda1 /media/RESCUE/boot + +mount -t proc proc /media/RESCUE/proc +mount -t sysfs sys /media/RESCUE/sys +mount -o bind /dev /media/RESCUE/dev +mount -o bind /run /media/RESCUE/run + +# Chroot into your proxmox install. + +chroot /media/RESCUE +#Then update grub and install it. + +update-grub +grub-install /dev/sda +# ^ EDITME diff --git a/proxmox/proxmox-mount-lxc-ctr-root-on-host.sh b/proxmox/proxmox-mount-lxc-ctr-root-on-host.sh new file mode 100644 index 0000000..f55f7e2 --- /dev/null +++ b/proxmox/proxmox-mount-lxc-ctr-root-on-host.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +pct mount $1 # number of LXC CTR + +exit; + +First, mount the LXC filesystems on the Proxmox host (LXC does not need to +be running, but can be). Use `pct mount xxx` for each LXC. It will tell +you the mount point, but it will be /var/lib/lxc/xxx/rootfs. Now you can +manipulate the files in the LXC from the Proxmox host. This includes all +mount points of the LXC overlaid properly. + +Next, use `rsync` to copy the files from one LXC to another using the full +path to both rootfs`s. + +Finally, recursively chown the files with a uid/gid offset of 100000 (the +offset used by unprivilaged LXCs). Root in the container (uid 0) is uid +100000 on host. I would just `chown -R 100000:100000` the entire directory +you just copied, so it`s accessible as root in the container, and then go +into the container and fix permissions within the container as container +root (using `chown -R user:group`) + +When you are done, `pct unmount xxx`. + +# REF: https://www.reddit.com/r/Proxmox/comments/1ch6555/most_efficient_way_to_copy_data_from_privileged/ \ No newline at end of file diff --git a/proxmox/proxmox-refresh-ctr-templates.sh b/proxmox/proxmox-refresh-ctr-templates.sh index 4ca2957..4cdee07 100644 --- a/proxmox/proxmox-refresh-ctr-templates.sh +++ b/proxmox/proxmox-refresh-ctr-templates.sh @@ -1,5 +1,8 @@ #!/bin/bash +# running from cron, we need this +PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/games:/usr/games:/root/bin:/root/bin/boojum:/usr/X11R6/bin:/usr/NX/bin: + pveam update pveam list local # storage name diff --git a/proxmox/proxmox-storage-report.sh b/proxmox/proxmox-storage-report.sh index e8a7287..6e46e1e 100644 --- a/proxmox/proxmox-storage-report.sh +++ b/proxmox/proxmox-storage-report.sh @@ -3,6 +3,7 @@ # Verbosely list the contents of various storage defined in the Proxmox GUI # 2024.May kneutron # Could be handy to grep the output for e.g. vm-112 or an ISO name to see which storage has it +# Also handy to find backups of a VM on different storage # running from cron, we need this PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/games:/usr/games:/root/bin:/root/bin/boojum:/usr/X11R6/bin:/usr/NX/bin: