Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/scripts/cleanup_backups.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
# Remove the old backups; run by the uwsgi cron.
# Kept out of uwsgi.ini, where uwsgi would expand the "%" magic variables (%p is the ini path).
DIR=${1:-/backup_restore}

# backup files older than 30 days, except the most recent 3 (a backup is composed by 3 files)
find "$DIR" -maxdepth 1 -type f -mtime +30 -printf '%T@ %p\n' | sort -n | head -n -3 | cut -d' ' -f2- | xargs -r -d '\n' rm -f --

# backup directories older than 30 days, never DIR itself
find "$DIR" -mindepth 1 -maxdepth 1 -type d -ctime +30 -exec rm -rf {} +
5 changes: 2 additions & 3 deletions src/uwsgi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ cheaper-busyness-backlog-step = 2 ; How many emergency workers to create if t

# cron = -1 -1 -1 -1 -1 sh -c 'django-admin collect_metrics -n -t xml';
# cron = 0 0 -1 -1 -1 sh -c 'find /backup_restore/ -type f -mtime +30 -exec rm -f {} \;'
# Remove backup files older than 30 days except the most recent 3 files (a backup is composed by 3 files)
cron = 0 0 -1 -1 -1 sh -c 'find /backup_restore/ -maxdepth 1 -type f -mtime +30 -printf "%T@ %p\n" | sort -n | head -n -3 | awk "{ print $2 }" | xargs -r rm'
cron = 0 0 -1 -1 -1 sh -c 'find /backup_restore/ -type d -ctime +30 -exec rm -rf {} \;'
# Remove backups older than 30 days (see the script; never put "%" here: uwsgi expands it)
cron = 0 0 -1 -1 -1 sh /usr/src/project/scripts/cleanup_backups.sh
Loading