MacOS – How to restore files when the account isn’t granted access

macosMySQLtime-machine

I had a heavily corrupted MySQL database, so I tried to restore the files from a recent backup (a local time machine snapshot), but that failed with the error:

The operation can’t be completed because you don’t have permission to access some of the items.

How can I restore these files?

In trying, I added my account to the "_mysql" group with dseditgroup (groups now lists me as being in the "_mysql" group), which is supposed to be granted read/write access to all files and folders, and tried restoring from Time Machine again with the same result. The folders also still display the "inaccessible" icon overlay (⛔️) in Finder. I can copy (slightly) older versions of the files stored on an external Time Machine drive from a shell with a sudo ditto, but get a permissions error from MySQLd when it tries to read one of the files (the binary log index).

The computer is running OS X 10.12.6.

Best Answer

I was able to access the local snapshots in "/.MobileBackups/Computer/" via a command line. Unfortunately, I disabled automatic Time Machine backups, not knowing that this would delete all local snapshots.

The files from the external Time Machine backup had an ACL that disallowed all write access to the database directories and files (revealed with ls -le). Removing the ACL with chmod -RN $dir granted access (no more permission errors when MySQLd runs).