auto rotating pg dump files

This commit is contained in:
simon 2021-05-09 12:26:38 +07:00
parent e3e0f294c3
commit b1e3b62e4b
1 changed files with 3 additions and 0 deletions

View File

@ -8,6 +8,9 @@ backup_dir="$HOME/backup"
# backup
docker exec postgres pg_dump -U aqi | gzip > "$backup_dir/pg_$time_stamp.gz"
# rotate
find backup/ -type f -name "pg_*.gz" | sort -r | tail -n +15 | xargs --no-run-if-empty trash
# log
log_file="$backup_dir/pg_status.log"