Files
homework27/template_backup.sh

20 lines
780 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
export BORG_PASSPHRASE="{{ borg_pass }}"
current_date=$(date +%Y.%m.%d_%H:%M:%S)
#Создваем бэкап
borg create --stats backup-user@192.168.80.30:/var/hdd-backup/backup::"backup_dir_etc-$current_date" /etc
#проверяем, что созданный бэкап присутсвтует, с пишем в лог
if borg list backup-user@192.168.80.30:/var/hdd-backup/backup| grep -q "backup_dir_etc-$current_date"; then
logger "Success create backup /etc/* to 192.168.80.30 /var/hdd-backup/backup"
else
logger "Error Create backup /etc/* to 192.168.80.30 /var/hdd-backup/backup"
fi
#Удаляем старые бэкапы
/bin/borg prune --keep-daily 90 --keep-monthly 12 --keep-yearly 1 backup-user@192.168.80.30:/var/hdd-backup/backup