I design the our show from my main desktop, I also have a show computer that I run, and I have a Synology NAS that gets backed up to DropBox using “CloudSync”. I have ran into a few issues with syncing to the show computer and to my Synology/DropBox.

n

    n

  1. I don’t need to copy the backup folder to the show computer.
  2. n

  3. I want the backups to be compressed so that way the sync does not need to copy 1,000 files to the cloud, just one and it’s compressed. Copying those 1,000 files can take several minutes to hours depending on your upload speed. Copying just one file takes seconds.
  4. n

  5. I don’t need to copy the render cache at all, to the show computer or the NAS.
  6. n

  7. If I happen to make a change on the show computer last minute, I want that change synced back down to my main computer.
  8. n

So here is the code that I use to do all of that.

nn

The code does the following:

    n

  1. Zips the contents of the Backup Folder
  2. n

  3. Copies those zip files to a new directory (Backup-Zipped) in the show folder
  4. n

  5. Copies newer changed files from Desktop to Show PC (excludes Backup Folders and Render Cache folder)
  6. n

  7. Copies newer changed files from Show to Desktop PC (excludes Backup Folder and Render Cache folder)
  8. n

  9. Deletes the content of the Backup Folder (prevents the cloud sync from having to upload 1Ks of files).
  10. n

  11. Copies newer changed files from Desktop to Show PC (excludes Render Cache folder)
  12. n

Download the PowerShell script. Please use with care, some of the code does remove files that I no longer want to keep because they are zipped.

nn

XLights Complete Backup.ps1

nnnn

clearnnfunction Test-Administrator  n{  n    [OutputType([bool])]n    param()n    process {n        [Security.Principal.WindowsPrincipal]$user = [Security.Principal.WindowsIdentity]::GetCurrent();n        return $user.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator);n    }n}nnif(-not (Test-Administrator))n{n    # TODO: define proper exit codes for the given errors n    Write-Error "This script must be executed as Administrator.";n    exit 1;n}nn$ErrorActionPreference = "Stop";nnset-alias sz "$env:ProgramFiles\7-Zip\7z.exe"n$7z = "C:\Program Files\7-Zip\7z.exe"n$dropbox = "\\192.168.10.155\DropBox\Christmas Lights\xLights"n$showPC = "\\192.168.50.100\xlightsShow\"n$desktop = "E:\xLights"n$excludeDesktop1 = "E:\xLights\Backup"n$excludeDesktop2 = "E:\xLights\Backup-Zipped"n$excludeDesktop3 = "E:\xLights\RenderCache"n$excludeShowPC2 = "\\192.168.50.100\xlightsShow\Backup"n$excludeShowPC1 = "\\192.168.50.100\xlightsShow\RenderCache"n$excludeDropbox1 = "E:\xLights\RenderCache"n$excludeDropbox2 = "E:\xLights\Backup"n$dirs = Get-ChildItem -Path $excludeDesktop1 | Where-Object { $_.Attributes -eq "Directory" }nnn#Zips Backup folders to ZIP Filesn# Creates 7z files based on the parent folders name and drops it inside the archive foldernForeach ($dir in $dirs)n{n      $name = $dir.namen      $newname = $name.ToLower() -replace(" ","")n      sz a -t7z "$excludeDesktop2\$newname" "$excludeDesktop1\$dir"nn}nnn#Copy from Backuped Zip Files to "Backup-Zipped" Diectorynrobocopy $excludeDesktop1 $excludeDesktop2 *.zipnn#pausenn#Copy from Desktop to Shownrobocopy $desktop $showPC *.* /XO /E /R:5 /W:5 /TBD /V /XD $excludeDesktop1 $excludeDesktop2 $excludeDesktop3nn#pausenn#Copy from Show to Desktopnrobocopy $showPC $desktop *.* /XO /E /R:5 /W:5 /TBD /V /XD $excludeShowPC1 $excludeShowPC2nn#pausenn#Delete all content in the Backup Folder. If syncing with DropBox, this will save SEVERAL minutes to hours.nnRemove-Item -Recurse -Force $excludeDesktop1nn#pausenn#Copy from Desktop to dropboxnrobocopy $desktop $dropbox *.* /XO  /E /R:5 /W:5 /TBD /V /XD $excludeDropbox1 $excludeDropbox2n

nn

Leave a Reply

Your email address will not be published. Required fields are marked *