Using Claude

For quite a while I’d been backing up several WordPress sites using Transmit and an AppleScript I wrote. That process only captured site content and had a couple of persistent problems:

  • AppleEvent timeout errors from Transmit
  • Manual database backups for MariaDB

I wanted to fix both issues but, frankly, was too lazy to bother. The sites aren’t terribly important, so once-a-week backups felt good enough — even if I always knew I should make the process more robust: use rsync for content, automate the database backup, log errors, all the good stuff.

I’ve been using Claude at work for use cases, specifications, and bits of software coding, so I decided to take a shot at building a proper backup tool with it.
I sat down with Claude, wrote a prompt with use cases, built test cases, and assembled the script piece by piece — reading and testing each section as I went.

Three hours later, I had my tool. 

Dependencies are minimal:

  • sshpass
  • rsync
  • bash
  • osascript (for macOS notifications when the backup completes)

The result is clean and solid. I run it via launchd with settings to prevent the Mac Mini from sleeping during execution.

Here is an overview of the functionality

‘backup_wordpress.sh’ is a bash script that automates WordPress site backups. It performs two distinct operations:

  • Database backups — connects via SSH to the web server and runs mysqldump remotely, piping output directly to the local backup volume
  • File backups — uses rsync over SSH to incrementally sync all site files from the remote server to the local backup volume

The script supports four run modes, timestamped logging, macOS notifications, automatic cleanup of old backups, filesystem flushing to ensure files are immediately visible after writing, and unattended scheduled execution via launchd.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *