Linuxathome.net

Linux news and help for home broadband internet users
It is currently Mon Jul 24, 2017 9:33 pm

All times are UTC + 10 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Oct 05, 2002 3:46 pm 
Offline
Newbie

Joined: Fri Aug 02, 2002 5:58 pm
Posts: 2
Location: Townsville, NQLD
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 07, 2002 2:23 am 
Offline
Newbie

Joined: Sun Jun 30, 2002 10:51 am
Posts: 24
Location: /dev/null
easiest way is to let find do all the work:

find /home/qoc-s/backup/ -name '20*' -mtime 7 -exec rm -rf {} \;

I think that's the right syntax...it should kill any file older than 7 days.

edit: for some reason it won't let me put a plus sign in my post. there should be a plus sign before the 7.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 10 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group