work on #2315: preserve corrupted database on SD storage

Also, switch the DB to internal storage if we could not use external one.
Merge branch 'release' into upstream