Page 1 of 1

Restore database via curl

Posted: Tuesday 08 January 2019 19:03
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!

Re: Restore database via curl

Posted: Tuesday 08 January 2019 22:10
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

Re: Restore database via curl

Posted: Thursday 10 January 2019 1:11
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 =(