1
0
mirror of https://github.com/xzeldon/vwdump.git synced 2025-06-28 02:28:14 +03:00
vwdump/delete.sh
jmqm 8573420236
Quality of life improvements (#17)
- Removed quotation marks with mounting volumes in docker-compose section.
- Replaced INFO prefix with each echo with a timestamp.
  - Subsequently, echoes that have a timestamp at the end have been adjusted to remove them.
- When deleting, it first checks if there are files to delete.
  - An appropriate echo will be shown in both circumstances.
2021-07-17 14:39:17 -05:00

23 lines
711 B
Bash

#!/bin/sh
# Sleep for one minute to ensure a backup is made first.
sleep 1m
# Go to the backups directory.
cd /backups
# Find all tar.xz archives older than x days and store them in a variable.
TO_DELETE=$(find . -iname "*.tar.xz" -type f -mtime +$DELETE_AFTER)
# Check if TO_DELETE is empty.
if [ ! -z "$TO_DELETE" ]; then
# Delete tar.xz archives older than x days.
find . -iname "*.tar.xz" -type f -mtime +$DELETE_AFTER -exec rm -f {} \;
# Echo that archives were deleted.
echo "[$(date +"%F %r")] Deleted archives older than $DELETE_AFTER days."
else
# Echo that there are no archives to delete.
echo "[$(date +"%F %r")] No archives older than $DELETE_AFTER days to delete."
fi