more G-Labs products

Author Topic: Not really an app.. Powershell script to backup homegenie  (Read 875 times)

January 09, 2016, 08:21:39 PM
Read 875 times

[email protected]

  • *****
  • Information
  • Hero Member
  • Posts: 271
I've knocked up a quick script for backing up all of my homegenie boxes to a nas drive via my desktop pc.

Its written in powershell but you could easily do the same in c# or bash..

script code is below..

Code: [Select]
[CmdletBinding()]
param()
# Backup Homegenie Servers - David Wallis 09-01-2016

# Array containing the IP addresses of the boxes to connect to.
$Servers = "192.168.0.69","192.168.0.47","192.168.0.172"

$OutputFolder = "Z:\Homegenie\Backups" # Change this to the place where you want to save backups to.
$uri ="api/HomeAutomation.HomeGenie/Config/System.Configure/System.ConfigurationBackup"

try {
foreach ($server in $Servers)
{
Write-Verbose "Processing $($Server)"
$url = "http://$($Server)/$($uri)"
$formattedDate  = get-date -uformat "%d-%m-%Y_%H-%M-%S"
$fourthOctet = ($server.Split("."))[3]
$outputFile = "$($OutputFolder)\homegenie_backup_config_$($fourthOctet)_$($formattedDate).zip"
Invoke-WebRequest -Uri $url -OutFile $outputFile
}
}
catch {
throw
}
save it as a .ps1 file and then run the following from a powershell prompt.

set-executionpolicy bypass; # Run this only once to enable running unsigned scripts.

then to run the script you can do:

.\ScriptName.ps1 -verbose


There are no comments for this topic. Do you want to be the first?