Ejemplo n.º 1
0
        /// <summary>
        /// Restaura la copia de respaldo
        /// </summary>
        /// <returns></returns>
        public bool PerformRestore(string name)
        {
            try
            {
                string folder   = ConfigurationManager.AppSettings["BACKUP_PATH"];
                string fullPath = folder + "/" + name;

                BackupMapper backupMapper = new BackupMapper();
                log.AddLogInfo("PerformRestore", "Restaurando respaldo...", this);

                if (backupMapper.Restore(fullPath))
                {
                    log.AddLogInfo("PerformRestore", "El respaldo se ha restaurado exitosamente.", this);
                    return(true);
                }
                else
                {
                    log.AddLogInfo("PerformRestore", "No se ha podido restaurar el respaldo.", this);
                    return(false);
                }
            }
            catch (Exception exception)
            {
                log.AddLogCritical("PerformRestore", exception.Message, this);
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Genera la copia de respaldo
        /// </summary>
        /// <returns></returns>
        public bool PerformBackup()
        {
            try
            {
                string folder   = ConfigurationManager.AppSettings["BACKUP_PATH"];
                string fullPath = folder + "/" + DateTime.Now.Ticks + ".bkp";

                BackupMapper backupMapper = new BackupMapper();
                log.AddLogInfo("PerformBackup", "Creando respaldo...", this);

                if (backupMapper.Backup(fullPath))
                {
                    log.AddLogInfo("PerformBackup", "El respaldo se ha generado exitosamente.", this);
                    return(true);
                }
                else
                {
                    string errorDescription = "No se ha podido generar el respaldo.";
                    log.AddLogCritical("PerformBackup", errorDescription, this);
                    AddError(new ResultBE(ResultBE.Type.FAIL, errorDescription));
                    return(false);
                }
            }
            catch (Exception exception)
            {
                string errorDescription = exception.Message;
                log.AddLogCritical("PerformBackup", errorDescription, this);
                AddError(new ResultBE(ResultBE.Type.FAIL, errorDescription));
                return(false);
            }
        }
Ejemplo n.º 3
0
        public static bool RestaurarBackup(string nombreArchivo)
        {
            try
            {
                string rutaBackups        = ConfigurationManager.AppSettings.Get("ubicacionBackups");
                string rutaCompletaBackup = rutaBackups + nombreArchivo + ".bak";
                if (File.Exists(rutaCompletaBackup))
                {
                    BackupMapper.RestaurarBackup(rutaCompletaBackup);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Log.Log.Grabar(ex);
            }

            return(false);
        }
Ejemplo n.º 4
0
        public static bool HacerBackup(List <string> mensajesDeError)
        {
            // Primero debo chequear la integridad de la BD
            if (DigitoVerificador.VerificarIntegridad(mensajesDeError))
            {
                try
                {
                    string rutaBackup = ConfigurationManager.AppSettings.Get("ubicacionBackups");
                    Directory.CreateDirectory(rutaBackup); // Si la carpeta no existe, la crea

                    string nombreArchivo = DateTime.Now.ToString(DATE_FORMAT_FOR_FILE);
                    BackupMapper.HacerBackup(rutaBackup + nombreArchivo + ".bak");
                    return(true);
                }
                catch (Exception ex)
                {
                    Log.Log.Grabar(ex);
                }
            }

            mensajesDeError.Add("No se puede hacer un backup porque la base de datos no está íntegra.");
            return(false);
        }