From 59f3f1ed249e2cdd15f42f48ca600bd5211206c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Genini?= Date: Tue, 11 Aug 2026 19:34:45 -0700 Subject: [PATCH 1/2] Fix Pantheon backup freshness check comparing epoch to formatted date provider_pull_pantheon_db() reads the last backup's date via `terminus backup:list ... --field=date`, which returns a raw Unix epoch timestamp (e.g. 1786491893.1987), and compares it directly against `$yesterday`, a formatted "Y-m-d H:M:S" string. Since epoch timestamps for any date after 2001 start with the digit "1" and formatted "YYYY-..." dates for 2000-2099 start with "2", the string comparison `"${last_backup}" < "${yesterday}"` is always true regardless of how recent the backup actually is. This forces a brand new `terminus backup:create` against the live/production environment on every single pull, even when a backup from minutes ago already exists. The Acquia provider (provider_pull_acquia_db) already converts its epoch timestamp to the same formatted string before comparing (see `date --date=@${last_date} ...`); this applies the same pattern here. Also fixes a secondary bug in the same condition: the "no backup exists" check compared the literal string "last_backup" instead of the variable "${last_backup}", so it never actually detected a missing backup. --- pull/pull | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pull/pull b/pull/pull index 9494dd8..06fd874 100755 --- a/pull/pull +++ b/pull/pull @@ -535,7 +535,11 @@ provider_pull_pantheon_db () 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 + if [[ "${last_backup}" != "" ]]; then + # terminus returns a raw epoch timestamp; convert to the same "Y-m-d H:M:S" format as $yesterday so the comparison below is meaningful. + last_backup=$(_exec date --date=@${last_backup%%.*} "+%Y-%m-%d %H:%M:%S") + fi + if [[ "${last_backup}" == "" ]] || [[ "${last_backup}" < "${yesterday}" ]] || [[ "$force" == "force" ]]; then # If last backup does not exist or is older than 24 hours create new one. echo -e "${acqua}Creating new backup on Pantheon for ${hostingsite} on the ${hostingenv} environment${NC}" _exec terminus backup:create ${hostingsite}.${hostingenv} --element=db From 62fe9d6e4d2948bf395b32634e8fdd9bbf2e872d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Genini?= Date: Tue, 11 Aug 2026 19:44:54 -0700 Subject: [PATCH 2/2] Quote the date argument to avoid relying on word-splitting Addresses CodeRabbit review feedback on #97: pass the timestamp to `date` as a single quoted argument (--date="@${last_backup%%.*}") instead of leaving it unquoted. --- pull/pull | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull/pull b/pull/pull index 06fd874..d1367bb 100755 --- a/pull/pull +++ b/pull/pull @@ -537,7 +537,7 @@ provider_pull_pantheon_db () if_failed_error "Error retrieving list of backups from Pantheon for ${hostingsite} on the ${hostingenv} environment" if [[ "${last_backup}" != "" ]]; then # terminus returns a raw epoch timestamp; convert to the same "Y-m-d H:M:S" format as $yesterday so the comparison below is meaningful. - last_backup=$(_exec date --date=@${last_backup%%.*} "+%Y-%m-%d %H:%M:%S") + last_backup=$(_exec date --date="@${last_backup%%.*}" "+%Y-%m-%d %H:%M:%S") fi if [[ "${last_backup}" == "" ]] || [[ "${last_backup}" < "${yesterday}" ]] || [[ "$force" == "force" ]]; then # If last backup does not exist or is older than 24 hours create new one.