We occasionally see backup tasks fail when the NAS device that hosts the source or destination volume starts to emit "too many open files" errors. The macOS smbd file sharing service has had problems over the years retaining too many open folders as part of a "directory leasing" feature. The feature is designed to improve the performance of repeated requests for the same folder information. If you're spending a lot of time in the Finder in one particular folder, having the folder information cached could be helpful (or not). The feature tends to cause trouble, however, when a backup process enumerates a large number of folders on the NAS volume. macOS imposes a limit on the number of files that any particular process can open, and the smbd file server process can run afoul of that limit if it doesn't manage directory leasing correctly.
If you see these errors when running a backup to or from a NAS volume, you can make a configuration change on your Mac, or on the server that hosts the network volume.
Server-side solution: Disable directory leasing
If the computer that hosts the network volume is a Mac, then you can disable directory leasing with a configuration change on that Mac:
- Turn off the File Sharing service in System Settings > General > Sharing
- Paste the following line into the Terminal application on that Mac, then press the Return key, and authenticate when prompted:
- Start the File Sharing service in System Settings > General > Sharing
- Run the CCC backup task again
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server DirectoryLeasingEnabled -bool NO
Client-side solution: disable directory caching
If the computer that hosts the network volume is not a Mac, you can disable directory caching and "deferred file closure" on your Mac client instead. Apple documents this troubleshooting step here, but their documented solution does not actually work because it references settings that do not exist. The nsmb.conf man page documents some seemingly-related settings as well, but those settings do not help resolve the caching problem. The settings that we recommend below are not documented, but are accessible via the SMBClient source code published by Apple on GitHub.
If your Mac already has an /etc/nsmb.conf file, add the following settings to the [default] section (edit that file in the Terminal via sudo nano /etc/nsmb.conf):
# Disable local SMB caching and directory leasing
dir_cache_off=yes
dir_lease_off=yes
file_def_close_off=yesIf your Mac doesn't have an /etc/nsmb.conf file, paste the following into the Terminal to create it:
sudo -s
printf '[default]
# Disable local SMB caching and directory leasing
dir_cache_off=yes
dir_lease_off=yes
file_def_close_off=yes\n' > /etc/nsmb.confAfter making changes to the /etc/nsmb.conf file, unmount, then remount the network volume for the changes to take effect (or simply restart the computer). Then try running your backup task again.