Backing up iCloud Drive
Whether it be user error or a bug, it’s definitely possible to lose data on iCloud Drive. If you keep important data there, personal or otherwise, it’s important to know a few things.
While Apple does backup iCloud Drive, the frequency may not suit you. A restore may also overwrite other files you’ve changed since the last backup if you are really wanting to restore just one file. Some network backup solutions don’t back up iCloud Drive so you may have to manually configure them to do so. Backblaze does back it up.
Manual backups
Backing up iCloud Drive yourself is an option. Simply copy the path below via Terminal or Finder to either a separate location on your local drive or to an external or network drive:
~/Library/Mobile\ Documents
Time Machine DOES backup iCloud Drive. However, Time Machine’s backup schedule is not predetermined. It’s possible to turn off Time Machine and then manually back up using the tmutil command. I’ll be honest and say that I’ve found this route to be frustrating, so I hesitate to even comment on it.
The crazy option
I have a script set up to run every 4 hours that does a Time Machine style backup, using hard links to save space. Note that you can do APFS snapshots using tmutil or rsync, but this doesn’t provide complete protection from data loss.
Here’s an example of an rsync command that will do an initial backup to an attached hard drive, then incremental backups after that, provided that you provide the previous backup folder path.
rsync -avhz --delete --delete-excluded --exclude='<list of paths to exclude>' --link-dest="<previous backup folder path>" ~/Library/Mobile\ Documents/ "<new backup folder path>"
I have something like this as part of a larger script that names folders and culls out old backups. So, if you’re comfortable with rsync, it may be a nice hard-core option for you.