Skip to content

Scripts

Administrative scripts located in /root/bin/ on px1.

Infrastructure Management

infra

Infrastructure CLI that wraps the Domain Manager API.

Location: /root/bin/infra

# Get next available VMID
infra next-vmid px1 prod     # Returns 1101, 1102, etc.
infra next-vmid px5 dev      # Returns 5501, 5502, etc.

# Decode a VMID
infra decode 1111            # Shows px1-silverstone, prod, sequence 11

# Get next available IP
infra next-ip                # Returns next UK IP (10.44.10.x)
infra next-ip france         # Returns next France IP (10.35.1.x)

# List infrastructure assets
infra list                   # List all assets
infra list --node px1        # List assets on px1 only
infra list --status running  # List running assets

# Get specific asset details
infra get 1112               # Get details for CT1112

# Sync preview
infra sync                   # Preview sync between DB and Proxmox

# Detect conflicts
infra conflicts              # Show IP conflicts and orphans

SSH Management

setup-vm-ssh

Bi-directional SSH setup for VMs and containers.

Location: /root/bin/setup-vm-ssh

# Setup SSH for a single VM/CT
setup-vm-ssh 1112            # Setup CT1112

# Setup SSH with specific user
setup-vm-ssh 1112 admin      # Setup for admin user

setup-vm-ssh-all

Run setup-vm-ssh for all running VMs and containers.

# Dry run - show what would be done
setup-vm-ssh-all --dry-run

# Setup all VMs/CTs
setup-vm-ssh-all

generate-infra-hosts.sh

Generates SSH host entries for infrastructure hosts.

Location: /root/bin/generate-infra-hosts.sh

Runs every 6 hours via cron. Updates /etc/hosts and SSH config with current VM/CT mappings.

Ceph Backup Scripts

ceph-snapshot-daily.sh

Creates daily RBD snapshots for critical VMs on Ceph.

Location: /root/bin/ceph-snapshot-daily.sh

  • Creates RBD snapshots for critical VMs (1111, 1112, 1113)
  • 7-day retention (auto-cleanup of older snapshots)
  • Runs at 02:00 daily
# Manual run
/root/bin/ceph-snapshot-daily.sh

# Check logs
tail -f /var/log/ceph-snapshots.log

# List snapshots
rbd snap ls ceph-pool/vm-1111-disk-0

ceph-export-to-px5.sh

Exports compressed Ceph images to France (px5) for disaster recovery.

Location: /root/bin/ceph-export-to-px5.sh

  • Exports critical VMs as compressed raw images
  • Stored on px5 at /mnt/nvme-vmdata/dr-images/
  • 3-copy retention per VM
  • Runs at 01:00 daily
# Manual run
/root/bin/ceph-export-to-px5.sh

# Check logs
tail -f /var/log/ceph-dr-export.log

# List exports on px5
ssh root@REDACTED_IP "ls -lh /mnt/nvme-vmdata/dr-images/"

Maintenance Scripts

mass-apt-update.sh

Updates packages across all nodes and containers.

Location: /root/bin/mass-apt-update.sh

# Run updates across cluster
/root/bin/mass-apt-update.sh

# Dry run
/root/bin/mass-apt-update.sh --dry-run

Ceph Management

Snapshot Commands

# Create manual snapshot
rbd snap create ceph-pool/vm-1111-disk-0@manual-$(date +%Y%m%d-%H%M)

# List snapshots
rbd snap ls ceph-pool/vm-1111-disk-0

# Rollback (VM must be stopped)
qm stop 1111
rbd snap rollback ceph-pool/vm-1111-disk-0@snapshot-name
qm start 1111

# Delete snapshot
rbd snap rm ceph-pool/vm-1111-disk-0@snapshot-name

Health Commands

# Cluster status
ceph -s

# OSD status
ceph osd tree

# Pool status
ceph osd pool ls detail

# Check for slow operations
ceph health detail

Script Locations Summary

Script Location Purpose
infra /root/bin/infra Infrastructure CLI
setup-vm-ssh /root/bin/setup-vm-ssh SSH access setup
generate-infra-hosts.sh /root/bin/ SSH host mapping
ceph-snapshot-daily.sh /root/bin/ Daily Ceph snapshots
ceph-export-to-px5.sh /root/bin/ DR export to France
mass-apt-update.sh /root/bin/ Cluster updates