How to automatically delete old backups


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to automatically delete old backups
# 1  
Old 01-08-2010
How to automatically delete old backups

I'm creating nightly backups using cygwin bash with this one line script:

zip -r "K:/backup/outlook/`date "+%y%m%d%M"`" C:/Documents\ and\ Settings/siegfried/Local\ Settings/Application\ Data/Microsoft/Outlook

How can I enhance my script using the "rm" command so I never have more than 4 zip files and the oldest is deleted?

I could use the cygwin bash "find" command to delete files older than four days, but this is not what I want (what if I miss doing backup one day or several days? I would not want to loose all my backups if I failed to do it regularly).

Also, is there any way to write a bash script that will kill the outlook process that locks these files? Hmmm... that may be more of a windows question that is more appropriate for a different forum...

Thanks,
Siegfried


Thanks,
siegfried
# 2  
Old 01-08-2010
In Debian we have logrotate, which does the task of what you are speaking.

Is that is available in Cygwin ? or Any equivalent ?!
# 3  
Old 01-11-2010
I believe there is such a utility and I looked into it previously. The problem was that it was specific to htpd.

How do I delete only the last line a a file? I suppos I could write a perl one-liner.

Assuming each log file name was a date, then I could call "ls | sort" and then how would I delete only the file whose file name that was last in the file?

Thanks,
siegfried
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete log files automatically.

Here is the script I want to run to deleted log files after a certain time: touch /usr/WebSphere/AppServer/profiles/AppSrv01/apps/RSA/logs find /usr/WebSphere/AppServer/profiles/AppSrv01/apps/RSA/logs -atime +120 - exec rm -rf {}\; Exerytime I run it, it throws me the error: find: paths must... (2 Replies)
Discussion started by: lennyz04
2 Replies

2. UNIX and Linux Applications

Oracle 9i - Backups

Is there a way to backup an Oracle 9i database without the use of OEM and OMS? (1 Reply)
Discussion started by: adelsin
1 Replies

3. Shell Programming and Scripting

How to set delete Key to erase automatically

We need to su to root in 1000 systems, so it is almost impossible to add "stty erase ^H" to every .profile on these systems. Is there any way to set delete key to erase automatically after running "su -"? Thanks :) (4 Replies)
Discussion started by: aixlover
4 Replies

4. Shell Programming and Scripting

Script to delete logs or take backups under specific user

I have to write a shell script like this-- 1) Utility will be run under the directory owner. 2) This utility will clean files in ABC/logs. And following logs will be backed up or deleted. Dispatcher Logs Middle tier Logs Sage log Sage monitor log Sage db clean up result log Core files ... (12 Replies)
Discussion started by: namishtiwari
12 Replies

5. UNIX Desktop Questions & Answers

Backups too CD

I've been handed the task of backing up some of our system files on a Solaris box. No probs. Zipped the logs that needed backing up but my superiors do not want it on tape, they want it spanned on CD's. The CD-Writer is available on a MS box. FTP'd the zipped logs across too the MS Machine but now... (1 Reply)
Discussion started by: mccrack_2003
1 Replies

6. UNIX for Advanced & Expert Users

backups in background

Hi, how i can do background backup process in Unix?? I has Solaris Operating System. very much thanks!! (4 Replies)
Discussion started by: jairog
4 Replies

7. UNIX for Dummies Questions & Answers

Backups.

Hello everyone my ? is about backups. I'am running SCO OS 505 and currently backing up the hole HD. Well the back up is taking too long and this is becoming a problem for the users since we are a 24-7 bussines, I whant stop backing up every thing on the HD. What are the most important files and... (1 Reply)
Discussion started by: kikkin
1 Replies

8. UNIX for Dummies Questions & Answers

backups

When using hostdump.sh to backup a system I can do it fine. But how can I restore what I backuped up? :) Thx in advance (2 Replies)
Discussion started by: merlin
2 Replies

9. Filesystems, Disks and Memory

Backups

I have been using the hostdump.sh backup script for over a year now and have recently run into a problem. I'm now getting the following error at the end of my jobs; /bin/mt -f: error fsf'ing tape. This script uses the native 'ufsdump'. So, I try to go back and read the last dump on the tape... (11 Replies)
Discussion started by: Solaris
11 Replies
Login or Register to Ask a Question