1. Follow the instructions on the page linked below to back up your contacts directly from iCloud:
Archive or make copies of your iCloud data - Apple Support
2. Back up all data on the computer. Open the iCloud pane in System Preferences. Uncheck the box marked Contacts and confirm that you want to delete the contacts from the computer. They'll still be in iCloud and on your other devices, if any. Verify that your contact database is now empty. If it isn't, and if you're sure that all the contacts you want to keep are on iCloud, delete all the remaining contacts. Then re-check the Contacts box and wait for the contacts to resynchronize from iCloud.