Skip to content

Instantly share code, notes, and snippets.

@horaciod
Created February 10, 2025 02:29
Show Gist options
  • Save horaciod/cf748761e938ad79a2774b4462aa5562 to your computer and use it in GitHub Desktop.
Save horaciod/cf748761e938ad79a2774b4462aa5562 to your computer and use it in GitHub Desktop.
#!/bin/bash
source_host="[email protected]"
source_dir="/disco2/backupspg/backups/basededatos"
target_dir="."
#obtiene el ultimo archivo del server remoto
last_backup=$(ssh ${source_host} "find ${source_dir} -type f -printf '%T@ %p\n' | sort -k1,1nr | head -1 |cut -d' ' -f2-")
if [ "${last_backup}" == "" ]; then
echo "ERROR: no existe el backup!"
else
echo "Ultimo backup sig: ${last_backup}">> sigsid.txt
if [ -f "basededatos.zip" ] ;then
echo "existe una copia previa"
mv basededatos.zip old_basededatos.zip
fi
rsync -avzh ${source_host}:${last_backup} ${target_dir}/basededatos.zip
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment