diff --git a/README.md b/README.md index bcff250..5e8c5e6 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ backup_mysql_user: backup backup_mysql_password: y0urverys3curep4ss # Script settings -deletetime: 30 days +retentiontime: 30 days directory: daily minimal_backups: 5 diff --git a/defaults/main.yml b/defaults/main.yml index b472b9a..e8b65c5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,7 +14,7 @@ backup_mysql_user: backup backup_mysql_password: y0urverys3curep4ss # Script settings -deletetime: 30 days +retentiontime: 30 days directory: daily minimal_backups: 5 diff --git a/templates/backup.sh.j2 b/templates/backup.sh.j2 index 0701ba1..127c8a2 100644 --- a/templates/backup.sh.j2 +++ b/templates/backup.sh.j2 @@ -35,7 +35,7 @@ echo -e "\e[39m" mysqluser="{{ backup_mysql_user }}" mysqlpass="{{ backup_mysql_password }}" bucket="s3://{{ customer }}-{{ app }}-backup" -deletetime="{{ deletetime }}" +retentiontime="{{ retentiontime }}" directory="{{ directory }}" minimalbackups={{ minimal_backups }} @@ -46,7 +46,7 @@ fi if [[ "$2" ]] then - deletetime="$2" + retentiontime="$2" fi # Timestamp (sortable AND readable) @@ -82,7 +82,7 @@ for db in $databases; do # Delete rm -f "$tmpfile" - # Delete older then $deletetime but keep a minimum of 5 + # Delete older then $retentiontime but keep a minimum of 5 files=`s3cmd ls $bucket/$db/$directory/` numberFiles=`echo "$files" | wc -l` if [ "$numberFiles" -gt "$minimalbackups" ] @@ -100,7 +100,7 @@ for db in $databases; do createDate=`echo $line|awk {'print $1" "$2'}` createDate=`date -d"$createDate" +%s` - olderThan=`date -d"-$deletetime" +%s` + olderThan=`date -d"-$retentiontime" +%s` if [[ $createDate -lt $olderThan ]] then