VMware Cloud Community
kaizenwerks
Contributor
Contributor

Copy files from a datastore to a network location

Hi all,

I was wondering if there was a way to script the copy of files (specifically syslog files) from a datastore to a network location. If so, it would be great if someone should shed some light on how to script this. Thanks!

0 Kudos
9 Replies
harkamal
Expert
Expert

May be you can mount the target network share as NFS datastore and move files from source ?

0 Kudos
kaizenwerks
Contributor
Contributor

Thanks for the reply Harkamal.

I have some concerns with creating a NFS mount where there will be a constant flow of writes to the NFS. Multiple that by several hundred hosts and there may be some network considerations and risks.

What I have done so far is setup ESXi hosts for FTP but to survive a reboot, the OEM.tgz needs to be customized. Although we've probably surpassed the gray area of unsupported configuration, customizing the installation is somewhere I'd like to avoid. We're looking to get these syslog files in an automated fashion over to an existing centralized repository for generating reports.

I'm looking to see if there is a better method or solution to accomplishing this goal, hence scripting the batch copy. Hope this helps. Thanks again all!

0 Kudos
admin
Immortal
Immortal

Check out Copy-DatastoreFile in the VI Toolkit Extensions.

Edit: The actual name is Copy-TkeDatastoreFile

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

0 Kudos
kaizenwerks
Contributor
Contributor

Thanks for the reply Carter. I did a Get-Help on Copy-DatastoreFile, thumbed through the PowerCLI Guide and did a google search on the command with no luck. Please excuse my novice question when I ask for more information so I can work through it. With this command, can files from a datastore be copied to a Windows file system? If so, can you provide an example? Much appreciated.

0 Kudos
bulletprooffool
Champion
Champion

Plenty options

You could look into the Vima appliance and just set up a cron job?

Next option is a powershell Scheduled task somewhere on a Windows host

Next, look into running something like rsync. . . I am sure it has been done.

Redirect the location of your logs to a network storage location and copy using the tools for that storage

WinSCP

Veeamm FastSCP

just need to select what you like working with.

One day I will virtualise myself . . .
kaizenwerks
Contributor
Contributor

Thanks for the reply bulletprooffool.

Previously I was going to set up cron jobs in combination with enabling FTP on our ESXi hosts. I just didn't want to resort to customizing the oem.tgz to survive the reboot (see previous posts). I don't have a budget for this so the Vima appliance won't be an option for me. Nice idea though.

Anyway, I'm good with going the scheduled tasks route as I've done with other tasks but I just haven't found the syntax to perform the copy to a network location. The Copy-DatastoreFile has been brought up but I haven't been able to find anything on it. Thanks.

0 Kudos
admin
Immortal
Immortal

That should read Copy-TkeDatastoreFile. it's in the VI Toolkit Extensions.

=====

Carter Shanklin

Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]

kaizenwerks
Contributor
Contributor

Thanks for the reply Carter. I followed your link and I'm excited to see the capabilities of this module. I have been using snap-ins so this will be the first time I am utilizing modules. Thanks for putting the module together. Here is where I am at:

I have loaded the viToolkitExtensions module and have the prompt to input a source but do not know the syntax. Can you provide some info on the syntax for source and destination?

Error message

-


Copy-TkeDatastoreFile : Can't determine source server, are you connected?

At line:1 char:22

+ Copy-TkeDatastoreFile <<<<

+ CategoryInfo : NotSpecified: (Smiley Happy , WriteErrorExcep

tion

+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio

n,Copy-TkeDatastoreFile

-


I have tried "/vmfs/volumes/4933e7d6-f1d66806-3f99-001a645cab94/Syslog", "Datastore/Syslog" ,"Datastore/Syslog/Syslog.log"

In addition, it would be great to understand the syntax for the destination. Thanks again.

0 Kudos
JimmyDean
Enthusiast
Enthusiast

I only see

code --> Copy-DatastoreItem

Synopsis

Copies items between datastores and between a datastore and a local file system provider.

Requirements

requires Snap-In VMware.VimAutomation.Core:

Add-PSSnapin VMware.VimAutomation.Core

0 Kudos