sqliteHow do I create a backup of my SQLite database?
Creating a backup of your SQLite database is a simple process.
- First, open a terminal window and navigate to the directory where your database is located.
- Then, use the
.backup
command followed by the name of the backup file and the name of the database you wish to back up.
sqlite> .backup my_backup.db my_database.db
- This will create a backup of the database in the same directory, with the name you specified.
- You can also specify a path for the backup file, if you wish to save it in a different directory.
sqlite> .backup /home/user/my_backup.db my_database.db
- If the backup was successful, you should see the following message:
Backup completed in 0.063 seconds
- You can also use the
.dump
command to back up your database. This command will create a SQL script of your database, which can be used to re-create the database.
sqlite> .dump > my_backup.sql
- To restore the database from the backup, you can use the
.read
command.
sqlite> .read my_backup.sql
Helpful links
More of Sqlite
- How do I list all tables in a SQLite database?
- How do I use SQLite to zip a file?
- How do I create a book database using SQLite?
- How do I use SQLite with Zephyr?
- How do I retrieve the last insert ID in SQLite?
- How can I use SQLite with Laravel?
- How can I use SQLite with Github?
- How do I use the SQLite CONCAT function?
- How can I get the year from a date in SQLite?
- How do I truncate a table in SQLite?
See more codes...