]> git.p6c8.net - psmysqlbackup.git/blobdiff - psmysqlbackup.ps1
Added comment in header of script file
[psmysqlbackup.git] / psmysqlbackup.ps1
index a33b144607c5e5ed8fbb8abf086934a815d19791..9292ed43dfa6eea857942fe6b7882242e579c9a5 100644 (file)
@@ -1,3 +1,11 @@
+# PSMySQLBackup
+# PowerShell script for backing up MySQL / MariaDB databases on Windows 
+#
+# Author: Patrick Canterino <patrick@patrick-canterino.de>
+# WWW: https://www.patrick-canterino.de/
+#      https://github.com/pcanterino/dsmonrot
+# License: 2-Clause BSD License
+
 # Config
 
 $configMysqlHost = "localhost"
@@ -38,22 +46,22 @@ function Create-Backup([String]$database, [String]$target) {
 
 function Rotate-Backups($backupDir) {
     if($configRotate -le 0) {
-               return
-       }
-       
-       $keepBackupsCount = $configRotate
-       
-       Get-ChildItem $backupDir -File | Where-Object {($_.Name -match "^backup-.+-\d{8,}-\d{6}\.sql$")} | Sort-Object -Descending |
-       Foreach-Object {
-               if($keepBackupsCount -ge 0) {
-                       $keepBackupsCount--
-               }
-               
-               if($keepBackupsCount -eq -1) {
-                       Write-Output "Deleting backup $($_.FullName)"
-                       Remove-Item -Force $_.FullName
-               }
-       }
+        return
+    }
+    
+    $keepBackupsCount = $configRotate
+
+    Get-ChildItem $backupDir -File | Where-Object {($_.Name -match "^backup-.+-\d{8,}-\d{6}\.sql$")} | Sort-Object -Descending |
+    Foreach-Object {
+        if($keepBackupsCount -ge 0) {
+            $keepBackupsCount--
+        }
+
+        if($keepBackupsCount -eq -1) {
+            Write-Output "Deleting backup $($_.FullName)"
+            Remove-Item -Force $_.FullName
+        }
+    }
 }
 
 $defaultExclusions = @("information_schema", "performance_schema")

patrick-canterino.de