Created
February 10, 2025 02:29
-
-
Save horaciod/cf748761e938ad79a2774b4462aa5562 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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