Restore database via curl

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
survivor182ca
Posts: 4
Joined: Tuesday 08 January 2019 18:57
Target OS: Linux
Domoticz version:
Contact:

Restore database via curl

Post by survivor182ca »

Hi,

We can do a backup via curl script easily :

Code: Select all

/usr/bin/curl -s http://127.0.0.1:8080/backupdatabase.php > /var/tmp/domoticz_backup/$BACKUPFILE 
My question is : can we do database restore via curl command???

Thank in advance!
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Restore database via curl

Post by waaren »

survivor182ca wrote: Tuesday 08 January 2019 19:03 Hi,

We can do a backup via curl script easily :

Code: Select all

/usr/bin/curl -s http://127.0.0.1:8080/backupdatabase.php > /var/tmp/domoticz_backup/$BACKUPFILE 
My question is : can we do database restore via curl command???

Thank in advance!
Not using the http://127.0.0.1:8080 This is pointing to an active domoticz.
If you would setup another server on your system like with

Code: Select all

cd /var/tmp/domoticz_backup
sudo python -m SimpleHTTPServer 8081
You could then use (from another window)

Code: Select all

cd domoticzdir
sudo curl -o domoticz.db2 localhost:8081/$BACKUPFILE
#
#db2 to ensure you do not overwrite your database by accident 
#
but why ? Why not simply use

Code: Select all

cd domoticzdir
sudo cp /var/tmp/domoticz_backup/$BACKUPFILE  domoticz.db2
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
survivor182ca
Posts: 4
Joined: Tuesday 08 January 2019 18:57
Target OS: Linux
Domoticz version:
Contact:

Re: Restore database via curl

Post by survivor182ca »

I want the curl restore because I run Domoticz on OpenWRT router and the database is always empty when the process starts.

Also the database is stored on the temporary drive /tmp/ ... this is why the database is empty at starts

I could run a CRON job that just restore my database every day if a curl command exist.

Copying the database to the path when the process is started does not work =(
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest