How to Re-number an OpenVZ Container from one CTID to another

Poor planning: I guess I am guilty. A few times I have needed to re-number an OpenVZ Container. You just need to know what your current CTID is (sourcecid) and your desired target CTID (targetcid).

Here are the steps:

vzctl chkpnt ${sourcecid} --dumpfile /tmp/openvz-renumber-dump.${sourcecid}
mv /etc/vz/conf/${sourcecid}.conf /etc/vz/conf/${targetcid}.conf
mv /vz/private/${sourcecid} /vz/private/${targetcid}
mv /vz/root/${sourcecid} /vz/root/${targetcid}
vzctl restore ${targetcid} --dumpfile /tmp/openvz-renumber-dump.${sourcecid}
[ linux centos ]