The Spectrum backup directory is getting full and I need to delete or move backups more than 7 days old.
search cancel

The Spectrum backup directory is getting full and I need to delete or move backups more than 7 days old.

book

Article ID: 248436

calendar_today

Updated On:

Products

CA Spectrum DX NetOps

Issue/Introduction

The $SPECROOT/SS-DB-Backup directory has many backup files taking up a log of space. I need to be able to automatically either delete or move backups older than 7 days automatically.

Environment

Release : Any

Component : DX NetOps Spectrum General

Resolution

You can use the find command to find any backups files in the $SPECROOT/SS-DB-Backup directory and when found, execute a command on the file.

For example, the following find command can be used in a script to delete any file in the $SPECROOT/SS-DB-Backup directory. This example is assuming the $SPECROOT/SS-DB-Backup directory is /app/spectrum/SS-DB-Backup. You can modify it for your use:

find /app/spectrum/SS-DB-Backup/* -mtime +7 -exec rm {} \;

Or if you do not wish to remove the file but move the file, you can use the following (where /destination/directory/ is the directory you wish to move the file to):

find /app/spectrum/SS-DB-Backup/* -mtime +7 -exec mv "{}" /destination/directory/ \;

You can add these commands to a script or you can use cron on Linux to execute the command once a day.

Additional Information

References:

https://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/

https://serverfault.com/questions/505949/move-files-to-another-directory-which-are-older-than-a-date