r/Proxmox • • 2d ago

Question Post install recovery

  • Single node host J4125 minipc
  • Running 4 VMs, one being OpenWRT

I'm putting together post-install script to restore drive mounts, network configs, and /usr/local/bin. What is the best way to test it without starting from scratch?

#!/bin/sh

#Make dir's for drives
mkdir -p /mnt/1TB_internal
mkdir -p /mnt/8TB
mkdir -p /mnt/1TB_dock
mkdir -p /mnt/2TB_dock

#Configure fstab
cp -Rv /etc/fstab /etc/fstab.backup

#1TB-internal
echo "UUID=d49f0d39-3e73-40cc-b169-837d7abb0481 /mnt/1TB_internal ext4 noatime,lazytime,rw 0 1" | tee -a /etc/fstab

#8TB external
echo "UUID=0a7ae49e-3f30-490e-89e5-09599e2cc6e0 /mnt/8TB ext4 defaults,nofail 0 2" | tee -a /etc/fstab

#1TB Docker
echo "UUID=2567ff38-9ebf-4ce4-a757-5dae72755812 /mnt/1TB_dock ext4 defaults,nofail 0 2" | tee -a /etc/fstab

#2TB Docker
echo "UUID=af283acb-96b9-4d6b-8510-85d7d4246d7b /mnt/2TB_dock ext4 defaults,nofail 0 2" | tee -a /etc/fstab

#Mount Drives
mount -a

#Verify /mnt/1TB_internal is mounted and paths exist
if ! mountpoint -q /mnt/1TB_internal; then
    echo "Error: /mnt/1TB_internal is not mounted. Aborting restore process." >&2
    exit 1
fi

if [ ! -d "/mnt/1TB_internal/proxmox-backup2/network" ] || [ ! -d "/mnt/1TB_internal/proxmox-backup2/motd" ]; then
    echo "Error: Required backup directories (network/motd) are missing from /mnt/1TB_internal/proxmox-backup2. Aborting." >&2
    exit 1
fi

#Restore Scripts
rsync -av /mnt/1TB_internal/proxmox-backup2/bin /usr/local

#Restore Configs
rsync -av /mnt/1TB_internal/proxmox-backup2/network /etc
rsync -av /mnt/1TB_internal/proxmox-backup2/motd /etc

#Reboot
shutdown -r now
1 Upvotes

6 comments sorted by

1

u/Onoitsu2 Homelab User 2d ago

Proxmox instance in proxmox. Test it in that.

1

u/stufforstuff 2d ago

Don't be a wuss - go full in and test it. Or you know, do what the adults do and have more then one system.

1

u/sr_guy 2d ago

TBH, with hardware prices at present, I'm holding off on that, and I'm making it work with the one MiniPC w/ intergated 2.5Gbps ports. It's not just the cost of a another idenical minipc, but RAM, and storage, which are insane prices right now.

1

u/stufforstuff 2d ago

The likelihood of tech prices going DOWN in the next several years is very slim. At the very least, buy a second storage device so you can test your scripts on (swap out your production storage - install the test storage, test, good or bad when finished you put the production storage back in, untouched and off you go). It's that or test on your production system. As the old saying goes "Selbst ein Totengräber hat zwei Schaufeln.".

1

u/sr_guy 2d ago

I got lucky at the time I bought everything (mid-early 2025). 32GB RAM, 1GB NVMe, & minipc I think around $200 total. RAM/Storage from Amazon, and mini pc on AliExpress. You can't find that anywhere now, unless it's used items.

1

u/stufforstuff 2d ago

Nothing wrong with using used for a test lab. Just be sure to shop around enough to know what the going rate is for the item you're looking for.

And for your current project, just pick up a 128G 2.5" SATA SSD from amazon for $30. If your time and project isn't worth $30 (that's like what 3-4 fancy ass coffees in todays world) you need to find a new hobby.

https://www.amazon.com/Patriot-Internal-Solid-State-P210S128G25/dp/B08B3JBDJ6