|
|
@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
set -euxo pipefail;
|
|
|
|
set -euxo pipefail;
|
|
|
|
|
|
|
|
|
|
|
|
backupsToKeep={{ backups_to_keep }};
|
|
|
|
backupsToKeep={{ backups_to_keep | quote }};
|
|
|
|
|
|
|
|
|
|
|
|
function onlyDatedFiles() {
|
|
|
|
function onlyDatedFiles() {
|
|
|
|
grep --perl-regexp '/\d+(-\d+)*(\.[^/]+)*$';
|
|
|
|
grep --perl-regexp '/\d+(-\d+)*(\.[^/]+)*$';
|
|
|
@ -16,6 +16,6 @@ find {{ backups_directory | quote }} -type f |
|
|
|
|
onlyDatedFiles |
|
|
|
|
onlyDatedFiles |
|
|
|
|
getDirName |
|
|
|
|
getDirName |
|
|
|
|
sort --unique |
|
|
|
|
sort --unique |
|
|
|
|
while read dir; do
|
|
|
|
while read -r dir; do
|
|
|
|
find "$dir" -type f | onlyDatedFiles | sort --reverse | tail --lines=+$((backupsToKeep + 1)) | xargs rm --force;
|
|
|
|
find "$dir" -type f | onlyDatedFiles | sort --reverse | tail --lines=+$((backupsToKeep + 1)) | xargs rm --force;
|
|
|
|
done
|
|
|
|
done
|
|
|
|