def generate_file(): """ Copied from the library: package dbbackup and module dbbackup/management/commands/dbbackup.py TODO: either rewrite it, or suffer the consequences :D. """ return get_connector('default').generate_filename()
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 setUp(self): self.command = DbbackupCommand() self.command.database = TEST_DATABASE['NAME'] self.command.storage = FakeStorage() self.command.stdout = DEV_NULL self.command.filename = None self.command.path = None self.command.connector = get_connector('default')
def setUp(self): self.command = DbbackupCommand() self.command.servername = 'foo-server' self.command.encrypt = False self.command.compress = False self.command.storage = get_storage() self.command.stdout = DEV_NULL self.command.filename = None self.command.path = None self.command.connector = get_connector('default')
def setUp(self): self.command = DbbackupCommand() self.command.servername = 'foo-server' self.command.encrypt = False self.command.compress = False self.command.storage = FakeStorage() self.command.stdout = DEV_NULL self.command.filename = None self.command.path = None self.command.connector = get_connector('default')
def setUp(self): self.command = DbbackupCommand() self.command.servername = 'foo-server' self.command.encrypt = False self.command.compress = False self.command.database = TEST_DATABASE['NAME'] self.command.storage = get_storage() self.command.connector = get_connector() self.command.stdout = DEV_NULL self.command.filename = None self.command.path = None
def setUp(self): self.command = DbbackupCommand() self.command.servername = 'foo-server' self.command.encrypt = False self.command.compress = False self.command.database = TEST_DATABASE['NAME'] self.command.storage = FakeStorage() self.command.connector = get_connector() self.command.stdout = DEV_NULL self.command.filename = None self.command.path = None
def setUp(self): self.command = DbrestoreCommand() self.command.stdout = DEV_NULL self.command.uncompress = False self.command.decrypt = False self.command.backup_extension = 'bak' self.command.filename = 'foofile' self.command.database = TEST_DATABASE self.command.passphrase = None self.command.interactive = True self.command.storage = FakeStorage() self.command.connector = get_connector() HANDLED_FILES.clean()
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
def get_dump_name(database=None): database = database or TEST_DATABASE return get_connector().generate_filename()
def test_get_connector(self): connector = get_connector() self.assertIsInstance(connector, BaseDBConnector)
def get_dump(database=TEST_DATABASE): return get_connector().create_dump()
def get_dump_name(database=TEST_DATABASE): return get_connector().generate_filename()