mirror of
https://github.com/fradelg/docker-mysql-cron-backup.git
synced 2024-11-01 00:21:46 +01:00
14 lines
424 B
Bash
14 lines
424 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
db=$1
|
||
|
EXT=$2
|
||
|
|
||
|
# This file could be customized to create custom delete strategy
|
||
|
|
||
|
while [ "$(find /backup -maxdepth 1 -name "*.$db.sql$EXT" -type f | wc -l)" -gt "$MAX_BACKUPS" ]
|
||
|
do
|
||
|
TARGET=$(find /backup -maxdepth 1 -name "*.$db.sql$EXT" -type f | sort | head -n 1)
|
||
|
echo "==> Max number of ($MAX_BACKUPS) backups reached. Deleting ${TARGET} ..."
|
||
|
rm -rf "${TARGET}"
|
||
|
echo "==> Backup ${TARGET} deleted"
|
||
|
done
|