{"record":{"id":"06defcda5dbe564f","repo":"duplicati/duplicati","slug":"cannotcreaterandomname","errorCode":"CannotCreateRandomName","errorMessage":"Unable to find a unique name for the database, please use --dbpath","messagePattern":"Unable to find a unique name for the database, please use --dbpath","errorType":"exception","errorClass":"UserInformationException","httpStatus":null,"severity":"error","filePath":"Duplicati/Library/Main/CLIDatabaseLocator.cs","lineNumber":219,"sourceCode":"\n            if (matches.Count == 0)\n            {\n                var backupname = options.BackupName;\n                if (string.IsNullOrEmpty(backupname) || backupname == Options.DefaultBackupName)\n                    backupname = GenerateRandomName();\n                else\n                {\n                    foreach (var c in System.IO.Path.GetInvalidFileNameChars())\n                        backupname = backupname.Replace(c.ToString(), \"\");\n                }\n\n                var newpath = System.IO.Path.Combine(folder, backupname + \".sqlite\");\n                int max_tries = 100;\n                while (System.IO.File.Exists(newpath) && max_tries-- > 0)\n                    newpath = System.IO.Path.Combine(folder, GenerateRandomName());\n\n                if (System.IO.File.Exists(newpath))\n                    throw new Duplicati.Library.Interface.UserInformationException(\"Unable to find a unique name for the database, please use --dbpath\", \"CannotCreateRandomName\");\n\n                //Create a new one, add it to the list, and save it\n                configs.Add(new BackendEntry()\n                {\n                    Type = type,\n                    Server = server,\n                    Path = path,\n                    Prefix = prefix,\n                    Username = username,\n                    //Passwordhash = password,\n                    Port = port,\n                    Databasepath = newpath,\n                    ParameterFile = null,\n                    IsSyncDb = isSyncDb\n                });\n\n                var settings = new Newtonsoft.Json.JsonSerializerSettings();\n                settings.Formatting = Newtonsoft.Json.Formatting.Indented;","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/duplicati/duplicati/blob/3f348be3e33f5d72d414e3ad55839c2ba34dda67/Duplicati/Library/Main/CLIDatabaseLocator.cs#L201-L237","documentation":"Thrown by CLIDatabaseLocator when auto-creating a new database file: it tries up to 100 randomly generated names and if every candidate path already exists on disk, it gives up and asks the user to supply --dbpath. This is a guard against pathological folder state, not normal operation.","triggerScenarios":"autoCreate is true, no existing match is found, and System.IO.File.Exists returns true for all 100 random names generated under the configured folder.","commonSituations":"The database folder has accumulated hundreds of randomly-named .sqlite files (e.g. from many abandoned backups or a bug leaking files); filesystem/permission issues make File.Exists behave unexpectedly; a very small name space collision (GenerateRandomName collision).","solutions":["Supply --dbpath to specify an exact, unused database file path.","Clean up the target folder: remove orphaned randomly-named .sqlite files.","Verify write access and free space on the folder."],"exampleFix":"// before: locator cannot find a free random name\nduplicati backup \"s3://host/path\"\n\n// after: explicit database path\nduplicati backup \"s3://host/path\" --dbpath=/data/duplicati/new.sqlite","handlingStrategy":"validation","validationCode":"// Avoid relying on random-name collision avoidance\nif (string.IsNullOrEmpty(dbPath))\n    throw new ArgumentException(\"Supply --dbpath to guarantee a unique database file\");\nif (System.IO.File.Exists(dbPath)) throw new InvalidOperationException($\"{dbPath} already exists\");","typeGuard":null,"tryCatchPattern":"try { var path = CLIDatabaseLocator.GetDatabasePath(...); }\ncatch (UserInformationException ex) when (ex.HelpID == \"CannotCreateRandomName\")\n{ /* fall back to an explicit --dbpath chosen by the caller */ }","preventionTips":["Specify --dbpath explicitly in all deployments.","Periodically prune orphaned .sqlite files from the database folder."],"tags":["database","filesystem","cli","edge-case"],"backgroundTag":null,"analyzedSha":"3f348be3e33f5d72d414e3ad55839c2ba34dda67","analyzedAt":"2026-08-13T16:48:27.008Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}