File Manager Copy Datastore File Task
Copies the source file or folder to the destination.
If the destination file does not exist, it is created. If the destination file exists, the force parameter determines whether to overwrite it with the source or not. Folders can be copied recursively. In this case, the destination, if it exists, must be a folder, else one will be created. Existing files on the destination that conflict with source files can be overwritten using the force parameter. Files and disks are always copied in binary format during recursive copy.
If source (or destination) name is specified as a URL, then the corresponding datacenter parameter may be omitted.
If any intermediate level folder specified by the source and destination does not exist, a FileNotFound fault is thrown.
If a file of a virtual machine is overwritten on the destination datastore as a result of the force parameter, it may corrupt that virtual machine.
If the source is an extent of a virtual disk, this operation treats the extent as a file.
If source and destination resolve to the same file system location, the call has no effect.
It is important to note that this operation will provide transactional guarantees only for a file. No guarantees are provided when copying a folder. If the intent is to clone a virtual machine registered in the inventory, with transactional guarantees, please refer to CloneVM_Task.
Datastore.FileManagement privilege is required on both source and destination datastores.
The unique identifier for the managed object to which the method attaches; the serialized managed object reference for a request has the form moType/moId
, in this case FileManager/{moId}
.
The vSphere release schema. The current specification covers vSphere 8.0.3.0 APIs.
Show optional properties
{
"sourceName": "string",
"destinationName": "string"
}
{
"sourceName": "string",
"sourceDatacenter": {
"_typeName": "string",
"type": "string",
"value": "string"
},
"destinationName": "string",
"destinationDatacenter": {
"_typeName": "string",
"type": "string",
"value": "string"
},
"force": false
}
The name of the source, either a URL or a datastore path referring to the file or folder to be copied.
Reference to an instance of the Datacenter managed object.
The name of the destination, either a URL or a datastore path referring to the destination file or folder.
Reference to an instance of the Datacenter managed object.
If true, overwrite any identically named file at the destination. If not specified, it is assumed to be false.
This method returns a Task object with which to monitor the operation.
{
"_typeName": "string",
"type": "string",
"value": "string"
}
InvalidDatastore: if the operation cannot be performed on the source or destination datastores. Typically, a specific subclass of this exception is thrown.
FileNotFound: if the file or folder specified by sourceName is not found, or, any intermediate level folder specified by the destinationName is not found.
CannotAccessFile: if the source cannot be accessed because of insufficient permissions.
FileLocked: if the source file or folder is currently locked or in use.
FileAlreadyExists: if a file with the given name already exists at the destination, and the force flag is false.
NoDiskSpace: if there is not enough space available at the destination datastore.
FileFault: if there is a generic file error
{
"_typeName": "string",
"faultCause": "MethodFault Object",
"faultMessage": [
{
"_typeName": "string",
"key": "string",
"arg": [
{
"_typeName": "string",
"key": "string",
"value": {
"_typeName": "string"
}
}
],
"message": "string"
}
]
}