Skip to content

Commit

Permalink
feat: add backups_cleanup.removal_rules_each_wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontalvo3 committed Dec 6, 2023
1 parent 0761b6b commit 6b69ef7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/roles/backups-cleanup/templates/backups-cleanup.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,32 @@
# change directory to backups location
cd {{ m_backups }}/{{ env }}

# remove all odd-numbered days (keep only even-numbered days)
# Apply backups cleanup rules at the backups+env root (without going into each wiki's directory)
# DEPRECATED:
# 1. Use method below going into each directory
# 2. This will eventually be removed, but not before providing some notification to users
{% if backups_cleanup.removal_rules is defined %}
{% for removal_rule in backups_cleanup.removal_rules %}
rm {{ removal_rule }} -f
{% endfor %}
{% endif %}

# compress all SQL files
# Apply backups cleanup rules for each wiki directory
{% if backups_cleanup.removal_rules_each_wiki is defined %}
# Loop over wiki directories
for dir in {{ m_backups }}/{{ env }}/*/
do
cd ${dir}
echo "Running backups cleanup rules for ${dir}:"
# Run removal rules like: rm $(ls -F *.sql | head -n -2) -f
{% for removal_rule in backups_cleanup.removal_rules_each_wiki %}
{{ removal_rule }}
{% endfor %}
cd ..
done
{% endif %}

# compress all SQL files following rule
{% if backups_cleanup.gzip_rules is defined %}
echo "gzip start time: $(date +\"%T\")"
{% for gzip_rule in backups_cleanup.gzip_rules %}
Expand Down

0 comments on commit 6b69ef7

Please sign in to comment.