Prune fails on GCD with "The limit for this folder's number of children (files and folders) has been exceeded."

I just noticed that prunes on a backup have started to fail:

$ duplicacy prune -exclusive -exhaustive -keep 0:360 -keep 30:90 -keep 7:14 -keep 1:3
Storage set to gcd://Backups/…
Keep no snapshots older than 360 days
Keep 1 snapshot every 30 day(s) if older than 90 day(s)
Keep 1 snapshot every 7 day(s) if older than 14 day(s)
Keep 1 snapshot every 1 day(s) if older than 3 day(s)
Fossil collection 46 found
Ignore snapshot … whose last revision was created 7 days ago
Fossils from collection 46 is eligible for deletion
Snapshot … revision 17735 was created after collection 46
[0] Maximum number of retries reached (backoff: 64, attempts: 15)
Failed to resurrect chunk a9…: googleapi: Error 403: The limit for this folder's number of children (files and folders) has been exceeded., numChildrenInNonRootLimitExceeded

Any idea how to get out of this state, or if any tweaks could be made to prevent it?

There is a limit of 500K files per folder on Google Drive. If you’re hitting this limit, either your backup is too large or the chunks folder is a flat one (which happens if you started using Duplicacy before a default nesting level of 1 was introduced).

You can fix it by creating a file named nesting in Google Drive (next to the config file) with the following content:

{
    "read-levels": [1, 2],
    "write-level": 2
}

But if the current nesting level is 0 (which means all chunks are placed right under the chunks folder not in subfolders), then the nesting file should be:

{
    "read-levels": [0, 1],
    "write-level": 1
}

Thanks. It looks like my chunks folder was completely flat (level 0). I made the file, but I’m still getting the same error. Do I need to do something to migrate/free up space to unstick things?

You can try to move that chunk file manually. Find it under fossils, then remove 9a from the file name but keep the rest, then move it to a subdirectory 9a under chunks.

Run a check after this to make sure this chunk can be correctly located. You need to run a more recent version for the nesting file to take effect.

Hopefully you won’t have many such chunks.