EspEasy restore config.dat rules1.txt using script

Moderators: rtenklooster, Voyager, BertB, Stuntteam

Forum rules
You have entered the experimental forum, beware!!!
Post Reply
Message
Author
ensingg
Normal user
Posts: 25
Joined: 16 Jul 2017, 10:52

EspEasy restore config.dat rules1.txt using script

#1 Post by ensingg » 19 Sep 2017, 14:56

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?

User avatar
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

#2 Post by grovkillen » 19 Sep 2017, 17:25

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 :idea: :idea: :idea:

elmicha
New user
Posts: 4
Joined: 30 Sep 2017, 20:12

Re: EspEasy restore config.dat rules1.txt using script

#3 Post by elmicha » 30 Sep 2017, 20:22

You can upload files using curl:

Code: Select all

curl --form "file=@rules1.txt" http://esp_easy_1/upload

ensingg
Normal user
Posts: 25
Joined: 16 Jul 2017, 10:52

Re: EspEasy restore config.dat rules1.txt using script

#4 Post by ensingg » 01 Oct 2017, 07:42

Super. Thats working excellent. Thank you.

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: EspEasy restore config.dat rules1.txt using script

#5 Post by papperone » 01 Oct 2017, 08:29

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

ensingg
Normal user
Posts: 25
Joined: 16 Jul 2017, 10:52

Powershell Backup script for ESP

#6 Post by ensingg » 01 Oct 2017, 10:03

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

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests