def backup_database(database_name): connector = get_connector('default') filename = connector.generate_filename() outputfile = connector.create_dump() compressed_file, filename = utils.compress_file(outputfile, filename) outputfile = compressed_file outputfile.seek(0) return outputfile, filename
def test_uncompress(self, *args): self.command.path = None compressed_file, self.command.filename = utils.compress_file(get_dump(), get_dump_name()) HANDLED_FILES['written_files'].append( (self.command.filename, compressed_file) ) self.command.uncompress = True self.command._restore_backup()
def test_uncompress(self, *args): self.command.path = None compressed_file, self.command.filename = utils.compress_file( get_dump(), get_dump_name()) HANDLED_FILES['written_files'].append( (self.command.filename, compressed_file)) self.command.uncompress = True self.command._restore_backup()
def backup(self, request, pk=None): connector = get_connector('default') filename = connector.generate_filename() outputfile = connector.create_dump() compressed_file, filename = utils.compress_file(outputfile, filename) outputfile = compressed_file outputfile.seek(0) response = HttpResponse( outputfile.read(), content_type="application/x-gzip" ) response['Content-Disposition'] = f'attachment; filename={filename}' response['X-Sendfile'] = smart_str(outputfile.read()) return response