next.js frontend w/ mongodb local backend
This commit is contained in:
parent
e24e17e42b
commit
f333d9ba00
18 changed files with 3144 additions and 337 deletions
17
db_scripts/backup_mongo.py
Normal file
17
db_scripts/backup_mongo.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import os
|
||||
from datetime import datetime
|
||||
|
||||
# Define the database name and backup directory
|
||||
db_name = "flask_db"
|
||||
|
||||
# Example: export BACKUP_DIR="/Users/<myname>/Codes/pyxr_db_backup"
|
||||
backup_dir = os.getenv('BACKUP_DIR', '/default/backup/path') # Use environment variable
|
||||
|
||||
# Create a timestamped backup file name
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
backup_file = os.path.join(backup_dir, f"{db_name}_backup_{timestamp}.gz")
|
||||
|
||||
# Run the mongodump command to back up the database
|
||||
os.system(f"mongodump --db {db_name} --archive={backup_file} --gzip")
|
||||
|
||||
print(f"Backup completed: {backup_file}")
|
||||
Loading…
Add table
Reference in a new issue