{"record":{"id":"50d4674f6bfe15b0","repo":"nopSolutions/nopCommerce","slug":"backup-directory-not-exists","errorCode":null,"errorMessage":"Backup directory not exists","messagePattern":"Backup directory not exists","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/Common/MaintenanceService.cs","lineNumber":54,"sourceCode":"        if (ensureFolderCreated)\r\n            _fileProvider.CreateDirectory(path);\r\n        return path;\r\n    }\r\n\r\n    #endregion\r\n\r\n    #region Methods\r\n\r\n    /// <summary>\r\n    /// Gets all backup files\r\n    /// </summary>\r\n    /// <returns>Backup file collection</returns>\r\n    public virtual IList<string> GetAllBackupFiles()\r\n    {\r\n        var path = GetBackupDirectoryPath();\r\n\r\n        if (!_fileProvider.DirectoryExists(path))\r\n            throw new NopException(\"Backup directory not exists\");\r\n\r\n        return _fileProvider.GetFiles(path, $\"*.{NopCommonDefaults.DbBackupFileExtension}\")\r\n            .OrderByDescending(p => _fileProvider.GetLastWriteTime(p)).ToList();\r\n    }\r\n\r\n    /// <summary>\r\n    /// Returns the path to the backup file\r\n    /// </summary>\r\n    /// <param name=\"backupFileName\">The name of the backup file</param>\r\n    /// <returns>The path to the backup file</returns>\r\n    public virtual string GetBackupPath(string backupFileName)\r\n    {\r\n        return _fileProvider.Combine(GetBackupDirectoryPath(), backupFileName);\r\n    }\r\n\r\n    /// <summary>\r\n    /// Creates a path to a new database backup file\r\n    /// </summary>\r","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/Common/MaintenanceService.cs#L36-L72","documentation":"Thrown by GetAllBackupFiles() as a NopException when the configured backup directory does not exist on disk. The method first resolves the directory path via GetBackupDirectoryPath() then checks _fileProvider.DirectoryExists(path). If the folder is missing, the database-backup file listing cannot proceed.","triggerScenarios":"Calling GetAllBackupFiles() on an installation where the backup directory (commonly ~/App_Data/ or the admin-configured path) has never been created or was deleted. Common after a fresh deploy, after moving the App_Data folder, or when file permissions prevent the directory from being enumerated.","commonSituations":"Fresh installation that has never produced a backup; deployment to a new server where the App_Data/Backups folder was excluded from the published artifacts; containerized hosting with ephemeral storage where the folder isn't in the volume mount.","solutions":["Create the backup directory before listing: ensure the path returned by GetBackupDirectoryPath() exists (Directory.CreateDirectory(path)).","Run the built-in 'Create backup' admin action once, which writes the first .bak file and implicitly creates the folder.","Check file/folder permissions for the application pool identity on the resolved backup path.","If hosting in a container, mount a persistent volume at the backup directory path."],"exampleFix":"// before\nvar files = _maintenanceService.GetAllBackupFiles();\n\n// after\nvar dir = _maintenanceService.GetBackupDirectoryPath();\nDirectory.CreateDirectory(dir);\nvar files = _maintenanceService.GetAllBackupFiles();","handlingStrategy":"fallback","validationCode":"var dir = _maintenanceService.GetBackupDirectoryPath();\nif (!_fileProvider.DirectoryExists(dir))\n    Directory.CreateDirectory(dir);\nvar files = _maintenanceService.GetAllBackupFiles();","typeGuard":null,"tryCatchPattern":"IList<string> files;\ntry { files = _maintenanceService.GetAllBackupFiles(); }\ncatch (NopException ex) when (ex.Message.Contains(\"Backup directory\"))\n{\n    _logger.LogWarning(ex, \"Backup directory missing; returning empty list.\");\n    files = Array.Empty<string>();\n}","preventionTips":["Run one backup-creation action during deployment to seed the folder.","Mount persistent storage at the backup path in containers.","Verify application-pool write permissions on App_Data."],"tags":["backup","maintenance","filesystem","configuration","deployment"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}