From 1e160bea3ab7940f92befaebbd9933cf5b30864b Mon Sep 17 00:00:00 2001 From: Zach Fuller Date: Thu, 15 Aug 2024 18:06:03 -0700 Subject: [PATCH] created bak-db task to create backup of db --- tasks.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tasks.py b/tasks.py index 1f857c0..a4f8fff 100644 --- a/tasks.py +++ b/tasks.py @@ -1,4 +1,6 @@ import sqlite3 +from datetime import datetime +from zoneinfo import ZoneInfo from invoke.context import Context from invoke.tasks import task @@ -22,3 +24,9 @@ def show_table(c: Context) -> None: cursor.execute("SELECT * FROM filemetadatarecord") print(cursor.fetchall()) conn.close() + + +@task +def bak_db(c: Context) -> None: + timestamp = datetime.now(ZoneInfo("UTC")).strftime("%Y-%m-%d_%H:%M:%S") + c.run(f"cp file_metadata.db file_metadata_{timestamp}.bak.db", echo=True)