There are a couple of ways to back up your SQLite database. To make it portable, use the .dump
statement as part of the CLP, which can export the entire database and scripts to the filesystem. An example can be seen as follows:
The preceding statement shows how to invoke SQLite with a database name and pipe the output to a file called temp.sql
.
Following is another way to invoke SQLite and then perform a backup interactively.
User can directly import the data, by the following set of commands:
The following command will open SQLite and the temp.db
database, and import the temp.sql
file to it. Within the temp.sql
file, there will be scripts to read the source files and import data back to database (existing or new version):
There is another way, just copy the temp.db
file to a version called temp.backup
, but the aforementioned methods are much better and portable, and there may be binary compatibility issues since SQLite does not have a great reputation for backward compatibility.