Limit backup files

Thread Tools Search this Thread
# 1  
Limit backup files

Hello all,

I am building a shell script. Every morning my shell script will trigger an external system backup script and the backup file (File Name format: "20030929backup.bkp" (i.e)current date + "backup.bkp") will be stored in the backup directory. After successful back, I need to keep only 10 backup files in the backup folder at most. Say on 11th day, day 1 file should be deleted and the 11th day file should be created. What's the best way to do this?

I am using the below command to get the list of backup files from backup directory.
$ find /home/EBI -name "*.bkp" -exec ls {} \;

We need to calculate the calendar days.

I thought of using (-atime +10) but, the thing is this backup script will not run on Sundays. So we miss one day... I guess we may need to count the number of backup files, find the oldest one, delete it and add the current file. What's the simple way to do this?

# 2  
Try this:

rm `ls -tr *.bkp | head -1`
# 3  
But, how do I count 10 backup files? and if it exceeds 10 then your command will work to delete the oldest file.

# 4  
I thought that you wanted to delete the oldest file. At this point I don't know what you want. But I'll take a stab at this anyway...

You can count backup files with:
ls *.bkp | wc -l

And this technique will indeed work if you happen to have 10 backup files.
# 5  
Thanks Perderabo. It worked.
# 6  
Also, I am trying to send an e-mail notification at the end of this script and I am using

$ /usr/lib/sendmail -v < /home/lognotes.txt

How do I specify the subject field?

Also, Is there a way I can type the message body instead of sending the log file from the command itself. Just simple one line command with "Subject", "To", "message body"

I want to send an e-mail like this:
Subject: Notification
Message Body: Backup Success

Please help,

# 7  
You need to use a user agent rather than calling sendmail directly. Or you need to make your script smart enough to actually be a user agent.

You may have user agents named things like elm or mailx. I would use mailx and then the subject is specified with -s.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #12
Difficulty: Easy
CPU stands for 'Computer Processing Unit' and controls all of a computer's functions, acting as the brain(s) of computers.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Solaris 11 - opened files limit ?

Hey all, I'm running apache (cswapache2) on a Solaris 11.3 server. Recently, if I create a new vhost, the service fails to restart, and enters in maintenance mode. If I comment lines with log files, the service starts again. I guess I've reached the limit. I checked the current values... (8 Replies)
Discussion started by: omegared77
8 Replies

2. UNIX for Beginners Questions & Answers

Limit number of files transferred

I've a folder in remote server and it has 50 files. I like to transfer these files by first 10 and next 10 files. I'm using mget command to transfer the files. How to limit the file transfer limit to 10. instead of copying 50 files at a time. Thanks Janarthan (5 Replies)
Discussion started by: Janarthan
5 Replies

3. UNIX for Dummies Questions & Answers

Limit Number of files

hi guys how can i limit number of files in a disk or partition ? or how can i make a limit to inode number for a disk or partition ? ext3 or ext4 file system (1 Reply)
Discussion started by: mhs
1 Replies

4. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

5. UNIX Desktop Questions & Answers

limit number of sub-dirs searched for files

using: find . -type f -print|xargs -li "string", how do I limit the dated directories (2010-7-14, 2010-7-13,etc.) to just 2009 & 2010 years of directories to search. We go back to 2004 in our archives, way too many files. (3 Replies)
Discussion started by: MJThom713
3 Replies

6. Shell Programming and Scripting

Any limit on files

I am doing an ftp of around 1010 files and I am using mput for this. For some reason its only transferring 10 or 20 files and the rest are not getting transferred. There is some socket error in the log. is there an issue if we have more than 50 or so files for mput. here is the o/p in the log... (2 Replies)
Discussion started by: dsravan
2 Replies

7. Shell Programming and Scripting

how to limit files downloaded by wget

I am trying to download a page and retrieve only wav and mp3 files via wget. the website is: Alarm Sounds | Free Sound Effects | Alarm Sound Clips | Sound Bites my command is : wget -rl 2 -e robots=off -A wav,mp3 When not using the -A wav,mp3... (2 Replies)
Discussion started by: Narnie
2 Replies

8. UNIX for Dummies Questions & Answers

Size Limit for zip files

Hi, I am using the jar command to compress a directory. The size of the directory contents is 105 GB. The jar/zip that gets created is approximately 5.5 GB in size. But this file seems to be corrupt when verified using the unzip command. Is there any limitation for the size of the zip file?... (4 Replies)
Discussion started by: prafulasher
4 Replies

9. UNIX for Advanced & Expert Users

limit to number of files in a given directory

Everyone, We are on a unix AIX 4.3 platform and our application is written as such that all configuration files must reside in a specific directory. Currently there are over 10,000 files in this directory (and growing at about 300 per month). My question is is there a physical limit to the... (2 Replies)
Discussion started by: hedrict
2 Replies

10. UNIX for Dummies Questions & Answers

limit of files in the ufs filesystem

Hello ! Does anyone knows which de limit of files in the ufs filesystem in the Solaris 2.6 ?? Danke, Witt (2 Replies)
Discussion started by: witt
2 Replies

Featured Tech Videos