Skip to content

fin pull db: Pantheon backup freshness check always creates a new backup (epoch vs formatted-date comparison bug) #96

Description

@sgenini

Summary

provider_pull_pantheon_db() in pull/pull is supposed to reuse an existing Pantheon backup if it's less than 24 hours old, and only call terminus backup:create (which runs a full DB dump on the live/production environment) when the cached backup has actually expired. In practice, it creates a brand new backup on every single fin pull db / fin refresh run, regardless of how recently one was made.

Root cause

local last_backup
last_backup=$(_exec -T "terminus backup:list ${hostingsite}.${hostingenv} --element=db --format=list --field=date | head -n 1")
if_failed_error "Error retrieving list of backups from Pantheon for ${hostingsite} on the ${hostingenv} environment"
if [[ "last_backup" == "" ]] || [[ "${last_backup}" < "${yesterday}" ]] || [[ "$force" == "force" ]]; then
  • terminus backup:list ... --field=date returns a raw Unix epoch timestamp (e.g. 1786491893.1987), not a formatted date.
  • $yesterday (set earlier in the file) is a formatted string: date --date='yesterday' "+%Y-%m-%d %H:%M:%S" → e.g. 2026-08-10 19:21:58.
  • The comparison "${last_backup}" < "${yesterday}" is a plain Bash string comparison. Since epoch timestamps for any date after 2001 start with the digit 1, and formatted YYYY-... dates for 2000-2099 start with 2, this comparison is always true"1786491893.1987" < "2026-08-10 19:21:58" evaluates true no matter what the actual backup age is.

There's also a secondary bug in the same line: [[ "last_backup" == "" ]] compares the literal string "last_backup" instead of the variable "${last_backup}" (missing $), so the "no backup exists yet" branch is also dead code.

Impact

  • Every fin pull db / fin refresh forces a new terminus backup:create against the live environment, even when a backup from minutes earlier already exists. Each of these takes ~15-20 minutes and runs a full dump on the production app container.
  • We noticed this because repeated fin refresh runs (about an hour apart) each showed up as a fresh "Exported database/files from live" entry in the Pantheon dashboard, with no reuse of the same-day backup.

Fix

The Acquia provider (provider_pull_acquia_db) already handles this correctly by converting its epoch timestamp to the same formatted string before comparing:

last_date=$(_exec date --date=@${last_date} "+%Y-%m-%d %H:%M:%S")

PR incoming that applies the same pattern to provider_pull_pantheon_db.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions