Browse Source

Add script and readme

master
Alex Williams 1 year ago
parent
commit
c29821ff62
Signed by: aw GPG Key ID: 19EE4AAA361A7E2C
2 changed files with 55 additions and 0 deletions
  1. +22
    -0
      README.md
  2. +33
    -0
      scorch-to-sqlite.sh

+ 22
- 0
README.md View File

@ -0,0 +1,22 @@
# Script to convert a Scorch DB (CSV) to SQLite
Get [Scorch here](https://github.com/trapexit/scorch)
# Usage
```
./scorch-to-sqlite.sh /path/to/scorch.db
```
Outputs `/path/to/scorch.db.sqlite`
# Requirements
* gzip
* sqlite3
# License
[MIT License](LICENSE)
Copyright (c) 2020 Alexander Williams, Unscramble <license@unscramble.jp>

+ 33
- 0
scorch-to-sqlite.sh View File

@ -0,0 +1,33 @@
#!/bin/sh
#
# Script to convert a Scorch DB to SQLite
# Scorch: https://github.com/trapexit/scorch
#
# Usage: ./scorch-to-sqlite.sh /path/to/scorch.db
# Outputs /path/to/scorch.db.sqlite
#
# The MIT License (MIT)
# https://github.com/aw/scorch-to-sqlite
#
# Copyright (c) 2020 Alexander Williams, Unscramble <license@unscramble.jp>
set -u
set -e
scorch_csv="$(mktemp)"
scorch_db="$1"
scorch_sql="${scorch_db}.sqlite"
cleanup() {
rm -f "$scorch_csv"
}
trap cleanup EXIT
echo 'file,hash,size,mode,mtime,inode' > "$scorch_csv"
echo "Decompressing DB: $scorch_db"
gzip -d -k -c "$scorch_db" >> "$scorch_csv"
echo "Importing DB into SQLite: $scorch_sql"
sqlite3 -csv "$scorch_sql" ".import $scorch_csv scorch"

Loading…
Cancel
Save