I am taking the backup of SQLite DB using cp command after running wal_checkpoint(FULL). The DB is being used in WAL mode so there are other files like -shm and -wal in my folder. When I run wal_checkpoint(FULL), the changes in WAL file get committed to the database. I was wondering whether -wal and -shm files get deleted after running a checkpoint. If not, then what do they contain ?
I know my backup process is not good since I am not using SQLite backup APIs. This is a bug in my code.
After searching through numerous sources, I believe the following to be true:
-shmfile contains an index to the-walfile. The-shmfile improves performance when reading the-walfile.-shmfile gets deleted, it get created again during next database access.checkpointis run, the-walfile can be deleted.To perform safe backups:
-shmand-walfiles. A backup can then be made usingcp,scpetc.checkpoint. This removes the fragmentation in the database file thereby reducing its size, so you transfer less data through network.