There may be many reasons for cloning a VPS. It could be to backup a server or it could be to have a template that makes it easy to create a new server.
Cloning a VPS to Create a New Server
A common goal would be to have a server set up exactly like you want and then clone it in less than five minutes have a new one running that is the same. The best way to do this is to create a VPS and configure it exactly like you need. That means you must install all of the necessary programs and modify them so they are working like you want. Set up the security and networking as well. Once you have a running VPS, then make sure it is turned off to clone it.
In this example, a VPS 26 is cloned to create 27. The data that you will create for a VPS is located in the /vz/private/ directory. Be sure to use the switch -a when you use cp as it is important in getting the permissions right. The -a options maintains all of the archival attributes which is very important.
cp -a /vz/private/26 /vz/private/27
Next you need to copy the configuration for the VPS so that all of the settings are available. The configuration files are found in /etc/vz/conf. Once you have copied the configuration file over you will need to edit two lines:
These two lines are important to set up the correct IP Address and the hostname to distinguish the virtual servers.
cp /etc/vz/conf/26.conf /etc/vz/conf/27.conf
# Copyright (C) 2000-2007 SWsoft. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# UBC parameters (in form of barrier:limit)
# Primary parameters
# Secondary parameters
# Auxiliary parameters
# Disk quota parameters (in form of softlimit:hardlimit)
# CPU fair sheduler parameter
Once this is complete and you have saved it you may start the VPS.