Created
February 11, 2018 20:14
-
-
Save goyalmohit/bb9164a8e35fb0bd242acf4cf1eb619c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cosmosServer = "mycosmos.documents.azure.com:10255" #Define the cosmos db hostname and port | |
$cosmosUser = "mycosmos-username" #Define username | |
$cosmosPassword = "mycosmos-password" #Defines password | |
$backupDir = "C:\cosmos-backup\$(Get-Date -Format yyyyMMddhhmmss)" | |
if(!(Test-Path $backupDir)){ | |
Write-Host "Creating temporary backup directory as $backupDir" | |
New-Item -Path $backupDir -ItemType Directory | Out-Null | |
} | |
Set-Location $backupDir | |
$mongoExe = "C:\Program Files\MongoDB\Server\3.6\bin\mongodump.exe" | |
$arguments = "--host $cosmosServer -u $cosmosUser -p $cosmosPassword --ssl --sslAllowInvalidCertificates --out $backupDir -vvvvv" | |
Start-Process $mongoExe $arguments -Wait -RedirectStandardError "standarderror.txt" -RedirectStandardOutput "standardoutput.txt" | |
Write-Host "Displaying standard output:" | |
Get-Content "standardoutput.txt" | |
Write-Host "Displaying if any errors:" | |
Get-Content "standarderror.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment