VMware Cloud Community
CossyCosmas02
Contributor
Contributor
Jump to solution

Copy-DataStoreItem Query

Hi Guys,

Im looking to create a backup/copy of a VM that runs in our production location. The VM(and its files) will then be transferred to our DR location where it can be restarted in the event that the primary site becomes unavailable.  

I've had a quick look around and it appears that the best solution is to create a Powershell script that connects to VCenter using the VMware CLi and using the 'copy-datastoreitem' cmdlet copy the files to either the local machine on which the PS script is running or to an available UNC path. The files can then be transferred to the DR location and the VM manually registered with the VCenter running at the site to provide a failover service.

The question i have relates to the consistency of the image.

Do I need to 'switch off', 'quiesce' or 'snapshot' the VM's before I use the 'copy-datastoreitem' command? Are there any other considerations I need to be aware of? I've seen one article where the chap creates a snapshot before using the 'copy-datastoreitem' command and wasn't quite sure why he did that.

Any advice/helpful pointers would be appreciated.

Thank you.

Cossy 

Reply
0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Making a snapshot creates a recovery point. During the copy operation the disks of the vm can still be changed. But if you have to start the vm on your DR site, you go to the snapshot first. That makes sure you start the vm with the disks you had when you created the snapshot.

After the copy operation you can remove the snapshot from the vm at the original site.

I hope this makes it clear to you?

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

Reply
0 Kudos
5 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

I would create a snapshot before you make the copy to make sure that the disk is not changed during the copy operation.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
CossyCosmas02
Contributor
Contributor
Jump to solution

Hi Robert,

Thanks for the prompt reply.

Taking a snapshot establishes a recovery point but still allows for updates to take place.

If I take a snapshot, I will end up with an additional disk/snapshot file which is also being continuously updated and I would ask the same consistency question about?

Am I misunderstanding something?

I simply want to be sure that the server will restart successfully in the new environment.

Cheers,

Cossy

Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Making a snapshot creates a recovery point. During the copy operation the disks of the vm can still be changed. But if you have to start the vm on your DR site, you go to the snapshot first. That makes sure you start the vm with the disks you had when you created the snapshot.

After the copy operation you can remove the snapshot from the vm at the original site.

I hope this makes it clear to you?

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
CossyCosmas02
Contributor
Contributor
Jump to solution

I see!

So...

1.     Create a snapshot.

2.     Copy the files from the datastore to a local file using copy-datastoreitem. 

3.     Copy the files from the local file to a datastore in the DR location using copy-datastoreitem.

4.     Register the new server in the DR VCenter.

5.     Restart the server from its snapshot.

Thanks again for your help.

Regards,

Cossy 

Reply
0 Kudos
IvanSinyov
Contributor
Contributor
Jump to solution

You can copy files fom datastore to datastore directly. You don't need to copy vmdks to local file.

Copy-DatastoreItem vmstore:\<Datacenter>\<Datastore>\<path to file> vmstore:\<Datacenter>\<path>\

Reply
0 Kudos