def test_mysql_backup(self, remove, open, command_executor): database = MySQL("Some database") database.database = "test_database" database.username = "******" database.password = "******" database.destination = "/file/path.sql" self.assertFalse(open.called) database.backup() self.assertTrue(open.called) self.assertFalse(remove.called) database.cleanup() self.assertTrue(remove.called)
def test_mysql_backup(self, remove, open, command_executor): database = MySQL("Some database") database.database = "test_database" database.username = "******" database.password = "******" database.destination = "/file/path.sql" self.assertFalse(open.called) database.backup() self.assertTrue(open.called) self.assertFalse(remove.called) database.cleanup() self.assertTrue(remove.called)
from paranoik.compress.tar import TarCompressor from paranoik.storage.s3 import S3 backup_time = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") BACKUP_DIR = os.path.join("/root", "backup", backup_time) os.mkdir(BACKUP_DIR) # Backup MySQL database_file = os.path.join(BACKUP_DIR, "mysql_database.sql") database = MySQL("Redmine database") database.database = "redmine" database.username = "******" database.password = "" database.destination = database_file # All of the above could be represented as arguments of the function: # database.backup(database, username, password, destination). I think # it will be more short and comfortable. database.backup() # Backup directories srv_backup = os.path.join(BACKUP_DIR, "redmine") srv_redmine = Directory("Redmine source") srv_redmine.path = "/srv/redmine" srv_redmine.destination = srv_backup srv_redmine.backup() # Compress the whole backup tar_file_name = "{0}.tar.gz".format(backup_time) tar_file_path = os.path.join("/root", "backup", tar_file_name)
from paranoik.compress.tar import TarCompressor from paranoik.storage.s3 import S3 backup_time = datetime.datetime.now().strftime("%Y%m%d_%H%M%S") BACKUP_DIR = os.path.join("/root", "backup", backup_time) os.mkdir(BACKUP_DIR) # Backup MySQL database_file = os.path.join(BACKUP_DIR, "mysql_database.sql") database = MySQL("Redmine database") database.database = "redmine" database.username = "******" database.password = "" database.destination = database_file database.backup() # Backup directories srv_backup = os.path.join(BACKUP_DIR, "redmine") srv_redmine = Directory("Redmine source") srv_redmine.path = "/srv/redmine" srv_redmine.destination = srv_backup srv_redmine.backup() # Compress the whole backup tar_file_name = "{0}.tar.gz".format(backup_time) tar_file_path = os.path.join("/root", "backup", tar_file_name) tar = TarCompressor(tar_file_path) tar.add(BACKUP_DIR)