Created
November 5, 2017 09:54
-
-
Save adrianvlupu/c11ae686907dd53b0b5ac3278af28c38 to your computer and use it in GitHub Desktop.
This file contains 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
$date = Get-Date -UFormat %Y-%m-%d; | |
$backupFolder = $date; | |
$basePath = 'C:\projects\db-backups'; | |
$destinationPath = Join-Path $basePath $backupFolder; | |
$mongodumpPath = 'C:\Program Files\MongoDB\Server\3.4\bin\mongodump.exe'; | |
Write-Host " | |
Your backup parameters are: | |
mongodump: $mongodumpPath | |
output: $basePath | |
"; | |
$shouldChangeOutputBit = Read-Host -Prompt 'Change the output base path ? (Y/N)'; | |
if ($shouldChangeOutputBit -eq 'Y' ) { | |
$basePath = Read-Host -Prompt 'Enter the new backup path'; | |
$destinationPath = Join-Path $basePath $backupFolder; | |
Write-Host " | |
Your NEW output path is: $basePath"; | |
} | |
if (!(Test-Path -Path $destinationPath)) { | |
New-Item -ItemType directory -Path $destinationPath; | |
} | |
& $mongodumpPath --out $destinationPath; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment