コード例 #1
0
                file = Common.join_paths(dst_dir, x)
                Common.remove(file)


def backup_with_config(config_path):
    content = Common.read_file(config_path)
    arr = Common.str2json(content)
    if arr:
        for x in arr:
            backup(x.get('src'),
                   x.get('dst_dir'),
                   x.get('retemtion_days'),
                   hours_last_day=x.get('hours_last_day'),
                   ignore_hours=x.get('ignore_hours'))


if __name__ == '__main__':
    Common.set_debug(True)

    config_path = Common.join_paths(Common.get_cmd_dir(), '..', 'tests',
                                    'backup_test.json')
    config_path = Common.abs_path(config_path)
    if Common.debug():
        for day in range(0, 18):
            for hour in range(0, 24):
                path = '/tmp/backup/backup_test_201902%02d%02d.json' % (
                    25 - day, hour)
                Common.replace_file(config_path, path)

    backup_with_config(config_path)
コード例 #2
0
 def backup(self):
     Common.replace_file(self._dbPath, self._dbPath + '.bak')