How to use vifs.php Command

The command vifs.php can be used to move files to and from your ESXi host. As of Update 2 of the ESXi 3.5 RCLI, this command is not supported with VirtualCenter. If you only need to copy files from your ESXi host, then you can also use your web browser to retrieve files. ESXi allows for two URLs to access files from your host.

https://<ESXi_ip/hostname>/folder – this URL can be used to browse the datastores that the ESXi has access to.
https://<ESXi_ip/hostname>/host – this URL is used to access host configuration and log files. Access to host files is controlled by the file /etc/vmware/hostd/webAccessibleConfigFiles.xml. Direct editing of this file would not be supported, but it would be possible to replace this file by customizing oem.tgz to expose more system files for editing. The below chart summarizes the host configuration / log files that are exposed by webAccessibleConfigFiles.xml and are thus downloadable via the web browser or accessible with vifs.pl

Display NameHost File NamePermissions with vifs.pl
hostAgentConfig.xml/etc/vmware/hostd/config.xmlGET/HEAD/PUT
sfcb.cfg/etc/sfcb.cfgGET/HEAD/PUT
openwsman.conf/etc/operwsman/openwsman.confGET/HEAD/PUT
license.cfg/etc/vmware/license.cfgGET/HEAD/PUT
vmware.lic/etc/vmware/vmware.licGET/HEAD/PUT
vmware_config/etc/vmware/configGET/HEAD/PUT
vmware_configrules/etc/vmware/configrulesGET/HEAD/PUT
proxy.xml/etc/vmware/hostd/proxy.xmlGET/HEAD/PUT
snmp.xml/etc/vmware/snmp.xmlGET/HEAD/PUT
syslog.conf/etc/syslog.confGET/HEAD/PUT
ssl_cert/etc/vmware/ssl/rui.crtGET/HEAD/PUT
ssl_key/etc/vmware/ssl/rui.keyPUT
hosts/etc/hostsGET/HEAD/PUT
motd/etc/motdGET/HEAD/PUT
vpxa.cfg/etc/opt/vmware/vpxa/vpxa.cfgGET/HEAD/PUT
esx.conf/etc/vmware/esx.confGET/HEAD/PUT
config.log/var/log/config.logGET/HEAD
messages/var/log/messagesGET/HEAD
ipmi_sel.raw/var/log/ipmi_sel.rawGET/HEAD
ipmi_sel/var/log/ipmi_selGET/HEAD
hostd.log/var/log/vmware/hostd.logGET/HEAD
vpxa.log/var/log/vmware/vpxa/vpxa.logGET/HEAD

Note: while most systems will only have one IPMI node, a system could have up to four in which case the files ipmiX_sel.raw (/var/log/ipmi/X/sel.raw), ipmiX_sel (/var/olg/ipmi/X/sel), ipmiX_sdr_content.raw (/var/log/ipmi/X/sdr_content), ipmiX_sdr_header.raw (/var/log/ipmi/X/sdr_header.raw) and ipmiX_sensor_readings.raw (/var/log/ipmi/X/sensor_readings.raw) would be displayed where X would correspond with the node number (0 to 3). These files would have GET/HEAD permissions.

Vifs.pl can access three types of files and folders on your host.
Host – host configuration and log files as shown in the the list above. These are accessed with the path of /host/<filename>
Temp – files and folders located in the /tmp directory
Datastores – use the datastores options to access files and folders on your host’s datastores. There are two syntax options for accessing datastore files.
1) Datastore prefix = [datastore_name] relative path – for the Linux RCLI it would be ‘[datastore1] folder/filename’ and for Windows it would be “[datastore1] folder\filename”
2) URL style = /folder_path/filename=datastorename – for the Linux RCLI it would be ‘/folder/filename&dsName=datastore1’ and for Windows it would be “/folder/filename&dsName=datastore1”

Note: should the directory name include a space, then the patch should be enclosed in quotes as show in the above examples.

The vifs.pl command allows for the options shown below.

OptionWorks on
datastore / temp / host
Description
–copy (-c) <source> <destination>X / X / —Copy a file from one datastore location to another.
–forceX / X / —Used with the copy option to overwrite the destination files
–dir (-D) <path>X / X / —Lists the contents of a datastore or temp folder
–get (-g) <remote_file> <local_file>X / — / XCopy a datastore or ESX(i) host file to the host running the RCLI. This operation uses HTTP GET (see accessing files via a URL above).
–listdc (-C)X / — / XLists available datacenter paths on the host
–listds (-S)X / — / XList the datastore names that a host has access to. If you are using multiple datacenters, then use the –dc (-Z) argument to specify the name of the datacenter from which to list the datastore
–dc (-Z) <datacenter_name>X / — / XNot used with single-host operations, this option will specify the datacenter context
–put (-p) <local_file> <remote_file>X / X / XCopy a file from the RCLI host to the ESX(i) host using HTTP PUT
–move (-m) <source> <destination>X / X / —Move a file from one datastore to another
–rm (-r) <remote_file>X / X / —Delete a file on the ESX(i) host
–rmdir (-R) <remote_folder>X / X / —Delete a folder on the ESX(i) host
–mkdir (-M) <remote_folder>X / X / —Create a folder on the ESX(i) host

Sample Session

vifs.pl –server 192.168.1.40 –username root –dir “[datastore1] SAN01”
SAN01-flat.vmdk
SAN01.vmdk
XVS-flat.vmdk
XVS.vmdk
XVS.vmsd
XVS.vmx
XVS.vmxf

vifs.pl –server 192.168.1.40 –username root –dir [datastore1]SAN01
SAN01-flat.vmdk
SAN01.vmdk
XVS-flat.vmdk
XVS.vmdk
XVS.vmsd
XVS.vmx
XVS.vmxf

vifs.pl –server 192.168.1.40 –username root –copy /vmfs/volumes/datastore1/SAN01/XVS.vmx /vmfs/volumes/datastore1/SAN01/XVS_backup.vmx
Copied file from /vmfs/volumes/datastore1/SAN01/XVS.vmx to /vmfs/volumes/datastore1/SAN01/XVS_backup.vmx successfully.

vifs.pl –server 192.168.1.40 –username root –listdc
ha-datacenter

vifs.pl –server 192.168.1.40 –username root –listds
NFS1 (1)
datastore1

vifs.pl –server 192.168.1.40 –username root –get [datastore1]SAN01/XVS.vmx c:\tmp\XVS.vmx
Downloaded file SAN01/XVS.vmx to c:\tmp\XVS.vmx successfully.

vifs.pl –server 192.168.1.40 –username root –get [datastore1]SAN01/XVS.vmx c:\tmp\XVS.vmx –protocol http
Note: you can download via HTTP if you have enabled this. This has the potential to speed up copies by 10 to 15%

vifs.pl –server 192.168.1.40 –username root –put c:\tmp\XVS.vmx “[datastore1] SAN01/XVS2.vmx”
Uploaded file c:\tmp\XVS.vmx to SAN01/XVS2.vmx successfully.

vifs.pl –server 192.168.1.40 –username root –rm “[datastore1] SAN01/XVS2.vmx”
Remove ‘SAN01/XVS2.vmx’? (y/n) : y
Deleted file [datastore1] SAN01/XVS2.vmx successfully.

The copying and moving of datastore files and folders can also be done with the VI client. Right click on the datastore and select “Browse Datastore”. You can then use the highlighted icons to manage files and folders or you can right click to get these options.

Leave a Comment

Your email address will not be published. Required fields are marked *