SQLite Import, Export, and Backup Cheatsheet/Create a compact backup with VACUUM INTO

Write a fresh copy of the database to a new file.

Section: Backup and maintenance

Create a compact backup with VACUUM INTO

sql
sql
VACUUM INTO 'backup-2026-03-28.db';
Explanation

Produces a compact copy and is a strong option for backup-style snapshots.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Backup and maintenance
Use the shell backup command
Create a backup from inside sqlite3.
OpenIn sheettextsame section
Run VACUUM
Rebuild the database file and reclaim free space.
OpenIn sheetsqlsame section
Run an integrity check
Verify the database structure and content consistency.
OpenIn sheetsqlsame section
Load data from an SQL file
Execute inserts and DDL from a seed script.
OpenIn sheetbash1 tag match
Import CSV with mode and separator
Set shell parsing options before import.
Export a query result to CSV
Write selected rows to a CSV file.