Ejemplo n.º 1
0
        private void Backup()
        {
            var source = new DirectoryInfo(CommonHelper.MapPath("~/"));

            var    tempPath      = CommonHelper.MapPath("~/App_Data/_Backup/App/SmartStore");
            string localTempPath = null;

            for (int i = 0; i < 50; i++)
            {
                localTempPath = tempPath + (i == 0 ? "" : "." + i.ToString());
                if (!Directory.Exists(localTempPath))
                {
                    Directory.CreateDirectory(localTempPath);
                    break;
                }
                localTempPath = null;
            }

            if (localTempPath == null)
            {
                var exception = new SmartException("Too many backups in '{0}'.".FormatInvariant(tempPath));
                _logger.Error(exception.Message, exception);
                throw exception;
            }

            var backupFolder  = new DirectoryInfo(localTempPath);
            var folderUpdater = new FolderUpdater(_logger);

            folderUpdater.Backup(source, backupFolder, "App_Data", "Media");

            _logger.Information("Backup successfully created in folder '{0}'.".FormatInvariant(localTempPath));
        }
Ejemplo n.º 2
0
        private void Backup()
        {
            var source = new DirectoryInfo(CommonHelper.MapPath("~/"));

            var tempPath = CommonHelper.MapPath("~/App_Data/_Backup/App/SmartStore");
            string localTempPath = null;
            for (int i = 0; i < 50; i++)
            {
                localTempPath = tempPath + (i == 0 ? "" : "." + i.ToString());
                if (!Directory.Exists(localTempPath))
                {
                    Directory.CreateDirectory(localTempPath);
                    break;
                }
                localTempPath = null;
            }

            if (localTempPath == null)
            {
                var exception = new SmartException("Too many backups in '{0}'.".FormatInvariant(tempPath));
                _logger.Error(exception.Message, exception);
                throw exception;
            }

            var backupFolder = new DirectoryInfo(localTempPath);
            var folderUpdater = new FolderUpdater(_logger);
            folderUpdater.Backup(source, backupFolder, "App_Data", "Media");

            _logger.Information("Backup successfully created in folder '{0}'.".FormatInvariant(localTempPath));
        }