feat: execute backup rotation after backup service execution

This commit is contained in:
wpetit 2020-10-22 10:51:08 +02:00
parent d7c5c11060
commit eee5579d18
2 changed files with 3 additions and 2 deletions

View File

@ -7,7 +7,8 @@ Type=oneshot
WorkingDirectory=/mnt/data/backup
ExecStartPre=/bin/sh -c 'systemctl -q is-active sentry.service && systemctl stop sentry'
ExecStart=/opt/sentry-util/sentry-util.sh backup
ExecStartPost=/bin/sh -c 'systemctl start sentry'
ExecStopPost=/bin/sh -c 'systemctl start sentry'
ExecStopPost=/opt/sentry-util/sentry-util.sh rotate
[Install]
WantedBy=multi-user.target

View File

@ -50,7 +50,7 @@ function restore {
}
function rotate {
local retention=${1:-1}
local retention=${1:-2}
local backup_dirs=( $(find -maxdepth 1 -type d -name "$BACKUP_DIR_PREFIX*" -printf "%f\n" | sort -r) )
echo "Rotating backups (retention: $retention)"
echo "Found ${#backup_dirs[@]} backup(s)"