Today a bug in Safari closed nearly all of my tabs and they were not in the history of last closed tabs. A precondition of this solution is having iCloud Tabs enabled.

link-2 1. Recover Tab Database

Navigate (⇧+⌘+G) in Finder to the following folder:

/Users/<user name>/Library/Safari/

Open Time Machine, change the date time to the last time, when the tabs were existent and copy the file CloudTabs.db and paste it in Finder into a new project directory.

link-2 2. Extract the URLs

Open the Terminal and cd to the project directory.

$ cd <e.g Documents/recover-tabs>

Open the database:

$ sqlite3
sqlite> .open CloudTabs.db

Get the device UUID:

SELECT device_uuid, device_name FROM cloud_tab_devices;
01234567-89AB-CDEF-0123456789AB|My Device

In this case the device UUID would be 01234567-89AB-CDEF-0123456789AB.

To get a list of URLs just use the following statement:

SELECT url FROM cloud_tabs WHERE device_uuid = '<device UUID>';

If you want the page titles, use the following statement:

SELECT title, url FROM cloud_tabs WHERE device_uuid = '<device UUID>';

Now just copy the list into a file.