System corrupted again - not FreePBX's fault - I can recover some of the files

(D E) #1

My installation (running on a Raspberry Pi) is corrupt again. I think it’s the fault of an SD card that I thought was of a good quality but clearly isn’t.

Anyway I can access the file structure by plugging the SD card into another Linux box.

Is there any way I can transplant FreePBX folders (including the db) onto a working OS and save myself the hours of work of updating all the modules and fighting with the file signatures?


(Jared Busch) #2

You should have been using the built in backup module to make backups. If not, then no, there is not easy way to deal with it.

Stop wasting time (time=$) with a RaspberryPi and just put it on Vultr on Digital Ocean for $5/month.


@dan_ce , there are basically three (maybe four :slight_smile: ) databases/locations that contain what you need,

A) Voicemail and recordings , are all in /var/spool/asterisk/* and /etc/asterisk/voicemail.conf

B) The current state of the machine , CF’s DND’s etc in /var/lib/asterisk/astdb-sqlite3

C) Most of the rest in the mysql/mariadb databases ‘asterisk’ and ‘asteriskcdrdb’

D) any customization you did in /etc/asterisk/*.conf , sorry you are on your own here :wink:

If you can reconstruct exactly what you had when it broke, then with asterisk and mysql stopped, you quite likely could restore the asterisk’s sqlite3 database and the /var/lib/mysql/asterisk* directory structures to the new machine if they are ‘un-corrupted’. If needed, repairing the mysql databases is usually quite easy. A broken sqlite3 data base is best recovered by just deleting it and letting Asterisk rebuild it, that sometimes needs a little attention to each ‘endpoint’ to re-sync it’s state with FreePBX’s database view which can’t do the CF/DND kinda stuff cos it’s dynamic.

As to wasting your time, I offer a counter argument,

Raspberry Pi 4 estimated cost of power per month is 30cents
Cost of 2G pI4 with case and psu plus SD approx $70
Learning how to not write logs to the SD = $0 + 20 minutes.

Break-even point Hardware vs. a VM with backups , about 1 year.

Residual value after that year, Vultr/DO = $0, PI hardware invested in including knowledge gained = $70 * 0.9 (ok, add depreciation :wink: ) + lots .

QED , You are neither wasting time nor money, you are gaining lots of ‘value added’ stuff. Many folks (myself included) have PI 2’s running for years under sinks and in broom closets without a problem,. almost all failures are either writing logs to the SD , so don’t, or losing power unexpectedly, a $15 usb power bank makes a very effective UPS for PI’s for that one.

Of course ‘off hardware’ backups are highly recommended also.


How dead is the SD card. If it’s just gone read only, it may be possible to do an image backup and restore to another SD card or USB drive.


In the past I have first off dd’ed the card into a file the long way then loop mount it , rsync it and fsck the resultant structure(s) all the usual recovery things are avaiable, even in a well constructed chroot, remembering its got arm binaries., But that’s another story and those 3/4 locations are usually recoverable, the cdr’s and logs being most likely broke, but who needs them anyway?

Logging to /dev/shm with an aggressive logrotate schema, no cdr/cel records and any recording off site with a local cache and likely your sd will be fine for years as almost nothing gets written but voicemails the v0.9+ fail2ban sqlite3 tableand the occasional ‘add/move/change’


(system) closed #6

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.