I need a script to clean up the files on our backup system. I was hoping this would be simple for someone to put together for me.
I'm sure I could do it, but I'm a bash n00b so it would definitely not be efficiently or within a reasonable amount of time.
Requirements:
- Root of backups is at /var/backup
- We are to process any directory whose name matches "vid*", "pic*", "usr*","*bak", "*.bak". Ignore any other directories.
- Each directory is processed individually.
- We don't recurse into lower directories.
- We only want to process files whose name matches "*config", "*_bak", "*.cfg". Ignore any other files.
- Delete any file matching "*.tmp" that is older than 30 days.
For each matching directory we will:
- Identify the oldest file that matches the above file name requirements
- Compare the content of that file to all other files that match the file name requirements and delete any matches.
- Identify the next newest file that remains
- Repeat the process until all duplicates are removed.
- Finally delete any "*.tmp" files that are older than 30 days.
ALL HELP IS APPRECIATED!