#************************************************************** #* Copyright 2018 Ali Corporation, All Rights Reserved #************************************************************** # configurations $BackupDir = "" $MongoDBInstallDir = "" $DBHOST = "" $DBPORT = "" # credential env should be set in workflow.env # $Env:Username # $Env:Password $id = (Get-Date -Format yyyyMMdd-HHmmss) & $MongoDBInstallDir/bin/mongodump.exe --host $DBHOST --port $DBPORT --username $Env:Username --password $Env:Password --archive > $BackupDir/mongodb-$id.bak if ($LastExitCode -ne 0) { throw "mongodump exited with error $LastExitCode" }