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

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
skuzob
Posts: 3
Joined: Monday 02 December 2013 1:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post 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.
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

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

Post by jkimmel »

For me this came exactly to the right time. Was faced with a non working webui.

Thank you!
Rfxcom
Raspi 4
User avatar
bizziebis
Posts: 182
Joined: Saturday 19 October 2013 14:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8805
Location: The Netherlands
Contact:

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

Post 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.
Peter112
Posts: 16
Joined: Tuesday 15 October 2013 14:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Uithuizen,Groningen,The Netherlands
Contact:

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

Post by Peter112 »

add to the domoticz wiki pages ?
RaspberryPI domoticz, test server Intel Atom 230 dual core @1,6 GhzW7-32bit domoticz Test,RFXtrx433 USB, Kaku ,OWL
Marbaf
Posts: 9
Joined: Saturday 22 February 2014 16:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by Marbaf »

Yes, I do not know if it's done, but I agree with last request, add this excellent post to wiki !
User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

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

Post 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
Quality outlives Quantity!
Larsja
Posts: 37
Joined: Monday 25 January 2016 21:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2.3530
Location: Bergen, Norway
Contact:

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

Post 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.
walberg
Posts: 46
Joined: Thursday 28 May 2015 18:41
Target OS: NAS (Synology & others)
Domoticz version: 3.5877
Location: Diemen Netherlands
Contact:

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

Post by walberg »

how can i copy domoticz.db from de SD cart to my Mac?

(there is no web interface anymore)
tweet
Posts: 1
Joined: Wednesday 10 January 2018 17:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by tweet »

tnx!
User avatar
McMelloW
Posts: 427
Joined: Monday 20 November 2017 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.1
Location: Harderwijk, NL
Contact:

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

Post 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
Greetings McMelloW
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest