VMware Cloud Community
AndreG79
Contributor
Contributor

Copy-DatastoreItem vmdk

I want to copy large vmdk between datastores.

$DatastoreSource = Get-Datastore -VmHost $VMHost | Where{ $_.Name -like "snap-$VmfsLabel" }
$DatastoreDestination = Get-Datastore -VmHost $VMHost | Where{ $_.Name -like "VM_test" }
New-PSDrive -Location $DatastoreSource -Name dssource -PSProvider VimDatastore -Root "\"
New-PSDrive -Location $DatastoreDestination -Name dsdestination -PSProvider VimDatastore -Root "\"

#VM HDD copy
Copy-DatastoreItem -Item dssource:\VM_test\VM_test_2.vmdk -Destination dsdestination:\VM_test-new\DB_HDD\VM_test_2.vmdk

The size of the vmdk is 80GB, but in the destination only 61kb.

if i use:

Copy-DatastoreItem -Item dssource:\VM_test\*.* -Destination dsdestination:\VM_test-new\DB_HDD\

All item will copy successfully with the full size.

What is the problem to copy one item?

0 Kudos
12 Replies
LucD
Leadership
Leadership

Any error messages ?

And is the copied VMDK valid ?

Can you for example connect it to a VM and access the disk inside that VM ?

Btw which PowerCLI version are you using ? Do a

Get-PowerCLIVersion


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
AndreG79
Contributor
Contributor

Hello LucD,

No error message, vmdk is not valid and not accessible.

Copy is very fast, only 5-9 seconds....

PowerCLI Version is the last one, downloaded and installed 3 weeks ago.

Maybe the problem is, i connect to the vCenter Server and not to the Single ESX Host?

0 Kudos
LucD
Leadership
Leadership

No, this should work when connected to the vCenter.

When you copy all the files in the folder, is the VMDK file then complete and valid ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
AndreG79
Contributor
Contributor

Yes, if i use .....*.* all Files in the Folder are complet and valid.

But i need only 2 VMDK and not all VM Files....

I test it tomorrow with smaller Files and post the results.

0 Kudos
LucD
Leadership
Leadership

Sorry, but I haven't seen that behaviour before Smiley Sad

Perhaps someone from the PowerCLI Development Team has an idea ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
AndreG79
Contributor
Contributor

PowerCLI Version
----------------
   VMware vSphere PowerCLI 5.0 build 435427
---------------
Snapin Versions
---------------
   VMWare AutoDeploy PowerCLI 5.0 build 575
   VMWare ImageBuilder PowerCLI 5.0 build 575
   VMware License PowerCLI 5.0 build 395016
   VMWare vSphere PowerCLI 5.0 build 435427

0 Kudos
LucD
Leadership
Leadership

That is not the latest PowerCLI build, perhaps you can try to upgrade to 5.1 and check if that makes a difference.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
AndreG79
Contributor
Contributor

I think I have a solution.
I started the copy process with "*. *" and looked at what happens to the DataStore.
The disk has been created there with "VM_test-flat.vmdk" and after the copy in "VM_test.vmdk" renamed.
Now I have changed the source name to "VM_test-flat.vmdk".
The copy is started, now I am waiting for the result.

0 Kudos
LucD
Leadership
Leadership

I didn't notice that in your script.

A VMDK file is actually 2 files (at least), there is the VMDK file itself, which is a type of header file.

It contains information about the vDisk. In fact you can display the content of that file, it's a text file.

The 2nd file is the file with the -flat suffix in there, that is the file that holds the actual content of the vDisk.

You need both of these to have a working vDisk.

When you start doing snapshots, changed block tracking... there are additional files that make up the vDisk.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
AndreG79
Contributor
Contributor

I sent you a PN.

0 Kudos
LucD
Leadership
Leadership

Just replied


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

AndreG79
Contributor
Contributor

thanks for making light in the dark........

The PowerCLI view is much more revealing than the vsphere client browse datastore view.....

get-childItem from the source:

LastWriteTime           Type       Length Name
       -------------           ----       ------ ----
28.10.2012     02:01    VmNvramFile         8684 vmname.nvram
15.03.2012     19:45     VmDiskFile          619 vmname.vmdk
03.12.2012     23:00           File          721 vmname.vmsd
04.12.2012     23:00   VmConfigFile         3456 vmname.vmx
11.10.2012     13:48           File         1575 vmname.vmxf
25.01.2011     12:45     VmDiskFile          623 vmname_2.vmdk
04.12.2012     23:00     VmDiskFile          271 vmname_2-000001.vmdk
04.12.2012     23:00           File       618496 vmname_2-000001-delta.vmdk
04.12.2012     23:00           File 322134865920 vmname_2-flat.vmdk
19.06.2012     23:00     VmDiskFile          623 vmname_3.vmdk
04.12.2012     23:00     VmDiskFile          326 vmname_3-000001.vmdk
04.12.2012     23:00           File     16945152 vmname_3-000001-delta.vmdk
04.12.2012     23:00           File  85921274880 vmname_3-flat.vmdk
04.12.2012     23:00     VmDiskFile          322 vmname-000001.vmdk
04.12.2012     23:00           File     33681408 vmname-000001-delta.vmdk
04.12.2012     23:00           File          134 vmname-aux.xml
04.10.2012     15:16           File           37 vmname-c5ff54d9.hlog
02.11.2011     12:30           File  17171480576 vmname-c5ff54d9.vswp
04.12.2012     23:00           File  64436843520 vmname-flat.vmdk
04.12.2012     23:00 VmSnapshotFile        30231 vmname-Snapshot20333.vmsn
04.12.2012     23:00           File        30309 vmname-vss_manifests20333.zip
17.10.2012     23:00      VmLogFile      1324054 vmware.log
28.10.2011     02:46      VmLogFile      1300309 vmware-14.log
03.11.2011     00:47      VmLogFile      1358505 vmware-15.log
28.02.2012     09:15      VmLogFile        85607 vmware-16.log
28.02.2012     23:45      VmLogFile      1365373 vmware-17.log
30.04.2012     23:01      VmLogFile      1329495 vmware-18.log
06.06.2012     23:01      VmLogFile      1338154 vmware-19.log

that's why the vmname_2.vmdk also only 0.61 kb

for my plan is the right command:

Copy-DatastoreItem -Item dssource:\VMNAME\VMNAME_*.* -Destination dsdestination:\VMNAMESHADOW\COPY_HDD\

0 Kudos