File Manager Copy Datastore File Task

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.

Request
URI
POST
https://{vcenter-host}/sdk/vim25/{release}/FileManager/{moId}/CopyDatastoreFile_Task
COPY
Path Parameters
string
moId
Required

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}.

string
release
Required

The vSphere release schema. The current specification covers vSphere 8.0.2.0 APIs.


Request Body
CopyDatastoreFileRequestType of type(s) application/json
Required
{
    "sourceName": "string",
    "sourceDatacenter": {
        "type": "string",
        "value": "string"
    },
    "destinationName": "string",
    "destinationDatacenter": {
        "type": "string",
        "value": "string"
    },
    "force": false
}
string
sourceName
Required

The name of the source, either a URL or a datastore path referring to the file or folder to be copied.

sourceDatacenter
Optional

Reference to an instance of the Datacenter managed object.

string
destinationName
Required

The name of the destination, either a URL or a datastore path referring to the destination file or folder.

destinationDatacenter
Optional

Reference to an instance of the Datacenter managed object.

boolean
force
Optional

If true, overwrite any identically named file at the destination. If not specified, it is assumed to be false.

Authentication
This operation uses the following authentication methods.
Responses
200

This method returns a Task object with which to monitor the operation.

Returns MoRefTask of type(s) application/json
This response body class contains all of the following: MoRefExtensibleManagedObject
{
    "_typeName": "string",
    "type": "string",
    "value": "string"
}

500

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

Returns VimFault of type(s) application/json
This response body class contains all of the following: MethodFault
{
    "_typeName": "string",
    "faultCause": "MethodFault Object",
    "faultMessage": [
        {
            "_typeName": "string",
            "key": "string",
            "arg": [
                {
                    "_typeName": "string",
                    "key": "string",
                    "value": {
                        "_typeName": "string"
                    }
                }
            ],
            "message": "string"
        }
    ]
}