Photo by Patrick Lindenberg / Unsplash

TIL - How to remove older backups from disk to save space

Today I Learned Oct 1, 2022

We keep database backups of a local monitoring system which grows twice in size every 2 months. Therefore, removing older backups is sometimes missed resulting in a shortage of disk space.

We keep the most recent files in a directory with the following shell script -

#!/bin/bash

/bin/ls -t /data/backups/*.sql.gz | tail +14 | xargs rm

Tags