18 lines
779 B
Python
18 lines
779 B
Python
from django.core.management.base import BaseCommand, CommandError
|
|
|
|
from statuslog.backup import BackupError, run_verify
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = 'آخرین بکاپ را روی دیتابیسِ آزمایشیِ جدا بازیابی و شمارشِ جدولهای پرداخت/ورود را میسنجد.'
|
|
|
|
def add_arguments(self, parser):
|
|
parser.add_argument('--file', default='', help='نامِ یک فایلِ مشخص در پوشهی بکاپ (پیشفرض: آخرین).')
|
|
|
|
def handle(self, *args, **opts):
|
|
try:
|
|
r = run_verify(opts['file'])
|
|
except BackupError as exc:
|
|
raise CommandError(str(exc))
|
|
self.stdout.write(f"بازیابی از {r['file']} سالم بود: {r['counts']}")
|