You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VMware vCenter 6.0同版本备份恢复失败问题求助

Troubleshooting vCenter 6.0 Postgres Backup Restore Failures

Looking at your error logs, the issues boil down to database constraint violations—duplicate unique keys and missing foreign key references—plus subtle schema mismatches between your backup and target vCenter versions. Let’s break down how to fix each problem step by step:

1. First: Validate Backup Integrity & Match vCenter Versions Exactly

Before diving into data edits, rule out basic, easily fixable issues:

  • Stick to identical vCenter builds: Even minor version tweaks (like 3d vs 3e) can introduce Postgres schema changes. Install the exact 6.0 3d build that matches your backup source, then attempt recovery again. Cross-minor-version restores often trigger constraint conflicts.
  • Verify backup consistency: Use Postgres’s built-in tool to check if your backup is corrupted:
    pg_restore --check --dbname=template0 /path/to/your/vcenter_backup.file
    
    If this returns errors, your backup is damaged, and you’ll need to use a different snapshot.

2. Fix Duplicate Unique Key Errors

The pk_vpx_host_node_cpu and pk_vpx_dbm_counter_metadata errors mean your backup has duplicate records that break unique index rules. Here’s how to clean them up safely:

Step 1: Restore Backup to a Temporary Database

First, restore your backup to a staging Postgres database (not the live vCenter DB) to avoid messing with production data:

pg_restore -d temp_vcenter_recovery /path/to/your/backup.file

Step 2: Remove Duplicate Records

Connect to the temp database and run these queries to delete duplicates (keeping one valid record per unique key):
For the host CPU duplicate:

-- Identify duplicate entries
SELECT host_id, numa_id, cpu_id, COUNT(*) 
FROM vpx_host_node_cpu 
GROUP BY host_id, numa_id, cpu_id 
HAVING COUNT(*) > 1;

-- Delete duplicates (retains the first occurrence)
DELETE FROM vpx_host_node_cpu 
WHERE ctid NOT IN (
  SELECT MIN(ctid) 
  FROM vpx_host_node_cpu 
  GROUP BY host_id, numa_id, cpu_id
);

For the counter metadata duplicate:

-- Identify duplicate counter IDs
SELECT counter_id, COUNT(*) 
FROM vpx_dbm_counter_metadata 
GROUP BY counter_id 
HAVING COUNT(*) > 1;

-- Delete duplicates
DELETE FROM vpx_dbm_counter_metadata 
WHERE ctid NOT IN (
  SELECT MIN(ctid) 
  FROM vpx_dbm_counter_metadata 
  GROUP BY counter_id
);

3. Fix Missing Foreign Key References

The errors with fk_vpx_virtual_ethernet_card and fk_vpx_ds_ref_vpx_entity mean some records reference rows that don’t exist in related tables. Clean these invalid references:

Fix Virtual Ethernet Card Foreign Key Issue

-- Find network card records pointing to non-existent virtual devices
SELECT * FROM vpx_virtual_ethernet_card 
WHERE vdevice_id NOT IN (SELECT vdevice_id FROM vpx_virtual_device);

-- Delete invalid records
DELETE FROM vpx_virtual_ethernet_card 
WHERE vdevice_id NOT IN (SELECT vdevice_id FROM vpx_virtual_device);

Fix Datastore Foreign Key Issue

First, confirm the foreign key column (likely entity_id for vpx_datastore), then clean invalid entries:

-- Find datastore records pointing to non-existent entities
SELECT * FROM vpx_datastore 
WHERE entity_id NOT IN (SELECT id FROM vpx_entity);

-- Delete invalid records
DELETE FROM vpx_datastore 
WHERE entity_id NOT IN (SELECT id FROM vpx_entity);

4. Re-Export & Restore the Cleaned Database

Once you’ve fixed all duplicates and invalid references, export the cleaned temp database:

pg_dump -Fc temp_vcenter_recovery > /path/to/cleaned_vcenter_backup.file

Use this cleaned backup to restore to your vCenter’s Postgres database, or leverage the official vCenter recovery tool for a more streamlined process.

Critical Note

Always make a copy of your original backup file before making any edits—you don’t want to lose your only source of data if something goes wrong.

内容的提问来源于stack exchange,提问作者Bharath M

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:53:34