Hosting Operations
Changes system stateBack 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.
$ 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
ls -lh app.dbsqlite3 app.db ".backup backup/app.db"ls -lh backup/app.db
next steps
Related commands
Check SQLite Database Integrity
When a SQLite-backed app behaves strangely, first rule out file corruption.
sqlite3 app.db "PRAGMA integrity_check;"
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;"
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;"
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;"
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.
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.