Search
  • Syracuse Lights

How I Backup the Show.

Updated: Dec 11, 2020

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.


  1. I don't need to copy the backup folder to the show computer.

  2. 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.

  3. I don't need to copy the render cache at all, to the show computer or the NAS.

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

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


The code does the following:

  1. Zips the contents of the Backup Folder

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

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

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

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

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

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.


XLights Complete Backup.ps1





clear

function Test-Administrator  
{  
    [OutputType([bool])]
    param()
    process {
        [Security.Principal.WindowsPrincipal]$user = [Security.Principal.WindowsIdentity]::GetCurrent();
        return $user.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator);
    }
}

if(-not (Test-Administrator))
{
    # TODO: define proper exit codes for the given errors 
    Write-Error "This script must be executed as Administrator.";
    exit 1;
}

$ErrorActionPreference = "Stop";

set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
$7z = "C:\Program Files\7-Zip\7z.exe"
$dropbox = "\\192.168.10.155\DropBox\Christmas Lights\xLights"
$showPC = "\\192.168.50.100\xlightsShow\"
$desktop = "E:\xLights"
$excludeDesktop1 = "E:\xLights\Backup"
$excludeDesktop2 = "E:\xLights\Backup-Zipped"
$excludeDesktop3 = "E:\xLights\RenderCache"
$excludeShowPC2 = "\\192.168.50.100\xlightsShow\Backup"
$excludeShowPC1 = "\\192.168.50.100\xlightsShow\RenderCache"
$excludeDropbox1 = "E:\xLights\RenderCache"
$excludeDropbox2 = "E:\xLights\Backup"
$dirs = Get-ChildItem -Path $excludeDesktop1 | Where-Object { $_.Attributes -eq "Directory" }


#Zips Backup folders to ZIP Files
# Creates 7z files based on the parent folders name and drops it inside the archive folder
Foreach ($dir in $dirs)
{
      $name = $dir.name
      $newname = $name.ToLower() -replace(" ","")
      sz a -t7z "$excludeDesktop2\$newname" "$excludeDesktop1\$dir"

}


#Copy from Backuped Zip Files to "Backup-Zipped" Diectory
robocopy $excludeDesktop1 $excludeDesktop2 *.zip

#pause

#Copy from Desktop to Show
robocopy $desktop $showPC *.* /XO /E /R:5 /W:5 /TBD /V /XD $excludeDesktop1 $excludeDesktop2 $excludeDesktop3

#pause

#Copy from Show to Desktop
robocopy $showPC $desktop *.* /XO /E /R:5 /W:5 /TBD /V /XD $excludeShowPC1 $excludeShowPC2

#pause

#Delete all content in the Backup Folder. If syncing with DropBox, this will save SEVERAL minutes to hours.

Remove-Item -Recurse -Force $excludeDesktop1

#pause

#Copy from Desktop to dropbox
robocopy $desktop $dropbox *.* /XO  /E /R:5 /W:5 /TBD /V /XD $excludeDropbox1 $excludeDropbox2




95 views0 comments

Recent Posts

See All