diff --git a/roles/backup/files/pull_remote_backups.sh b/roles/backup/files/pull_remote_backups.sh index f354473..a035741 100644 --- a/roles/backup/files/pull_remote_backups.sh +++ b/roles/backup/files/pull_remote_backups.sh @@ -10,7 +10,7 @@ DATABASE_ENGINE=$3 DEST_DIR=${HOME}/backups/${STAGE}/${DATABASE_ENGINE}/ # remove files oder than XX in backup-DIR -find ${DEST_DIR} -type f -mtime +3 -delete +find ${DEST_DIR} -type f -mtime +2 -delete mkdir -p ${DEST_DIR} rsync -av --remove-source-files -e "ssh -o StrictHostKeyChecking=no" ${REMOTE_SYSTEM_USER}@${DATABASE_SERVER_IP}:/backups/${DATABASE_ENGINE}/* ${DEST_DIR}/ diff --git a/roles/backup/files/push_backups_to_restore_server.sh b/roles/backup/files/push_backups_to_restore_server.sh index 660246e..1a0ec16 100644 --- a/roles/backup/files/push_backups_to_restore_server.sh +++ b/roles/backup/files/push_backups_to_restore_server.sh @@ -17,6 +17,10 @@ BACKUP_FILE_FOR_TRANSFER=$(find "${LOCAL_BACKUP_DIR}/${DATE}/" -name *.gz.gpg | REMOTE_BACKUP_DIR="/home/${REMOTE_SYSTEM_USER}/backups/${STAGE}/${DATABASE_ENGINE}" DEST_DIR="${REMOTE_BACKUP_DIR}/${DATE}/" +if [ ! -f $BACKUP_FILE_FOR_TRANSFER ]; then + echo "BACKUP_FILE_FOR_TRANSFER not found. EXIT" && exit 1 +fi + # avoid "REMOTE HOST IDENTIFICATION HAS CHANGED" - errors due to dynamic created server on restore process ssh-keygen -f "/home/backuphamster/.ssh/known_hosts" -R ${DATABASE_SERVER_IP} diff --git a/roles/backup/tasks/main.yml b/roles/backup/tasks/main.yml index f8fb2a8..4db1552 100644 --- a/roles/backup/tasks/main.yml +++ b/roles/backup/tasks/main.yml @@ -56,7 +56,7 @@ - pull_remote_backups.sh - push_backups_to_restore_server.sh -- name: Touch metrics.prom is not exists +- name: Touch metrics.prom if not exists file: path: "/home/{{ system_user }}/metrics.prom" state: touch