3

I have been using hard links, as described here, for linking my important folders to my Dropbox. A very useful trick for backing up without messing up your preferred directory structure.

After my update the High Sierra, all the hard links where corrupted in such a way that all the files were lost.

This leaves me with a problem. How do I backup selected folders from my harddisk through Dropbox without changing my original file organization, without losing all my info this time. Does High Sierra support hard links? It seems not... what to do in such a case?

update

So both Dropbox and OneDrive need me to put files in a dedicated folder. It seems like hard links are no longer an option. In this case, I suppose I should switch to a dedicated service that does allow me to 'check' existing folders into the backup?

  • 1
    Is the new filesystem HFS or APFS? – Mark Jan 23 '18 at 11:13
  • I'm curious, but wouldn't one solution (albeit a rather elaborate one) be to make a script that monitors filesystem changes in the two folders, and propagates any changes to the other folder? I don't know how I would implement that, though. – Matt Jun 8 at 2:23
1

I've been successful been using Dropbox with folders "out of the root" using symlinks:

  • Stop Dropbox (quit the app)
  • Create a symlink to the destination folder anywhere within the Dropbox folder trees
  • Relaunch Dropbox

The link is synched into Dropbox as a folder in that position. Works great!

  • OMG Dropbox supports symlinks. This is amazing. I'm buying Dropbox professional right now even though my employer offers OneDrive (which doesn't support symlinks). The future me from an alternate timeline (that now seased to exist) who experienced loss of data due to not syncing thanks you! – dorien Mar 19 '18 at 3:30
5

The method you described involves installing a third party ln command that allows you to ask the kernel to create a hard-link for a directory.

The ln command from coreutils ends up executing the linkat() function in the Darwin kernel, where the source code includes the following comment:

/*
 * Normally, linking to directories is not supported.
 * However, some file systems may have limited support.
 */

It is therefore generally not recommended to create hard-links to directories.

In regards to upgrading to High Sierra, your system will usually have its file system converted from HFS+ (which supports these hard-links in some cases) to APFS (which do not supports directory hard links). Therefore you will not have hard-links after conversion.

See the documentation from Apple on the subject here:

https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/APFS_Guide/FAQ/FAQ.html

Especially the following paragraph:

Directory hard links are not supported by Apple File System. All directory hard links are converted to symbolic links or aliases when you convert from HFS+ to APFS volume formats on macOS.

The conversion program is supposed to convert these hard-links into symbolic links (soft links). The symbolic links points to new entries created in /.HFS+ Private Directory Data/.

However it seems that there might be a bug involving the conversion since you've experienced loss of files. This might be due to the fact that hard linked directories are seldomly used, and cannot be created with the standard Apple supplied tools.

Therefore I think you should file a bug report with Apple using Radar.

  • Thanks, so basically there is no way to do this anymore? – dorien Jan 23 '18 at 15:11
  • Not with APFS, no. You could use a HFS+ formatted drive and continue like before. However, it is not (as far as I know) possible to online convert APFS to HFS+. You would then need to copy over all your data to a secondary drive (USB or similar), reformat the original hard drive and then copy the data back. Time Machine backups would probably be an easy way of doing this. – jksoegaard Jan 23 '18 at 15:36
  • As a recent linux user switched to mac, I don't use time machine as all my external backup drives are nicely organized per topic not formatted for mac usage. Unfortunately, having great trouble accessing both my NFTS and EXT3 disk these days, but that's another topic. Apple... please make your fs decent. – dorien Jan 24 '18 at 4:42
  • Directory hard links are not recommended on Linux either. In fact the creation of them are purposefully limited to the root user, and even then most file systems do not really support them. For example the fsck for ext3 will complain about these as far as I recall. I'm not even sure btrfs supports creating them in the first place. – jksoegaard Jan 24 '18 at 14:39
  • Regarding accessing NTFS and ext3 drives from macOS - this is entirely possible. You can just search AskDifferent for solutions (multiple exist). – jksoegaard Jan 24 '18 at 14:39
1

You may do the opposite: move your folders into the Dropbox folder, then create symlinks to the locations you desire.

Example :

mv ~/Documents/cats ~/Dropbox/cats
ln -s ~/Dropbox/cats ~/Documents/cats
  • Seems like a bit of a hassle. I'm used to using terminal to navigate through my documents, this would change how I go to my files. Also lots of my files are code that may have some links to each other that may not work anymore. – dorien Jan 24 '18 at 4:40
0

Happened across this post as I was trying to find a way to automate deletion of hard links. Thought I'd add my two cents.

I've been using Sugarsync for about 5 years to avoid exactly the problem you describe. It just backs up my files in their original directory structure. It's worked well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .