OpenVZ Forum


Home » General » Support » *SOLVED* Clone VPS
*SOLVED* Clone VPS [message #4748] Tue, 25 July 2006 11:51 Go to next message
pbundschuh is currently offline  pbundschuh
Messages: 7
Registered: January 2006
Junior Member
Hello,

is it possible, to make an exact copy (=clone) of an vps on the same machine?

regards,

Philipp

[Updated on: Wed, 26 July 2006 13:42] by Moderator

Report message to a moderator

Re: Clone VPS [message #4749 is a reply to message #4748] Tue, 25 July 2006 12:03 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Just copy your VPS directory (/vz/private/200) to the new
directory (/vz/private/201).
Copy config files (200.conf to 201.conf) and edit the last one in a decent way.

[Updated on: Tue, 25 July 2006 18:18]

Report message to a moderator

Re: Clone VPS [message #8425 is a reply to message #4749] Mon, 20 November 2006 08:11 Go to previous messageGo to next message
zenny
Messages: 48
Registered: November 2006
Member
Thanks Vasily for the invaluable tip.

However I cannot copy the /vz/priate/200 to /vz/private/201 using the cp command. Of cource, I did mkdir /vz/root/201 /vz/private/201.

Is there any specific way to do it? Please elaborate on what should be the specific command to clone VPSes in the same HN (hardware node).

Thanks in advance.

[Updated on: Mon, 20 November 2006 08:45]

Report message to a moderator

Re: Clone VPS [message #8432 is a reply to message #8425] Mon, 20 November 2006 08:59 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Hello,

Quote:

However I cannot copy the /vz/priate/200 to /vz/private/201 using the cp command. Of cource, I did mkdir /vz/private/201.


Why can't you? Smile

Quote:

Is there any specific way to do it? Please elaborate on what should be the specific command to clone VPSes in the same server.


In current distribution of OpenVZ there is no specific tool. I guess this is so 'cause of it's very easy to do it by hand:
# vzctl stop 101
Stopping VE ...
VE was stopped
VE is unmounted
# cp -r /vz/priate/101 /vz/private/202
# cp /etc/vz/conf/101.conf /etc/vz/conf/202.conf
# vzctl start 202
Starting VE ...
Initializing quota ...
VE is mounted
Setting CPU units: 1000
VE start in progress...


This can easily be disgned as a shell script.

HTH,
Vasily.
Re: Clone VPS [message #8433 is a reply to message #8432] Mon, 20 November 2006 09:23 Go to previous messageGo to next message
zenny
Messages: 48
Registered: November 2006
Member
I did exactly as you stated but didn't work, but reported 'omitting directories' error.

I rebooted the HN and did the same and copying worked.

But the new problem after starting the coped VPS.

#vzctl start 202 gives an error message:

"Unable to start init, probably incorrect template, 
VE start failed"


I created and destroyed the 202 earlier with a different distro and also the 202.conf.destroyed has also been removed.

However, when I copied to something new like 211 the ID which was not used before, it worked perfectly.

Could you elaborate what could be the reason or where to tweak in the cases like 202 as stated above?

Thank you for your continued coooperation,

[Updated on: Mon, 20 November 2006 09:33]

Report message to a moderator

Re: Clone VPS [message #8435 is a reply to message #8433] Mon, 20 November 2006 09:34 Go to previous messageGo to next message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Hmmm,

can you post output of the following commands:

# ls -l /vz/private/<veid>/sbin/ | grep init
# ls -l /vz/private/<veid>/bin/ | grep init

# ls -l /vz/private/<old_veid>/sbin/ | grep init
# ls -l /vz/private/<old_veid>/bin/ | grep init

<veid> is the id of newly created VE.
<old_veid> is the id of original VE.

Tell me, were there some troubles while copying?
Any error messages? Does original VE start?

Thank you.
Re: Clone VPS [message #8437 is a reply to message #8435] Mon, 20 November 2006 09:47 Go to previous messageGo to next message
zenny
Messages: 48
Registered: November 2006
Member
With the new VE, the above ls command outputs "No such file or Directory"

With the old VE, the first command (sbin dir) shows three files, init, initlog and telinit linked to init

the second command (bin dir) simply executes without any outputs.

And the cp went well without any glitches.

[Updated on: Mon, 20 November 2006 09:52]

Report message to a moderator

Re: Clone VPS [message #12125 is a reply to message #8437] Wed, 18 April 2007 06:24 Go to previous messageGo to next message
pixelplumber is currently offline  pixelplumber
Messages: 5
Registered: January 2007
Location: Australia
Junior Member
Just want to add for anyone coming accross this thread that it's probably a good idea to use the cp -p option to preserve permissions. I copied a VPS once and root ended up owning everything inside the duplicated VPS which broke a few things.
Re: Clone VPS [message #12127 is a reply to message #12125] Wed, 18 April 2007 06:31 Go to previous messageGo to next message
jarcher is currently offline  jarcher
Messages: 91
Registered: August 2006
Location: Smithfield, Rhode Island
Member
pixelplumber wrote on Wed, 18 April 2007 02:24

Just want to add for anyone coming accross this thread that it's probably a good idea to use the cp -p option to preserve permissions. I copied a VPS once and root ended up owning everything inside the duplicated VPS which broke a few things.


I learned that I need to use cp -a, which is the same as -dpR
Re: Clone VPS [message #27853 is a reply to message #12127] Fri, 29 February 2008 09:41 Go to previous messageGo to next message
ittec is currently offline  ittec
Messages: 41
Registered: February 2008
Member
Thanks, great post!!! Very Happy

[Updated on: Fri, 29 February 2008 09:42]

Report message to a moderator

Re: *SOLVED* Clone VPS [message #27906 is a reply to message #4748] Sun, 02 March 2008 04:27 Go to previous message
ugob is currently offline  ugob
Messages: 271
Registered: March 2007
Senior Member
pbundschuh wrote on Tue, 25 July 2006 07:51

Hello,

is it possible, to make an exact copy (=clone) of an vps on the same machine?

regards,

Philipp


I use vzdump to do that. Very nice tool. A backup tool at first, but I use it also to create some cloning.


Please read the manual before asking questions:
http://download.openvz.org/doc/OpenVZ-Users-Guide.pdf

Please have a look at the wiki before asking questions:
http://wiki.openvz.org/Main_Page
Previous Topic: openvz with hsphere 3.1 beta 2 - help
Next Topic: What about this message !!
Goto Forum:
  


Current Time: Tue May 14 11:37:16 GMT 2024

Total time taken to generate the page: 0.01465 seconds