Skip to content

Instantly share code, notes, and snippets.

@hafei
Forked from stefanwalther/Backup_MongoDB.ps1
Created August 16, 2018 03:42
Show Gist options
  • Save hafei/ece8c8608cb15f8c672ad086daa41d78 to your computer and use it in GitHub Desktop.
Save hafei/ece8c8608cb15f8c672ad086daa41d78 to your computer and use it in GitHub Desktop.
Powershell to backup all local MongoDB databases
$date = Get-Date -UFormat %Y-%m-%d;
$backupFolder = $date;
$basePath = "C:\bla";
$destinationPath = Join-Path $basePath $backupFolder;
if(!(Test-Path -Path $destinationPath)) {
New-Item -ItemType directory -Path $destinationPath;
(C:\mongodb\bin\mongodump.exe --out $destinationPath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment