Skip to content

Instantly share code, notes, and snippets.

@horaciod
Created February 10, 2025 02:29
  • Select an option

Select an option

#!/bin/bash
source_host="desarrollo@192.22.185.11"
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