custom backup dir path can be specified from now on

This commit is contained in:
Mate Majoros 2026-01-13 14:37:30 +02:00
parent 4d7ec83b4e
commit 39949bb7db

View file

@ -17,7 +17,11 @@ on:
required: true
type: string
backup_timestamp:
description: 'Backup timestamp (e.g., 20260109_142920) - leave empty to use latest'
description: '(Optional) Backup timestamp (e.g., 20260109_142920) - leave empty to use latest'
required: false
type: string
absolute_backup_dir_path:
description: '(Optional) Absolute path to the backup directory (the backup files contained in the directory should match the the following naming convention: <timestamp>-<site_name>-database.sql.gz, <timestamp>-<site_name>-files.tar, <timestamp>-<site_name>-private-files.tar.gz)'
required: false
type: string
@ -126,46 +130,50 @@ jobs:
cd ${{ env.DEPLOY_PATH }}
docker compose exec -T backend bash -c '
# Check both possible archived locations
if [ -d /home/frappe/frappe-bench/archived/sites ]; then
ARCHIVED_BASE=/home/frappe/frappe-bench/archived/sites
elif [ -d /home/frappe/frappe-bench/archived_sites ]; then
ARCHIVED_BASE=/home/frappe/frappe-bench/archived_sites
if [ -n \"${{ github.event.inputs.absolute_backup_dir_path }}\" ]; then
BACKUP_DIR=\"${{ github.event.inputs.absolute_backup_dir_path }}\"
else
echo \"ERROR: No archived sites directory found\"
exit 1
fi
# Find the archived site directory matching criteria
INPUT_TIMESTAMP=\"${{ github.event.inputs.backup_timestamp }}\"
if [ -n \"\$INPUT_TIMESTAMP\" ]; then
echo \"Searching for archived site containing backup timestamp: \$INPUT_TIMESTAMP\"
ARCHIVED_SITE=\"\"
# Loop through all matching site directories to find one with the specific backup
for site_dir in \$(ls -d \"\$ARCHIVED_BASE\"/${{ github.event.inputs.site_name }}* 2>/dev/null); do
if ls \"\$site_dir/private/backups/\${INPUT_TIMESTAMP}\"-*-database.sql.gz 1> /dev/null 2>&1; then
ARCHIVED_SITE=\"\$site_dir\"
break
# Check both possible archived locations
if [ -d /home/frappe/frappe-bench/archived/sites ]; then
ARCHIVED_BASE=/home/frappe/frappe-bench/archived/sites
elif [ -d /home/frappe/frappe-bench/archived_sites ]; then
ARCHIVED_BASE=/home/frappe/frappe-bench/archived_sites
else
echo \"ERROR: No archived sites directory found\"
exit 1
fi
# Find the archived site directory matching criteria
INPUT_TIMESTAMP=\"${{ github.event.inputs.backup_timestamp }}\"
if [ -n \"\$INPUT_TIMESTAMP\" ]; then
echo \"Searching for archived site containing backup timestamp: \$INPUT_TIMESTAMP\"
ARCHIVED_SITE=\"\"
# Loop through all matching site directories to find one with the specific backup
for site_dir in \$(ls -d \"\$ARCHIVED_BASE\"/${{ github.event.inputs.site_name }}* 2>/dev/null); do
if ls \"\$site_dir/private/backups/\${INPUT_TIMESTAMP}\"-*-database.sql.gz 1> /dev/null 2>&1; then
ARCHIVED_SITE=\"\$site_dir\"
break
fi
done
if [ -z \"\$ARCHIVED_SITE\" ]; then
echo \"ERROR: No archived site folder for ${{ github.event.inputs.site_name }} contains backup \$INPUT_TIMESTAMP\"
exit 1
fi
done
else
# Default: take the latest archived folder
ARCHIVED_SITE=\$(ls -td \"\$ARCHIVED_BASE\"/${{ github.event.inputs.site_name }}* 2>/dev/null | head -n 1)
fi
if [ -z \"\$ARCHIVED_SITE\" ]; then
echo \"ERROR: No archived site folder for ${{ github.event.inputs.site_name }} contains backup \$INPUT_TIMESTAMP\"
exit 1
echo \"ERROR: No archived backup found for site ${{ github.event.inputs.site_name }}\"
exit 1
fi
else
# Default: take the latest archived folder
ARCHIVED_SITE=\$(ls -td \"\$ARCHIVED_BASE\"/${{ github.event.inputs.site_name }}* 2>/dev/null | head -n 1)
BACKUP_DIR=\"\$ARCHIVED_SITE/private/backups\"
fi
if [ -z \"\$ARCHIVED_SITE\" ]; then
echo \"ERROR: No archived backup found for site ${{ github.event.inputs.site_name }}\"
exit 1
fi
BACKUP_DIR=\"\$ARCHIVED_SITE/private/backups\"
if [ ! -d \"\$BACKUP_DIR\" ]; then
echo \"ERROR: Backup directory not found: \$BACKUP_DIR\"
exit 1