Export Set — Target Path outside MID server path

rgu
Tera Contributor

When setting the target path of an export set, the root of the file path is the "export" folder of the MID server software hierarchy. For example, D:\ServiceNow\prod_midserver\export.

What solutions do you employ for directly telling an export set to place (or copy) the file to a location outside of the MID server software hierarchy? For example, D:\Dropbox.

I do not want to have to rely on a batch file and Windows scheduled task to move/copy files after the fact.

I found this post, but it concerns FTPing the file. I was not sure how to modify it to a file copy.

https://community.servicenow.com/community/blogs/blog/2016/11/22/using-export-sets-transfer-using-sf...

I also found this previous post on the topic, but the person that answered it did not fully understand the question.

https://community.servicenow.com/thread/293571

Thanks for your time.

13 REPLIES 13

Moon1
Giga Contributor

HI, GowriSankar,

This may be not an answer you want to get to configure the Destination Folder outside MIDServer environment such as shared network driver or so.

My solution on our org is to use 'Batch script' to export from [MID Server]\export folder to your target folder, and use the Window Scheduler to execute my batch script (powershell).

Below is my PowerScript, and I copied to the MID Server and set up / execute the Window Scheduler to execute every midnight to move out the Exported Set (all log files) to the target folder.

Wish it help your issue as the work-around solution. It works last four months nicely.

NOTE: Better to use the schedule runner user has not limited by the Password expiry date or change policy. So I am using the Service account and add it to the Admin role on the MID Server and use that user for the Window Schedule Task.

So here is my PowserShell script, and leave you to find out how to set up Window schedule to execute the PowerShell script (for example, https://community.spiceworks.com/how_to/17736-run-powershell-scripts-from-task-scheduler)

--- Powershell script ---

#---
# Script: CreateZipArchiveOfFolder.ps1
# comments: .NET Framework 4.5 above required.
# original: https://blogs.technet.microsoft.com/heyscriptingguy/2015/03/09/use-powershell-to-create-zip-archive-of-folder/
# PowerShell: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-6&viewFallbackFrom=powershell-Microsoft.PowerShell.Core
# Author: Munhwan Gim
# Last Modified Date: 2018 May 10
# Comment: Need to improve to move the network Map Drive out of MID Server if any concern for Diskspace.
#----
$source = "E:\Program Files\Snow\PROD_MID_Server\agent\export"

$destinationFolder = "E:\backup\SNOW_MID_Export"
$extractFolderName = "extract"
$extractPath = $destinationFolder + "\" + $extractFolderName

$destination = $destinationFolder + "\export_PROD_MID_server_$(get-date -f yyyy-MM-dd).zip"

# Remove the existing backup with the same name if any
If(Test-path $destination) {Remove-item $destination}

# Compress all exported files
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($source, $destination)

# Extract the backed up files to check
[io.compression.zipfile]::ExtractToDirectory($destination, $extractPath)

# Remove files on $source in order to collect only one night exported filed
Get-ChildItem -Path $source -Include * -File -Recurse | foreach {$_.Delete()}

-----------------------------

 

cheers,

Munhwan (aka Moon1) Gim

 

 

Hi Saskhi, 

Did you find the solution for exporting the filer to different directory other than Mid Server directory. Let me know if you have any solution for it

You can create a symlink to any other path, and store it in the mid server directory. See my previous comment further below.

Jon Ulrich
Kilo Guru

I just had this same issue, and found the solution

You can create a symlink in your export folder to the remote server:

In a command prompt type the following, substituting your required paths

mklink /D "D:\mymidserver\agent\export\folder_name" \\myserver\myshare\myfolder


This will create a new subfolder in your export folder called "folder_name" that is mapped to the remote server.
In your export set target File Path put the name of the new folder "folder_name"

This should do it for you 🙂