Esempio n. 1
0
 def testRunDuplicity(self, mock_runCmd):
     backupService = Backup()
     backupService.runDuplicity(
         '/backup', 'ftp://*****:*****@my-server.com/backup/dump', '1D', 7, 1,
         1000)
     mock_runCmd.assert_any_call(
         mock.ANY,
         'duplicity  --volsize 1000 --no-encryption --allow-source-mismatch --full-if-older-than 1D /backup ftp://user:[email protected]/backup/dump'
     )
     mock_runCmd.assert_any_call(
         mock.ANY,
         'duplicity remove-all-but-n-full 7 --force --allow-source-mismatch --no-encryption ftp://user:[email protected]/backup/dump'
     )
     mock_runCmd.assert_any_call(
         mock.ANY,
         'duplicity remove-all-inc-of-but-n-full 1 --force --allow-source-mismatch --no-encryption ftp://user:[email protected]/backup/dump'
     )
     mock_runCmd.assert_any_call(
         mock.ANY,
         'duplicity  cleanup --force --no-encryption ftp://user:[email protected]/backup/dump'
     )
Esempio n. 2
0
                    settings['duplicity']['source-path'] + '/rancher',
                    listStacks)
                logger.info("The exporting of stack if finished")

            # We dump the rancher database if needed
            if settings['module']['rancher-db'] is True:
                logger.info("Start to dump Rancher database...")
                backupService.dumpRancherDatabase(
                    settings['duplicity']['source-path'] + '/rancher',
                    rancherDatabaseSettings)
                logger.info("The Rancher database dumping is finished.")

            # We run the backup
            if os.getenv("BACKUP_DUPLICITY_enable") == "true":
                logger.info(
                    "Start to externalize the backup with Duplicity...")
                backupService.runDuplicity(
                    settings['duplicity']['source-path'], backend,
                    settings['duplicity']['full-if-older-than'],
                    settings['duplicity']['remove-all-but-n-full'],
                    settings['duplicity']['remove-all-inc-of-but-n-full'],
                    settings['duplicity']['volsize'],
                    settings['duplicity']['options'],
                    settings['duplicity']['encrypt-key'])
                logger.info("The backup exporing is finished.")

        except Exception as e:
            logger.error("Unattented error occur : %s", e.message)
            logger.error(traceback.format_exc())
            sys.exit(1)
Esempio n. 3
0
        try:
            backupService.initDuplicity(BACKUP_PATH, backend)
        except Exception as e:
            logger.info(
                "No backup found (probably the first) or already initialized")
            pass

        # We dump the container if needed
        # Get all services (potential dump)
        if DISABLE_DUMP != "true":
            listServices = rancherService.getServices()
            listDump = backupService.searchDump(BACKUP_PATH, listServices,
                                                listSettings)
            backupService.runDump(listDump)

        # We dump the rancher settings
        if DISABLE_DUMP_RANCHER != "true":
            listStacks = rancherService.getStacks()
            backupService.dumpStacksSettings(BACKUP_PATH + '/rancher',
                                             listStacks)

        # We run the backup
        backupService.runDuplicity(BACKUP_PATH, backend, BK_FULL_FREQ,
                                   BK_KEEP_FULL, BK_KEEP_FULL_CHAIN,
                                   VOLUME_SIZE)

    except Exception as e:
        logger.error("Unattented error occur : %s", e.message)
        logger.error(traceback.format_exc())
        sys.exit(1)