Or how I learned to stop worrying and love robocopy
After spending a good deal of time importing games, adjusting metadata, and getting everything configured just right, one starts to crave the piece of mind of having a mirrored copy of that collection on another machine just in case.
Since my CLI-fu leans more Way of the Bash rather than Powershell, I naturally wanted something as trivial as
rsync $MUH_LIBRARY/ firstname.lastname@example.org.XXX:/backups/muh_library and throw that into my crontab running
@daily or similar. But, even though WSL provides a great dev experience, it doesn't necessarily (nor should it) provide some of the system-level utilities of GNU/Linux (like not having systemd, for example). But obviously, this kind of simple pattern can't be reserved to the majesty of Tux. It's just a bit different and requires some discovery.
Enter: Task Scheduler
Cool. Adjust timing to taste.
Now, what's this
launchbox.ps1? That's going to be the backup script.
# Given, $LOCAL_LAUNCHBOX_PATH = "C:\Users\coolguy\LaunchBox\" $REMOTE_LAUNCHBOX_PATH = "\\OPENMEDIAVAULT\coolguy\backups\LaunchBox" # we can mirror local to remote (this will delete files in remote if they've been removed in the source. # /copy will just copy new files in source to the sink, but since LaunchBox includes it's own DB, I'm using /mir # Of course, if you only cared about backuping the games and their file organization, /copyall may also suffice robocopy $LOCAL_LAUNCHBOX_PATH $REMOTE_LAUNCHBOX_PATH /mir # Since this will output each file as it scans for changes, I'm using Select-Object to "tail" the output. (/np is added to remove progress reporting in the log output as well) robocopy $LOCAL_LAUNCHBOX_PATH $REMOTE_LAUNCHBOX_PATH /mir /np | Select-Object -last 8 # which will output # # Total Copied Skipped Mismatch FAILED Extras # Dirs : 2098 0 2098 0 0 0 # Files : 2401 0 2401 0 0 0 # Bytes : 62.925 g 0 62.925 g 0 0 0 # Times : 0:00:08 0:00:00 0:00:00 0:00:08 # Ended : Friday, January 22, 2021 10:56:34 AM
The full script includes some start/end headers and outputs to a script (appending). Check it out:
$logpath = "$HOME\.launchbox-backup.log" $start = $(Get-Date -Format 'o') Write-Output "[$start] MIRRORING LAUNCHBOX TO MEDIAVAULT" | Out-File -FilePath $logpath -Append robocopy C:\Users\jgori\LaunchBox\ '\\OPENMEDIAVAULT\VaultBackups\launchbox' /mir /np | Select-Object -last 8 | Out-File -FilePath $logpath -Append $end = $(Get-Date -Format 'o') Write-Output "[$end] DONE" | Out-File -FilePath $logpath -Append
PS C:\Users\jgori> Get-Content .\.launchbox-backup.log [2021-01-22T10:56:26.0070112-05:00] MIRRORING LAUNCHBOX TO MEDIAVAULT Total Copied Skipped Mismatch FAILED Extras Dirs : 2098 0 2098 0 0 0 Files : 2401 0 2401 0 0 0 Bytes : 62.925 g 0 62.925 g 0 0 0 Times : 0:00:08 0:00:00 0:00:00 0:00:08 Ended : Friday, January 22, 2021 10:56:34 AM [2021-01-22T10:56:34.4067462-05:00] DONE [2021-01-22T10:56:56.1825927-05:00] MIRRORING LAUNCHBOX TO MEDIAVAULT Total Copied Skipped Mismatch FAILED Extras Dirs : 2098 0 2098 0 0 0 Files : 2402 1 2401 0 0 0 Bytes : 62.925 g 0 62.925 g 0 0 0 Times : 0:00:08 0:00:00 0:00:00 0:00:08 Ended : Friday, January 22, 2021 10:57:04 AM [2021-01-22T10:57:04.5780894-05:00] DONE
- send request to a healthchecks endpoint to register success (or failure)
- maybe integrate ntfy + pushover for push notifications
- or us smtp to send confirmations