Skip to content

Commit

Permalink
correct purge list filling because two types of files were counted
Browse files Browse the repository at this point in the history
  • Loading branch information
tohtor committed Oct 18, 2018
1 parent 21a117a commit 7560822
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pg_back
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,24 @@ else
# with the time of last modification since Epoch. Sort them so
# that the newest come first and keep
to_purge=()

# Fill purge list with .sql file
i=1
while read line; do
if (( $i > ${PGBK_PURGE_MIN_KEEP:-0} )); then
to_purge+=( "$line" )
fi
(( i++ ))
done < <(stat -c '%Y|%n' $PGBK_BACKUP_DIR/${db}_*.sql 2>/dev/null | sort -rn)

# Fill purge list with .dump file
i=1
while read line; do
if (( $i > ${PGBK_PURGE_MIN_KEEP:-0} )); then
to_purge+=( "$line" )
fi
(( i++ ))
done < <(stat -c '%Y|%n' $PGBK_BACKUP_DIR/${db}_*.{dump,sql} 2>/dev/null | sort -rn)
done < <(stat -c '%Y|%n' $PGBK_BACKUP_DIR/${db}_*.dump 2>/dev/null | sort -rn)

# Check if the file/dir is old enough to be removed
for dump in "${to_purge[@]}"; do
Expand Down

0 comments on commit 7560822

Please sign in to comment.