How to use terminal to access iCloud Drive when Finder is not running

backupcommand lineicloudosx

I would like to access iCloud drive from Terminal in order to create an emergency backup. Unfortunately, my installation of Mac OS Yosemite is not operational, so I am using recovery mode to create my backup. In this mode, the Finder is not available and iCloud Drive is not running.

I am aware that normally, the iCloud drive directories are located at
~/Library/Mobile\ Documents/com~apple~CloudDocs. Unfortunately this directory does not appear when using Terminal in recovery mode (there appears to be no Mobile Documents in Library). This makes sense, because I am not logged in as any of the users (and I believe the recovery utility runs on its own partition).

My questions are thus:

  1. Is there any way I can connect to and access iCloud drive directories from Terminal in Mac OS recovery mode (i.e. after booting up while holding down cmd + r) when iCloud Drive sync is not running (as Finder isn't running)?
  2. How can I copy all files in a given folder (including all subfolders) into an iCloud drive directory using a Terminal command?

Should it not be possible to log into iCloud drive using Terminal, Dropbox would be an alternative. I am not sure, however, whether I can install the Dropbox command line tool in recovery mode.

Best Answer

I think you're going the wrong way.

Why you try to recover these files? Reinstall the OS from CMD + R and login again. Now you can backup all your documents. The reinstall will not delete your files until you don't format the disk/s. btw. you could login in iCloud via www.icloud.com and get your files from there.

An other solution could be: Download the latest Combo Update for your installed OS (for ex. https://support.apple.com/kb/DL1832?locale=de_DE) and turn the damaged OS in Target Disk Mode with holding the "T" key on startup. Now connect your damaged OS via Firewire or Thunderbolt (or even with a FW to TB converter/adapter) and run from your working Yosemite installation the Combo Update installer. Choose as destination the damaged OS from Target Disk Mode. In many cases the Combo Update can fix some issues without have to reinstall the whole OS. But thats only a temporary solution. The issue should be resolved.

Btw. I don't understand why you're trying to recover the files from the disk, when the files are already on iCloud? What's your intension? Perhaps we could help you better if we know what the intension is?

Best regards

Related Question