Created
August 22, 2023 09:52
-
-
Save michelep/6711b60f2b6ca104b0df1a4bfc2c1966 to your computer and use it in GitHub Desktop.
rt-shredder manteinance script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Make sure to be in the right directory (fit to your RT4 installation) | |
cd /opt/rt4 | |
# Get the current year | |
current_year=$(date +'%Y') | |
# Subtract two years from the current year | |
two_years_before=$((current_year - 2)) | |
# Get the current month and day | |
current_month_day=$(date +'%d-%m') | |
# Concatenate the two years before with the current month and day, with hour | |
two_years_before="$current_month_day-$two_years_before 23:59:59" | |
echo -n "Archiving 100 tickets before $two_years_before..." | |
./sbin/rt-shredder --plugin "Tickets=query,(Status='rejected' OR Status='resolved') AND LastUpdated < '$two_years_before';limit,100" --force | |
# Find all files with .sql extension in the current directory | |
files=$(find . -name "*.sql") | |
# Loop through each file | |
for file in $files; do | |
# Compress the file using bzip2 | |
bzip2 "$file" | |
done | |
echo "DONE!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment