I made a (powershell) script dat backups all the settings from the esp8266's in my network and zip it to a daily package.
But now I like to change a rules1.txt using that script and put it back to the espeasy.
Is it possible to do an upload of a rules1.txt (or other) to the esp using HTTP url commands?
EspEasy restore config.dat rules1.txt using script
Moderators: rtenklooster, Voyager, BertB, Stuntteam
Forum rules
You have entered the experimental forum, beware!!!
You have entered the experimental forum, beware!!!
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: EspEasy restore config.dat rules1.txt using script
The only way is these ways: https://www.letscontrolit.com/wiki/inde ... nd_restore
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: EspEasy restore config.dat rules1.txt using script
You can upload files using curl:
Code: Select all
curl --form "file=@rules1.txt" http://esp_easy_1/upload
Re: EspEasy restore config.dat rules1.txt using script
Super. Thats working excellent. Thank you.
Re: EspEasy restore config.dat rules1.txt using script
ensingg would you mind to share your script?
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone
Powershell Backup script for ESP
This is the Windows powershell script I created for home use. It will backup all configuration files of the espeasy in a folder (see end of script) and zip it together.
The code can probably optimized. But works.
<#
.Synopsis
Short description
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
#>
function Export-ESPSettings
{
[CmdletBinding()]
[Alias()]
[OutputType([int])]
Param
(
# Param1 help description
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
$Hostname,
# Param2 help description
$OutputDir
)
Begin
{
remove-item $OutputDir"config.dat"
remove-item $OutputDir"security.dat"
remove-item $OutputDir"rules1.txt"
remove-item $OutputDir"rules2.txt"
remove-item $OutputDir"rules3.txt"
remove-item $OutputDir"rules4.txt"
remove-item $OutputDir"esp.css"
}
Process
{
Invoke-WebRequest -uri "http://$hostname/config.dat" -outfile $outputdir"config.dat"
Invoke-WebRequest -uri "http://$hostname/security.dat" -outfile $outputdir"security.dat"
Invoke-WebRequest -uri "http://$hostname/rules1.txt" -outfile $outputdir"rules1.txt"
Invoke-WebRequest -uri "http://$hostname/rules2.txt" -outfile $outputdir"rules2.txt"
Invoke-WebRequest -uri "http://$hostname/rules3.txt" -outfile $outputdir"rules3.txt"
Invoke-WebRequest -uri "http://$hostname/rules4.txt" -outfile $outputdir"rules4.txt"
Invoke-WebRequest -uri "http://$hostname/esp.css" -outfile $outputdir"esp.css"
}
End
{
$Hostn=$hostname.replace(".","")
compress-archive -path $OutputDir"config.dat" -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"security.dat" -update -DestinationPath ($OutputDir+ $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"rules1.txt" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"rules2.txt" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"rules3.txt" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"rules4.txt" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"esp.css" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
remove-item $OutputDir"config.dat"
remove-item $OutputDir"security.dat"
remove-item $OutputDir"rules1.txt"
remove-item $OutputDir"rules2.txt"
remove-item $OutputDir"rules3.txt"
remove-item $OutputDir"rules4.txt"
remove-item $OutputDir"esp.css"
}
}
$pad="c:\backup\esp\"
Export-ESPSettings -Hostname "192.168.0.10" -OutputDir $pad
Export-ESPSettings -Hostname "192.168.0.20" -OutputDir $pad
The code can probably optimized. But works.
<#
.Synopsis
Short description
.DESCRIPTION
Long description
.EXAMPLE
Example of how to use this cmdlet
.EXAMPLE
Another example of how to use this cmdlet
#>
function Export-ESPSettings
{
[CmdletBinding()]
[Alias()]
[OutputType([int])]
Param
(
# Param1 help description
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
$Hostname,
# Param2 help description
$OutputDir
)
Begin
{
remove-item $OutputDir"config.dat"
remove-item $OutputDir"security.dat"
remove-item $OutputDir"rules1.txt"
remove-item $OutputDir"rules2.txt"
remove-item $OutputDir"rules3.txt"
remove-item $OutputDir"rules4.txt"
remove-item $OutputDir"esp.css"
}
Process
{
Invoke-WebRequest -uri "http://$hostname/config.dat" -outfile $outputdir"config.dat"
Invoke-WebRequest -uri "http://$hostname/security.dat" -outfile $outputdir"security.dat"
Invoke-WebRequest -uri "http://$hostname/rules1.txt" -outfile $outputdir"rules1.txt"
Invoke-WebRequest -uri "http://$hostname/rules2.txt" -outfile $outputdir"rules2.txt"
Invoke-WebRequest -uri "http://$hostname/rules3.txt" -outfile $outputdir"rules3.txt"
Invoke-WebRequest -uri "http://$hostname/rules4.txt" -outfile $outputdir"rules4.txt"
Invoke-WebRequest -uri "http://$hostname/esp.css" -outfile $outputdir"esp.css"
}
End
{
$Hostn=$hostname.replace(".","")
compress-archive -path $OutputDir"config.dat" -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"security.dat" -update -DestinationPath ($OutputDir+ $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"rules1.txt" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"rules2.txt" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"rules3.txt" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"rules4.txt" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
compress-archive -path $OutputDir"esp.css" -update -DestinationPath ($OutputDir + $hostn +"_" + (get-date -Format yyyyMMddHHmm) + '.zip')
remove-item $OutputDir"config.dat"
remove-item $OutputDir"security.dat"
remove-item $OutputDir"rules1.txt"
remove-item $OutputDir"rules2.txt"
remove-item $OutputDir"rules3.txt"
remove-item $OutputDir"rules4.txt"
remove-item $OutputDir"esp.css"
}
}
$pad="c:\backup\esp\"
Export-ESPSettings -Hostname "192.168.0.10" -OutputDir $pad
Export-ESPSettings -Hostname "192.168.0.20" -OutputDir $pad
Who is online
Users browsing this forum: No registered users and 6 guests