@@ -0,0 +1,1203 @@
+package com.dianping.cat.report.task.config;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.util.List;%0A%0Aimport org.unidal.dal.jdbc.DalException;%0Aimport org.unidal.eunit.helper.Files;%0Aimport org.unidal.lookup.annotation.Inject;%0A%0Aimport com.dianping.cat.core.config.Config;%0Aimport com.dianping.cat.core.config.ConfigDao;%0Aimport com.dianping.cat.core.config.ConfigEntity;%0A%0Apublic class ConfigBackupTask %7B%0A%09@Inject%0A%09private ConfigDao m_dao;%0A%0A%09private static final String BASE_DIR_PATH = %22src/main/resources/config/backup/%22;%0A%0A%09private boolean backupConfig(String name, String context) %7B%0A%09%09String filePath = BASE_DIR_PATH + name + %22.xml%22;%0A%09%09File backupFile = new File(filePath);%0A%0A%09%09try %7B%0A%09%09%09Files.forIO().writeTo(backupFile, context);%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%09return true;%0A%09%7D%0A%0A%09public boolean backupConfigs() %7B%0A%09%09boolean result = true;%0A%0A%09%09try %7B%0A%09%09%09List%3CConfig%3E configs = m_dao.findAllConfig(ConfigEntity.READSET_FULL);%0A%0A%09%09%09for (Config config : configs) %7B%0A%09%09%09%09boolean tmpResult = backupConfig(config.getName(), config.getContent());%0A%0A%09%09%09%09if (!tmpResult && result) %7B%0A%09%09%09%09%09result = false;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D catch (DalException e) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%09return result;%0A%09%7D%0A%7D

add config backup task