Skip to content

Commit 0960dc8

Browse files
authored
added built-in compress for mongodump command
1 parent 97b2331 commit 0960dc8

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

backupMongoDatabase.ps1

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,12 @@ Write-Host "Backing up the Database: '$databaseName' to local directory: $backup
3838

3939
# ATTENTION ⚠: Use the absolute path if you haven't added mongo to your System Path
4040
# Ex: C:\mongodb\bin\mongodump.exe -h $mongoDbHost -d $databaseName -o "$directoryPath"
41-
mongodump -h "$mongoDbHost" -d "$databaseName" -o "$directoryPath"
41+
# Version 3.2 introduced gzip & archive
42+
mongodump --gzip -h "$mongoDbHost" -d "$databaseName" -o "$directoryPath"
4243

4344
Write-Host "Creating the backup for $databaseName..."
4445

4546
$watch.Stop();
4647
Write-Host "MongoDB backup completed in "$watch.Elapsed.ToString()
4748

48-
# Zip sfolder
49-
Write-Host "Zipping the folder backup folder..."
50-
Compress-Archive -Path "$directoryPath" -DestinationPath $zippedFileDestinationPath
51-
52-
# Delete the backup folter created
53-
Write-Host "Delete backup's folder"
54-
Remove-Item "$directoryPath" -Recurse
55-
5649
#endregion

0 commit comments

Comments
 (0)