mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
Upgrading exports (#283)
* Upgrading export capabilities * Only apply sqlite hacks for sqlite This fixes #250, #246 Adds export.py to save CTFs without needing to actually spin up CTFd Also forcing charset properly for MySQL
This commit is contained in:
23
export.py
Normal file
23
export.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from CTFd import create_app
|
||||
from CTFd.utils import ctf_name, export_ctf
|
||||
|
||||
import datetime
|
||||
import sys
|
||||
import shutil
|
||||
import zipfile
|
||||
|
||||
|
||||
app = create_app()
|
||||
with app.app_context():
|
||||
backup = export_ctf()
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
with open(sys.argv[1], 'wb') as target:
|
||||
shutil.copyfileobj(backup, target)
|
||||
else:
|
||||
ctf_name = ctf_name()
|
||||
day = datetime.datetime.now().strftime("%Y-%m-%d")
|
||||
full_name = "{}.{}.zip".format(ctf_name, day)
|
||||
|
||||
with open(full_name, 'wb') as target:
|
||||
shutil.copyfileobj(backup, target)
|
||||
Reference in New Issue
Block a user