A MacOS app to backup All Photos in iCloud to External Drive I have more than 140 GB of photos &amp; videos.  On my Mac I have only 256 GB of storage so I chose "Optimize Mac Storage" to make more room. 

I have a NAS with a lot of available storage (it has apps for my Apple TV).  My internet connection is not great here so I would like to be able to extract the photos and videos from my Mac and into a common format on an external or network drive. 

I can write a script or a Swift program to do this work but I do not have a clue how to approach a resolution. I also looked at SQLite file of Photos, which can be queried with sqlite3 program an used the following query: SELECT imagePath FROM RKMaster but it does not contain all the photos since I did not Download everything to my Mac.
You could do it in the Photos apps. If you launch it holding the option key, and choose to create a new library on the external drive. Then change the preferences to download all photos. It will take a while but that will download a full version of the library to the external. Then quit, safely remove the backup drive. Open again and choose the old local library, and quickly change the preference back to "optimize". It's a bit of a process but it should work.