Backup Safari Tabs - Scheduled

Summary

This a script and task that will backup Safari tabs on a schedule

Body

Step-by-Step: Create the Safari Tab Backup Workflow in Automator

1. Open Automator

  • Go to Applications > Automator
  • Choose New Document
  • Select "Application" or "Workflow" (either works, but "Application" is easier to run via Calendar)

2. Add an AppleScript Action

  • In the left sidebar, search for “Run AppleScript”
  • Drag it into the workflow area

3. Paste This AppleScript

set desktopPath to (path to desktop folder as text)
set backupFolder to desktopPath & "Safari Tab Backups:"
set backupFolderPOSIX to POSIX path of backupFolder

-- Create backup folder if it doesn't exist
do shell script "mkdir -p " & quoted form of backupFolderPOSIX

set dateString to do shell script "date +%Y-%m-%d"
set backupFile to backupFolderPOSIX & "/SafariTabs_" & dateString & ".txt"

tell application "Safari"
    set tabURLs to {}
    repeat with w in windows
        repeat with t in tabs of w
            set end of tabURLs to URL of t
        end repeat
    end repeat
end tell

set AppleScript's text item delimiters to linefeed
set tabText to tabURLs as text

do shell script "echo " & quoted form of tabText & " > " & quoted form of backupFile

4. Save the Workflow

  • File > Save
  • Name it something like SafariTabBackup
  • Save it to your Applications folder or Desktop

Step-by-Step: Schedule It to Run Daily

Option A: Use Calendar

  1. Open Calendar
  2. Create a new event at the time you want the backup to run
  3. Set it to repeat daily
  4. Add an alert > Custom > Open file
  5. Choose the Automator app you saved (SafariTabBackup.app)

Optional: Add Cleanup Script to Delete Old Files​​​​​​​

find ~/Desktop/Safari\ Tab\ Backups/ -name "SafariTabs_*.txt" -mtime +7 -delete

Use “Run Shell Script” in Automator, save it as SafariTabCleanup, and schedule it weekly using Calendar.

 

Details

Details

Article ID: 14178
Created
Thu 8/21/25 8:01 AM
Modified
Wed 3/4/26 8:55 AM