Skip to content

Commit

Permalink
created bak-db task to create backup of db
Browse files Browse the repository at this point in the history
  • Loading branch information
fullerzz committed Aug 16, 2024
1 parent 30c5b79 commit 1e160be
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sqlite3
from datetime import datetime
from zoneinfo import ZoneInfo

from invoke.context import Context
from invoke.tasks import task
Expand All @@ -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)

0 comments on commit 1e160be

Please sign in to comment.