Step by step guide to restore a backup or database to a Pi
Posted: Monday 02 December 2013 1:21
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.
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.