I use the below script to backup some info on my Red Hat 7.2 box and place it to a mounted dir on my Win2k box.
The files are named with the creation date at the start like this:
2002_1005_030000_docs.tar.gz
What I want to be able to do is get the script to check the folder with the backups in it and delete any previous copies that are older than x days.
How do I do this?
Quote:
#!/bin/bash
# archives important files
clear
DATE=`date +%Y_%m%d_%H%M%S`
BACKUP_DOCS_NAME=$DATE"_docs.tar.gz"
echo Operation begun at $DATE
DOCS_DIR="/home/server/documents/"
ARCHIVE_DEST_DIR=/home/qoc-s/backup/
echo Files will be stored in $ARCHIVE_DEST_DIR
echo ===============================
echo
echo "tarring and gziping the files to $ARCHIVE_DEST_DIR$BACKUP from $DOCS_DIR"
tar -czf $ARCHIVE_DEST_DIR$BACKUP_DOCS_NAME $DOCS_DIR