Skip to content

Commit

Permalink
backup.sh should gzip the archive, and not use sudo.
Browse files Browse the repository at this point in the history
  • Loading branch information
lemon24 committed Aug 3, 2024
1 parent 36eab7d commit a2f3496
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash
#
# back up a SQLite database not owned by the current user
# back up a SQLite database
#
# usage:
# backup.sh src dst
# backup.sh src
# ./backup.sh src dst
# ./backup.sh src
#
# example:
# "backup.sh /src/db.sqlite" -> ./db.sqlite.2023-01-28
# "./backup.sh /src/db.sqlite" -> ./db.sqlite.2023-01-28.gz
#

set -o nounset
Expand All @@ -29,5 +29,8 @@ trap 'rm -rf '"$tmpdir" EXIT

tmp=$tmpdir/$( basename "$src" )

time sudo sqlite3 "$src" "VACUUM INTO '$tmp'"
time cp "$tmp" "$dst"
du -sh "$src"
sqlite3 "$src" "VACUUM INTO '$tmp'"
du -sh "$tmp"
gzip -c "$tmp" > "$dst.gz"
du -sh "$dst.gz"

0 comments on commit a2f3496

Please sign in to comment.