Skip to content

Commit

Permalink
Change deletetime to retentiontime
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenvandermeulen committed Mar 21, 2023
1 parent 99b23c6 commit 0305864
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions templates/backup.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -46,7 +46,7 @@ fi

if [[ "$2" ]]
then
deletetime="$2"
retentiontime="$2"
fi

# Timestamp (sortable AND readable)
Expand Down Expand Up @@ -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" ]
Expand All @@ -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
Expand Down

0 comments on commit 0305864

Please sign in to comment.