Working save/restore functionality for DB