Plesk

Unable to create domain alias or Plesk upgrade fails: Duplicate entry for key ‘guid’

Symptoms

Cause

Database inconsistency, several domains have the same GUID. 

Resolution

  1. Log into the server via SSH.

  2. Create a backup for Plesk database:

    # plesk db dump psa > psa.backup`date +%F-%s`.sql

  3. Run the command below to fix the database inconsistency with the duplicated domain GUID: 

    # plesk db -Ne "SELECT guid, count(guid) FROM domains GROUP BY guid HAVING COUNT(guid) > 1" | while read G C; do echo "> DUPLICATED GUID: $G"; for ((i=0;i<(C-1);i++)); do plesk db -Ne "SELECT id, name FROM domains WHERE guid = '$G' limit 1" | while read I D; do plesk db -Ne "UPDATE domains SET guid = UUID() WHERE id = '$I'"; echo "- FIXED: $D"; done; done; done; echo "> COMPLETED"