You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
707 B
19 lines
707 B
from django.core.management.base import BaseCommand, CommandError |
|
|
|
from core.backup import BackupError, create_backup |
|
|
|
|
|
class Command(BaseCommand): |
|
help = "Create a local PostgreSQL backup and checksum manifest." |
|
|
|
def add_arguments(self, parser): |
|
parser.add_argument("--output", dest="output") |
|
|
|
def handle(self, *args, **options): |
|
try: |
|
result = create_backup(options["output"]) |
|
except BackupError as error: |
|
raise CommandError(error.code) from None |
|
self.stdout.write(f"backup={result.name} format={result.version}") |
|
for table, count in sorted(result.row_counts.items()): |
|
self.stdout.write(f"table={table} rows={count}")
|
|
|