Page 1 of 1

Step by step guide to restore a backup or database to a Pi

Posted: Monday 02 December 2013 1:21
by skuzob
Hi, I am not the best with Linux or the Pi but slowly learning.
I have screenshots but don't have time to upload right now.

How to manually restore a Domoticz database for Raspberry Pi from a Windows machine.

I have had 3 SD card failures since starting to use Domoticz with my Raspberry Pi and RFXCOM in August.
I hope this helps those that have had similar problems. All three cards were Kingston Class 4 4gb Mico SDHC cards.

Symptoms: Domoticz running for weeks then webpages fail to load. You can ping Raspberry Pi but cannot SSH to device with putty.
Rebooting of device makes no difference. Putting the SD card into a Windows machine result in no SD card found or only the boot partition loaded.

Step 1: Once you have found Domoticz has stopped and you can no longer use Putty to log into your device through SSH we have no option to safely power down the Pi. Remove the power connecter from the Pi and then remove the SD card. Do not remove the SD card while the Pi is powered up.

Step 2: If you have failed to take regular database backups from the inbuilt option in Domoticz under http://deviceIP:8080#Setup Backup Database, you may be able to recover the old database from your SD card. In Windows, download Disk Internals linux reader.
http://www.diskinternals.com/linux-reader/
Once installed, navigate to /home/pi/domoticz and save the domoticz.db to your machine. If the SD card fails to be recognised by the windows machine (as happened to me the first time) you are out of luck and will have to go back to an older backup. If you have no backup you will have to start your Domoticz from scratch.

Step 3: Buy a class 10 high quality SD card. This list here seems to be the most comprehensive for Raspberry Pi http://elinux.org/RPi_SD_cards. I purchased a PNY Class 10 8 GB card that can run at up to 27 MB/s as it was the only one I could find for under €20 on a Sunday.

Step 4: During the down time, I took the opportunity to upgrade my RFXCOM device to the latest firmware from http://www.rfxcom.com/Downloads

Step 5: Create a new Domoticz SD card using the latest version from http://sourceforge.net/projects/domoticz/files/

Step 6: Place the new SD card into your Raspberry Pi and power up the Pi.

Step 7: If you are lucky, your router should assign the same DHCP address to the Pi. If not, please refer back to the Domoticz Manual to carry out the initial setup of the Pi. Check that you can log into the Domoticz main page.

Step 8: Load putty.exe and log in with
User: pi
Password: raspberry

Step 9: Next, we need to expand the file system, otherwise we will not be able to copy over files to the Pi as it will have a disk full error. To do this, type
sudo raspi-config

While here, you can take the time to set the time zone and change the default password.

We can now choose finish and reboot the pi.

Step 10: Using putty, we can log in again and shutdown the Domoticz service using;

sudo service domoticz.sh stop

Step 11: Download and install WINSCP from http://winscp.net/eng/index.php and use the SCP protocol settings to log into the Pi

Step 12: On the right hand pane in WinSCP navigate to /home/pi/domoticz

Step 13: Rename domoticz.db to domoticz._db so we can restore to the clean database if the old database does not work.

Step 14: Using the left hand pane in WinSCP, navigate to the backup.db you have saved or domoticz.db which you have recovered from your bad SD card.

Step 15: Copy the required database file over. Ensure the file brought over is renamed domoticz.db

Step 16: Use putty to start domoticz.

sudo service domoticz.sh start

Step 17: You should now be able to log back into Domoticz. Make sure to set the correct mode for your RFXCOM under http://xxx.xxx.xxx.xxx:8080/#Hardware as this information will need to be resent to the RFXCOM device if you upgraded the firmware. The Class 10 SD card also helps the device boot much faster and domoticz seems much more responsive.

Step 18: Using W32Disk Imager, take a backup of the SD card to your machine.

Re: Step by step guide to restore a backup or database to a

Posted: Monday 02 December 2013 8:13
by jkimmel
For me this came exactly to the right time. Was faced with a non working webui.

Thank you!

Re: Step by step guide to restore a backup or database to a

Posted: Monday 02 December 2013 12:12
by bizziebis
Nice work. Can imagine it will help a lot of people who don't have much Linux knowledge.

Would be nice if Domoticz had an option to restore a database backup. Then you only have to make a new SD card and upload the database through the web interface.

Re: Step by step guide to restore a backup or database to a

Posted: Monday 02 December 2013 18:45
by Peter112
add to the domoticz wiki pages ?

Re: Step by step guide to restore a backup or database to a

Posted: Friday 14 March 2014 11:15
by Marbaf
Yes, I do not know if it's done, but I agree with last request, add this excellent post to wiki !

Re: Step by step guide to restore a backup or database to a

Posted: Sunday 20 April 2014 16:44
by gizmocuz
bizziebis wrote:Nice work. Can imagine it will help a lot of people who don't have much Linux knowledge.

Would be nice if Domoticz had an option to restore a database backup. Then you only have to make a new SD card and upload the database through the web interface.
This is included, see bottom of application settings page

Re: Step by step guide to restore a backup or database to a Pi

Posted: Wednesday 03 August 2016 22:12
by Larsja
I just wanna say a big thanks :D

Noticed unstability on my domoticz, suspecting a faulty SD card. Managed to fuck it up, fuck it up again by restoring a backup that was stored on my laptop from early may (lots have happened since then ;) and with the linuxreader thingy ive found the daily backup folder, with hourly, daily and monthly, so now im atleast some steps closer to restore it on my new sd card.

Re: Step by step guide to restore a backup or database to a Pi

Posted: Tuesday 30 October 2018 18:44
by walberg
how can i copy domoticz.db from de SD cart to my Mac?

(there is no web interface anymore)

Re: Step by step guide to restore a backup or database to a Pi

Posted: Friday 30 October 2020 20:45
by tweet
tnx!

Re: Step by step guide to restore a backup or database to a Pi

Posted: Saturday 31 October 2020 10:50
by McMelloW
@skuzob

Thanks for sharing this. You have quite some struggle with your RPi

Perhaps this can be of some help to you to backup and restore your SD-Card

https://github.com/framps/raspiBackup
https://www.linux-tips-and-tricks.de/en/

And Look here for an example on a Reboot or Shutdown Switch in case your RPi is not reachable. It is just one of the many on internet.

https://sigmdel.ca/michel/ha/rpi/guide_ ... bootswitch