Back to commands

Hosting Operations

Changes system state

Back Up a SQLite Database File

You need to create a SQLite backup through sqlite3 instead of a raw file copy.

Command

sqlite3 app.db ".backup backup/app.db"

Before you run this

System impact: Changes system or application state. Needs inspection, scoping, and rollback notes before production use.

When not to use it: Do not use it as your only production backup plan; automate and verify backups separately.

Expected output

The sqlite3 backup command is quiet on success; verify with ls afterward.

System impact

Changes system state. SQLite writes a backup copy to backup/app.db.

When to use it

Use before risky data work, migrations, or manual inspection on a SQLite-backed app.

When not to use it

Do not use it as your only production backup plan; automate and verify backups separately.

Recovery / rollback

Remove the backup file with rm backup/app.db if it was created only for a temporary check.

Watch this command run

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

demo@lab:~$

$ ls -lh app.db

-rw-r--r-- 1 root root 16 Jun 26 00:27 app.db

$ sqlite3 app.db ".backup backup/app.db"

$ ls -lh backup/app.db

-rw-r--r-- 1 root root 16 Jun 26 00:27 backup/app.db
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. ls -lh app.db
  2. sqlite3 app.db ".backup backup/app.db"
  3. ls -lh backup/app.db

next steps

Related commands

Hosting Operations Read-only

Check SQLite Database Integrity

When a SQLite-backed app behaves strangely, first rule out file corruption.

sqlite3 app.db "PRAGMA integrity_check;"
Hosting Operations Read-only

Count Rows in Key SQLite Tables

A quick row count can reveal empty imports, runaway events, or missing data.

sqlite3 app.db "SELECT 'users', count(*) FROM users UNION ALL SELECT 'orders', count(*) FROM orders UNION ALL SELECT 'events', count(*) FROM events;"
Hosting Operations Read-only

List SQLite User Tables Only

System metadata tables can distract from the app tables you care about.

sqlite3 app.db "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
Hosting Operations Read-only

Show Recent SQLite Events

For small apps, the quickest timeline may be inside the SQLite file.

sqlite3 app.db "SELECT created_at, event_type FROM events ORDER BY created_at DESC LIMIT 5;"
Hosting Operations Read-only

Show One SQLite Table Schema

A failed query is often just a wrong assumption about column names.

sqlite3 app.db ".schema users"
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lfcs:operations-deployment
  • lfcs:services-logs
  • linuxplus:provisional
  • linuxplus:troubleshooting
  • risk:production-state-change

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.