How should I backup SQLite database using EF Core?

34 Views Asked by At

Recently I am working hard on embedded device develop by .NET. Not only the program but also the database is stored in the SD card.

Now I have a situation.

Because my embedded device is used in a workshop, when there is an uncontrollable power outage in the workshop, or there are various possibilities such as wires falling off due to human movement, causing the equipment to suddenly lose power, the database may be damaged.

There was nothing I could do to avoid any of these actions that would cause a blackout. So I had to find a way to back up the database. When EF Core could not read the database, I used the backup to restore the database.

An immature idea I have is to create another identical database. Regularly back up the contents of the main database to this backup database. Although I know that there may be situations where both databases are damaged at the same time, it can at least reduce the probability of database damage to a certain extent.

I guess that whether it is EF Core or SQLite, there should be some ways to deal with the power outage that occurs during the database reading and writing process. Unfortunately, I really couldn't find a relevant solution, so I had to think of using two databases to avoid failures.

How should I backup SQLite database using EF Core?

0

There are 0 best solutions below