[GH-ISSUE #877] Backup script keep x copies etc #551

Closed
opened 2026-03-02 02:17:12 +03:00 by kerem · 2 comments
Owner

Originally created by @silversword411 on GitHub (Dec 19, 2021).
Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/877

Originally assigned to: @silversword411 on GitHub.

Want to try and simplify the entire backup process that's officially supported.

Having script keep 7 daily, 4 weekly, and 6 monthly pruning as necessary seems like a nice default so backup folder won't grow forever.

Originally created by @silversword411 on GitHub (Dec 19, 2021). Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/877 Originally assigned to: @silversword411 on GitHub. Want to try and simplify the entire backup process that's officially supported. Having script keep 7 daily, 4 weekly, and 6 monthly pruning as necessary seems like a nice default so backup folder won't grow forever.
kerem 2026-03-02 02:17:12 +03:00
Author
Owner

@silversword411 commented on GitHub (Dec 19, 2021):

I think this will do it

for i in {0..7}; do ((keep[$(date +%Y%m%d -d "-$i day")]++)); done
for i in {0..4}; do ((keep[$(date +%Y%m%d -d "sunday-$((i+1)) week")]++)); done
for i in {0..12}; do
        DW=$(($(date +%-W)-$(date -d $(date -d "$(date +%Y-%m-15) -$i month" +%Y-%m-01) +%-W)))
        for (( AY=$(date -d "$(date +%Y-%m-15) -$i month" +%Y); AY < $(date +%Y); AY++ )); do
                ((DW+=$(date -d $AY-12-31 +%W)))
        done
        ((keep[$(date +%Y%m%d -d "sunday-$DW weeks")]++))
done
for i in {0..5}; do
        DW=$(date +%-W)
        for (( AY=$(($(date +%Y)-i)); AY < $(date +%Y); AY++ )); do
                ((DW+=$(date -d $AY-12-31 +%W)))
        done
        ((keep[$(date +%Y%m%d -d "sunday-$DW weeks")]++))
done
echo ${!keep[@]}

Will reassess in a couple weeks

<!-- gh-comment-id:997444943 --> @silversword411 commented on GitHub (Dec 19, 2021): I think this will do it ```bash for i in {0..7}; do ((keep[$(date +%Y%m%d -d "-$i day")]++)); done for i in {0..4}; do ((keep[$(date +%Y%m%d -d "sunday-$((i+1)) week")]++)); done for i in {0..12}; do DW=$(($(date +%-W)-$(date -d $(date -d "$(date +%Y-%m-15) -$i month" +%Y-%m-01) +%-W))) for (( AY=$(date -d "$(date +%Y-%m-15) -$i month" +%Y); AY < $(date +%Y); AY++ )); do ((DW+=$(date -d $AY-12-31 +%W))) done ((keep[$(date +%Y%m%d -d "sunday-$DW weeks")]++)) done for i in {0..5}; do DW=$(date +%-W) for (( AY=$(($(date +%Y)-i)); AY < $(date +%Y); AY++ )); do ((DW+=$(date -d $AY-12-31 +%W))) done ((keep[$(date +%Y%m%d -d "sunday-$DW weeks")]++)) done echo ${!keep[@]} ``` Will reassess in a couple weeks
Author
Owner

@wh1te909 commented on GitHub (May 27, 2023):

dingers changes should cover this

<!-- gh-comment-id:1565119313 --> @wh1te909 commented on GitHub (May 27, 2023): dingers changes should cover this
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tacticalrmm#551
No description provided.