agentsclimarketplace

Sqlite fast migration skill

Skill AkatQuas/sqlite-fast-migration-skill

High-speed cross-machine SQLite database migration using dump + gzip compression + local rebuild. Replaces slow, fragile rsync for GB-sized databases.From its SKILL.md

Install
npx -y skills add AkatQuas/sqlite-fast-migration-skill

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

5.7 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

SQLite Fast Migration Skill

Replace rsync-based direct .db copy — use SQLite's built-in .dump, gzip compression, and local rebuild to migrate GB-sized SQLite databases across machines, solving slow transfer speeds and file corruption.

When to Use

Migrating, backing up, or copying large SQLite databases (hundreds of MB to GB) from a remote server to your local machine. Especially useful when:

  • The database has many indexes, making the .db file bloated with redundant data
  • The source database is being written to during transfer (risk of corruption)
  • You have limited bandwidth or a slow network connection
  • rsync reports database disk image is malformed or takes too long

For small databases (~250 MB or less), direct rsync is fine — no need for this approach.

Problem

The traditional approach — rsync copying the entire .db binary file — has two major flaws:

  1. Inefficient transfers — SQLite stores indexes to speed up queries, but indexes are just redundant copies of the data. A single index can account for 50% of the total disk space, wasting massive bandwidth during transfer.

  2. File corruption — Large databases take a long time to copy. During transfer, the live source database may be updated, causing rsync to read a mix of old and new data. The result is a corrupted file with database disk image is malformed.

Solution

Stop transferring raw .db binaries. Instead, use a three-phase approach: SQL dump + compressed transfer + local rebuild.

PhaseWhatWhy
Deduplicatesqlite3 .dump converts the binary DB to SQL textIndexes become single CREATE INDEX statements — no redundant index data transferred
Compressgzip the SQL textSQL text is highly repetitive, achieving excellent compression ratios
Static snapshotTransfer the fixed text fileThe dump is a point-in-time snapshot, immune to concurrent writes on the source
Rebuild locallysqlite3 executes the SQL scriptAuto-creates tables, inserts data, and rebuilds all indexes — identical to the source

Measured Results (3.4 GB production database)

FileDisk UsageNote
Original SQLite .db3.4 GBIncludes massive index redundancy
SQLite dump (plain text)1.3 GBBusiness data only, indexes reduced to CREATE statements
gzip compressed dump240 MB14× compression vs original

Procedure

The standard 6-step pipeline:

# ── 1. Remote: dump and compress ──
ssh username@server "sqlite3 my_remote_database.db .dump | gzip -c > my_remote_database.db.txt.gz"

# ── 2. Local: pull the compressed package ──
rsync --progress username@server:my_remote_database.db.txt.gz my_local_database.db.txt.gz

# ── 3. Clean up remote temp file ──
ssh username@server "rm my_remote_database.db.txt.gz"

# ── 4. Local: decompress ──
gunzip my_local_database.db.txt.gz

# ── 5. Local: rebuild database from SQL (auto creates tables, inserts data, builds indexes) ──
cat my_local_database.db.txt | sqlite3 my_local_database.db

# ── 6. Clean up local temp text file ──
rm my_local_database.db.txt

Quick one-liners

Dump + compress only (for later manual processing):

sqlite3 explorer.db .dump | gzip -c > explorer.db.txt.gz

Rebuild from local SQL text only:

cat my_local_database.db.txt | sqlite3 my_reconstructed_database.db

What NOT to do (anti-pattern)

# Don't do this — slow and fragile for large files
rsync --progress username@server:my_remote_database.db my_local_database.db

Pitfalls

  • Index redundancy is the main culprit — the dump approach reduces indexes to single-line CREATE INDEX statements, achieving up to 14× compression. Always dump first, don't copy the .db raw.
  • Dump is a static snapshot — it captures the database at a single point in time, immune to concurrent writes. This eliminates the version-mixing corruption that plagues rsync.
  • Locking under high concurrency — if the source database is under heavy write load, .dump may wait for a lock. Run during off-peak hours, or use .backup first and dump the backup.
  • Local rebuild has a cost — rebuilding indexes locally consumes CPU and disk I/O, but this is negligible compared to the time saved on network transfer.
  • Clean up temp files — always remove *.txt.gz and *.txt afterward to avoid cluttering server and local disk.
  • Zero dependencies — only needs sqlite3 CLI and standard compression tools (gzip/gunzip). No plugins, services, or frameworks required.

Verification

After migration, verify:

  1. Opening the local database produces no database disk image is malformed error
  2. Query the local database — row counts, table structure, and indexes match the remote source
  3. Overall migration time is significantly shorter than rsync with the raw .db file under the same network conditions
  4. No *.txt.gz or *.txt temp files remain on either server or local machine

References

License

MIT

What ships with it: 5 files

6.3 KB alongside SKILL.md

assets/

examples/

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.