Browse Source

Handled multiple dated backups + better choice output

No more infinite loop, and split "before event" into two parts.
jenn 1 year ago
parent
commit
2e15678fea
2 changed files with 19 additions and 11 deletions
  1. BIN
      windows/DJ/RUN - Sync Files.lnk
  2. 19 11
      windows/DJ/Sync-DJ.ps1

BIN
windows/DJ/RUN - Sync Files.lnk


+ 19 - 11
windows/DJ/Sync-DJ.ps1

@@ -44,14 +44,14 @@ $CHOICES = @(
         "Mixxx:   Desktop --> Server",
         [SourceDirs]::MixxxConfig,
         [SourceDirs]::Music_MixxxConfig,
-        $false, # Make Backup
+        $true,  # Make Backup
         $false  # Ignore Timestamps
     ),
     [Choice]::new(
         "Mixxx:   Desktop --> Drive",
         [SourceDirs]::MixxxConfig,
         [SourceDirs]::Drive_MixxxConfig,
-        $false, # Make Backup
+        $true,  # Make Backup
         $false  # Ignore Timestamps
     ),
     [Choice]::new(
@@ -153,24 +153,23 @@ function GetModifiedDate($dirPath) {
 function makeDatedBackup($dirPath) {
     if (-not(Test-Path $dirPath)) {
         # Not an error, but nothing we can do.
-        out "Directory does no exist: ${dirPath}"
         return
     }
 
     $modifiedDate = GetModifiedDate($dirPath)
     $newPath = "$dirPath-$modifiedDate"
-    
     if (Test-Path $newPath) {
         $num = 2
         $newNewPath = "$newPath-$num"
         while (Test-Path $newNewPath) {
             $num++
+            $newNewPath = "$newPath-$num"
         }
         out "$newPath already exists. Using $newNewPath"
         $newPath = $newNewPath
     }
-
     $dirName = [io.path]::GetFileName($newPath)
+    out "DEBUG: Make dated backup"
     pause "Moving $dirPath to $dirName"
 
     Move-Item -Path $dirPath -Destination $newPath
@@ -209,10 +208,13 @@ function syncDirs {
     if ($IgnoreTimestamps) {
         $roboAdditionalExcludes = @("/xn")
     }
+	
+	if ($Source -eq [SourceDirs]::MixxxConfig) {
+		$roboAdditionalExcludes = @("/xd", [string]::Format("{0}\analysis", [SourceDirs]::MixxxConfig))
+	}
 
     pause "Copying contents of: `n`t${Source}`nTo:`n`t${Destination}"
-
-    robocopy $Source $Destination $roboWhat $roboOptions $roboExclude
+    robocopy $Source $Destination $roboWhat $roboOptions $roboExclude $roboAdditionalExcludes
 }
 
 function chooseSyncOption() {
@@ -224,9 +226,10 @@ function chooseSyncOption() {
     }
     Write-Host "`n`n"
 
-    Write-Host "Before an event: 1, 2, 6, 9"
-    Write-Host "During an event: 3"
-    Write-host "After an event:  5, 7, 8, 10, 4"
+    Write-Host "Before an event:    1, 2, 6, 9"
+    Write-Host "During an event:    3"
+	Write-Host "Laptop after event: 5"
+    Write-host "After an event:     7, 8, 10, 4"
     $input = Read-Host -Prompt "Enter option number"
     $choice = [int]$input
 
@@ -247,7 +250,12 @@ function Main() {
         -IgnoreTimestamps $option.IgnoreTimestamps
     #syncDirs -Source ([SourceDirs]::MixxxConfig) -Destination ([SourceDirs]::Test) -NoBackup -IgnoreTimestamps
 
-    pause ([string]::Format("Done running {0}!", $option.DisplayName))
+    pause ([string]::Format(
+        "Done running {0}!`n`t{1} --> {2}",
+        $option.DisplayName,
+        $option.Source,
+        $option.Dest
+    ))
 }
 
 Main