OH + RPi2 - Move everything away from SD Card

I have acron job that backs up my pi to nas

cron:
0 13 * * * /home/pi/backupPi.sh

… and if you need incremental backups with rsync instead full backups with dd, you could use:

https://www.linux-tips-and-tricks.de/en/backup

This is one of the setups I’ve also tried in the past. My experience was that indeed it works… but for me it was less stable that the alternative approach of having the files on my synology via NFS.
The main difference is that when e.g.updates are done, it seems the iscsi has more chance on corruptions than the NFS approach.

Interesting… I wonder how that works - is it the actual files within the iscsi target that got corrupted or the actual iscsi disk? I need to get down to testing the snapshot and backup functionalities of the Qnap iscsi in order to have a tested plan for recovery when things go wrong

It’s been some time ago that I’ve than this, but I recall it is a disk corruption. As specifically when the NAS has reboots/unexpected powerdowns, As the iscsi is a block device to the user, the filesystem on it gets corrupted.
In the NFS, which is a file bases system, worse that can happen is that the open file closes.

there are some nice articles if you google for nfs vs iscsi
e.g. https://www.usenix.org/legacy/events/fast04/tech/full_papers/radkov/radkov_html/node5.html

Observe that the benefits of asynchronous meta-data update in iSCSI come at the cost of lower reliability of data and meta-data persistence than in NFS. Due to synchronous meta-data updates in NFS, both data and meta-data updates persist across client failure. However, in iSCSI, meta-data updates as well as related data may be lost in case client fails prior to flushing the journal and data blocks to the iSCSI server.

Add a smartphone power bank as UPS. Simple, cheap and sufficient. It avoids the need for OH restarts every time you or someone else hit the breakers or earth (ground) cable. I stopped counting how often that happened in my house over the last year.

Moving away everything from SD card is possible but don’t focus on that, it has drawbacks, too, and even if done properly, it’s not sufficient.
What’s much more important is a plan for quick recovery. See my recent post here and also this old one.

Yes, I did this already.

Could you advise some smartphone backup battery that has an ups behavior mine doesn’t assure power continuity when the main supply cut.

I used pretty simple USB power bank, which I even got for free as a present while visiting some exhibition. It has a logo of that company, so I have no idea who is original manufacturer. It has a micro-USB and USB ports.

Same for me ! So the advice would probably be to embark on a fair, go collect some gifts :slight_smile:

ok thanks for the advices

I tried to move /var/logs to USB as a first step, but somehow failed. Does anyone have working instruction how to do it correctly?

@Artyom_Syomushkin how is it going? I want to start openHAB / openHABian on a Raspberry Pi 3. The third Pi can be run w/o a SD-Card and the older models (except the first with full SD Card) just need the file “bootcode.bin” on the internal SD-Card [1]. I am running dnsmasq on a Pi 1 and NFS on my other Debian Server. I want to use my new Pi diskless with openHABian - I hope this combination will not interfere.

[1] https://www.raspberrypi.org/blog/pi-3-booting-part-ii-ethernet-all-the-awesome/

I might be wrong here, but i think the openhabianpi isn’t just an image, but also a (separate) set of scripts to manage the installation - including moving the root partition to an USB device:

@chris400 since I didn’t want to start from new installation, I simply followed couple of first instructions, disabled swap file and created tmpfs for logs. I adjusted logback.xml to keep only 10 days of records maximum_ so that it fits into RAM. The only one log - events is backup to my NAS every weekend.
Finally I see that SD card is not used so often anymore, so I guess it should survive relatively long.

1 Like

Would you please share the guide.
I would like to go the same route…

Hello thread!
I’m writing here to say that i had a weird sd failure even if the raspberry pi v3 was powered by a battery pack. I flashed the sd more than one year ago. During this period some unwanted shutdown did occur anyway due to “human error”. I restored a backup (that is performed daily automatically on a synology) and now everything seems to work.
In my case the pi was losing ethernet connectivity and it was causing also the access point to hang. This made me suspect of an hardware failure first, but by using a different raspberry i ended up concluding that it was sds fault.
Whats strange is that i restored a backup taken after the first symptoms of ethernet hang showed up. If file was corrupted, the backup would simply copy it to the new sd.

This is a message in bottle for other users who may experience some trouble in the future.
Lionhe

@Lionello_Marrelli Hi Lionello,
I am folowing this thread because i would like to backup my openHAB system (SSD drive with Power bank) via nfs to my Synology NAS. (i still have to create a bu power solution for my network switches…)
I noticed that nfs on Synology does not work like the default nfs specs. They made their own additions to this. Til now, i haven’t got this working…
Tried several solutions like raspiBackup but no success…
If you are using nfs with your backup solution, could you please share your solution?
I would greatly appreciate it.
Kind regards, Bert

@deltabert Hi Bert,
I am using raspiBackup on a Synology NAS mounted via NFS (by editing the \etc\fstab).

  1. I had to play with NFS settings on the Synology (but I followed suggestions on a forum on Synology). NFS is essential as it allows mapping permissions and hard-links, considerably reducing the storage size of incremental backups.
  2. in the last versions raspiBackup is more strict in checking for errors. If an error occur the entire backup fails. I added these errors to the ignore list.

You have to solve the NFS issue first.
On the raspberry side I modified my /etc/fstab as follows

192.168.27.11:/volume2/backup /mnt/ds216 nfs rw,acl,vers=3,proto=tcp,hard,nolock,nofail,x-systemd.automount,x-systemd.requires=network-online.target 0 0

(if I rember well, vers=3 was important)

On the synology side, I followed instructions of the following link (it is in italian but you can easily find the english one).
In my case I opened the synology to my local network with
192.168.27.0/24

NFS can be painful to setup, ma once in place it works pretty well.

If you use openHABian, the recommendation is to use Amanda. It’s a preconfigured backup solution to come bundled with openHABian. Install it from the openhabian-config menu.
If you didn’t use the openHABian image, openHABian is also available as a set of scripts you could also install on top of an existing Raspbian.