summary refs log tree commit diff
path: root/database.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-01-14 18:25:52 -0500
committerJune McEnroe <june@causal.agency>2020-01-14 18:25:52 -0500
commit699a8c625cdf1f9a57bf4be326dc0c797c2d4d63 (patch)
tree590c05c0bd8dac0addf1c89974ad3dac2af37ab9 /database.h
parentAdd columnsize = 0 option to FTS index (diff)
downloadlitterbox-699a8c625cdf1f9a57bf4be326dc0c797c2d4d63.tar.gz
litterbox-699a8c625cdf1f9a57bf4be326dc0c797c2d4d63.zip
Add -b flag for live backup
Diffstat (limited to 'database.h')
-rw-r--r--database.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/database.h b/database.h
index 83be73c..d9b2718 100644
--- a/database.h
+++ b/database.h
@@ -335,3 +335,13 @@ static inline void dbMigrate(void) {
 		dbExec(MigrationSQL[version]);
 	}
 }
+
+static inline void dbBackup(const char *path) {
+	if (sqlite3_libversion_number() < 3027000) {
+		errx(EX_CONFIG, "SQLite version 3.27.0 or newer required");
+	}
+	sqlite3_stmt *stmt = dbPrepare(SQL(VACUUM INTO :path;));
+	dbBindText(stmt, ":path", path);
+	dbRun(stmt);
+	sqlite3_finalize(stmt);
+}