[SOLVED] Migration path from one server to another (in the future).

mike.spragg

New Member
May 19, 2024
17
2
3
Sorry for dumb/simple question - I've got 8.3.2 on bare-metal etc. and all working fine.

However, in 3 years time the server will get replaced - what's the quickest/easiest way to migrate machines from one to another. The original server won't stay in production (but both will be up/running until move has been done) - in other words, once {oldserver} has been migrated to {newserver[ then {oldserver} be shutdown and removed. Therefore, setting up HA/Cluster isn't really needed (unless it really helps the migration). I can't find a simple way to link both pve's together in UI. Do I need to export/import ? Just trying to get "ducks in a row" for the future !

With vmware you had the separate utility vCenter Convert that would take source/target and allow you to move images and was pretty easy. Obviously the option to Import from ESXi won't be useful in 3 years as the old vmware will be gone,

As I say, sorry for dumb question - I'm sure I saw it in one of the help html guides at one point.
 
Last edited:
Hey

Simple add the new Server to the Cluster migrate remove old Server from Cluster Supersimple and SDN, Storage Conf is also directly migrated (Live Migration also Possible) all im the same UI ;-)

Compared to vMotion you could give the Proxmox Datacenter Manager (ALPHA) a try... cross Cluster migrations is also quiet simple.

My last bigger Hardware Cgange I djd over a PBS while Restoring the VM... oh yet a third option.

ARe your ducks in row?
 
  • Like
Reactions: mike.spragg
They definitely are now - thank you ! Going to try that tomorrow! I’ve not seen the data manager, thanks for heads up !
 
Just a quick update - the Proxmox Datacenter Manager (thanks tscret for bringing this to my attention) is exactly the util I needed - been moving things around and works great (except cd-rom!)
 
If you like a could provide you a bash script to disconnect all mounted ISOs.
That'd definitely be handy - I've been using vmware for ages and I think/know that Proxmox is a very decent alternative (not that my humble opinion counts of course!) so anything that helps the transition is gratefully received !
 
That'd definitely be handy - I've been using vmware for ages and I think/know that Proxmox is a very decent alternative (not that my humble opinion counts of course!) so anything that helps the transition is gratefully received !
Sorry Comments are in german but script iterates through all nodes in the Cluster. If I have time I go to rebuild it with pvesh (API Functions in CLI)


Bash:
#!/bin/bash

# Benutzer für SSH (muss root sein oder sudo-Rechte haben)
SSH_USER="root"

# Funktion: Liest alle Cluster-Nodes aus
get_cluster_nodes() {
    pvecm nodes | grep -v "Nodeid" | awk '{print $3}'
}

# Funktion: Entfernt ISO-Dateien von CD-ROM-Geräten auf einem Node
remove_cdrom_isos() {
    local node=$1
    echo "Verarbeite Node: $node"
    local removed_vms=""
  
    # SSH-Verbindung zum Node herstellen und alle VMs durchgehen
    ssh "${SSH_USER}@${node}" bash << 'EOF'
for vmid in $(qm list | awk 'NR>1 {print $1}'); do
    iso_found=0
    vm_name=$(qm config $vmid | grep "name:" | awk -F': ' '{print $2}')
  
    # Überprüfen, ob eine ISO gemountet ist
    for iso_device in $(qm config $vmid | grep -i 'media=cdrom' | awk -F': ' '{print $1}'); do
        # Nur Geräte mit gemountetem ISO bearbeiten
        iso_path=$(qm config $vmid | grep -i "media=cdrom" |  grep -i "$iso_device" | awk -F': ' '{print $2}')
        if [ "$iso_path" != "none,media=cdrom" ]; then
            echo "Entferne ISO von VM $vmid ($vm_name), Gerät $iso_device, ISO: $iso_path"
            qm set $vmid -$iso_device none
            iso_found=1
        fi
    done

    # Wenn eine ISO entfernt wurde, zur Liste der entfernten VMs hinzufügen
    if [ $iso_found -eq 1 ]; then
        echo "$vmid $vm_name" >> /tmp/removed_vms.txt
    fi
done
EOF

    # Überprüfung, ob VMs entfernt wurden und Ausgabe der Ergebnisse
    if ssh "${SSH_USER}@${node}" "[ -f /tmp/removed_vms.txt ]"; then
        removed_vms=$(ssh "${SSH_USER}@${node}" 'cat /tmp/removed_vms.txt')
        ssh "${SSH_USER}@${node}" 'rm -f /tmp/removed_vms.txt' # Temporäre Datei löschen
    fi
  
    if [ -n "$removed_vms" ]; then
        echo "Folgende VMs haben ISO entfernt bekommen auf Node $node:"
        echo "$removed_vms"
        echo "$removed_vms" >> /tmp/removed_vms_summary.txt
    else
        echo "Keine ISOs entfernt auf Node $node."
    fi
}

# Hauptlogik: Alle Nodes durchlaufen
NODES=$(get_cluster_nodes)

if [ -z "$NODES" ]; then
    echo "Keine Nodes im Cluster gefunden oder Cluster ist nicht erreichbar."
    exit 1
fi

echo "Gefundene Cluster-Nodes: $NODES"
for node in $NODES; do
    remove_cdrom_isos "$node"
done

# Zusammenfassung über den gesamten Cluster
if [ -f /tmp/removed_vms_summary.txt ]; then
    echo "Zusammenfassung: Folgende VMs wurden ISO entfernt über den gesamten Cluster:"
    cat /tmp/removed_vms_summary.txt
    echo "Anzahl der entfernten ISOs: $(wc -l < /tmp/removed_vms_summary.txt)"
    rm -f /tmp/removed_vms_summary.txt
else
    echo "Keine ISOs wurden im Cluster entfernt."
fi

echo "Alle Nodes verarbeitet."
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!