LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-09-2004, 08:54 AM   #1
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Rep: Reputation: 50
need shell backup sript


hello all,
i have a win2k server and linux (redhat 8.0) box. A database service runs in win box and it backups data everyday.
i m wanted to copy that files that in win2k server to linux box. so i think that i will have to use smbfs to get files. but i am also wanted to delete old backups which are located in windows, keeping last 7 backup files then send mail to someone about the result of backup. i know a little about bash shell. i can delete than 7 days old files by checking modify time like that:
$find /mnt/backup -mtime +7 -type f -exec rm -f -- {} \;
but i must delete older files than last 7 backup files. if a trouble occur copying backup files, all of backup files can be deleted. im stuck here. i think i can do sending mails and other things.
anyone can help me pls?

thnx..
 
Old 10-09-2004, 11:49 AM   #2
rkmalik
LQ Newbie
 
Registered: Oct 2004
Location: UK
Posts: 13

Rep: Reputation: 0
Q?

Sorry what was the question ?
 
Old 10-12-2004, 10:54 AM   #3
maxut
Senior Member
 
Registered: May 2003
Location: istanbul
Distribution: debian - redhat - others
Posts: 1,188

Original Poster
Rep: Reputation: 50
i solved the trouble myself here it is. maybe someone will need it

it checks gbk files in source dir, and deletes olders by modifying time if there are more than 7 gbk files

Code:
source_dir=/path/to/gbk/files
file_q=$(ls $source_dir|grep -ci ".gbk$")

if [ $file_q -gt 7 ] ; then
let fark=$file_q-7
while [ ! $fark = 0 ] ; do
sil=$(ls -rt1 $source_dir|grep -i ".gbk$" -m 1)
rm -f $source_dir/$sil
let fark=fark-1
done
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup software (using shell) essdeeay Linux - Software 2 11-01-2005 05:51 AM
Shell Script for backup BBQ_Matt Linux - Software 7 06-30-2005 05:19 PM
Incremental Backup shell script. datadriven Linux - General 3 06-02-2004 09:19 AM
writting a backup shell script yenonn Slackware 2 03-18-2004 07:49 PM
execute sript? cloids Linux - Software 1 01-15-2004 01:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration