How do I dump an SQLite database?

June 5, 2017 603 views
Backups Ubuntu 16.04

Hi there,

How would I go about dumping an sqlite database on Ubuntu 16.04?

I am using an sqlite database within TeamSpeak 3 but do not know the commands to dump the sqlite database.

Any help would be appreciated.

2 Answers

@alexeps2014

The easiest way would be to use .dump, for example:

sqlite3 dbname.db .dump > dbname.bak

You can either cd in to the directory where the database is, or call the direct path during execution.

For example, if your database is located at:

/home/sqlite/teamspeak3.db

and you wanted to backup the database to

/usr/local/src/teamspeak3.bak

you'd use:

sqlite3 /home/sqlite/teamspeak3.db .dump > /usr/local/src/teamspeak3.bak
  • Hi there,

    Thanks for responding.

    I attempted your method, however it unfortunately failed.

    I typed:

    sqlite3 /home/teamspeak/ts3server.sqlitedb .dump > /usr/local/src/teamspeak3.bak
    

    However, the droplet responded:

    "The program 'sqlite3' is currently not installed. You can install it by typing: apt install sqlite3"
    

    I cannot execute this command as networking is currently disabled on my droplet as I have recently become victim to a DDoS attack, thus the reason of me wanting to dump/backup the sqlite database in the first place.

    What would be the next step?

    • @alexeps2014

      If you're running an older version, it may just be sqlite instead of sqlite3.

      If neither work, then you'll need to install sqlite3 by running:

      apt-get -y install sqlite3
      

      Once installed, you'll be able to run the command I provided in my previous response.

Have another answer? Share your knowledge.