SUM of Backup Files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SUM of Backup Files
# 1  
Old 08-11-2009
SUM of Backup Files

Hello Everyone,

I'm struggiling with backup issues and need to sum up sizes of backup files monthly and add the result to the next month's sum recursively.
For this i have a well working script that i modified as i showed below and this part gives the sum of the file sizes under working directory. Using this i want to add each months' SUM recursively. When the SUM reaches a spesific value like %70 and %90 of a size of a magnetic tape i should give a warning (email probably) and then the SUM will be reset to zero. How can i use the script in a loop, could u please help, im not used to Looping.

a=$`find . \( -name "*.tar" -o -name "*.gz" \) -mtime +1 -exec ls -l {} \;awk '/^-/ {total += $5} END {printf "%15.2f\n",total}'`
printf "SUM_OF_SIZE_OF_ALL_FILES=$a" >> SUM_OF_FILES.txt; 

### can i use the last part of the script again to sum up the every month's result by getting the result from recorded file by "cat"? ###

cat SUM_OF_FILES.txt > awk '/^-/ {total += $5} END {printf "%15.2f\n",total}'##as the sum value is in .txt the $5 part should be change as $0 or $1?##

if ["$a" -eq 50000000 ]; then ...
### i dont know how to calculate %70-90 of a value so i assigned a direct value here###

printf " ----ATTENTION!! 50 GBYTE or %70 of TAPE DRIVE IS FULL ----- ";

sendmail -bd .......

fi

if ["$a" -ge 70000000 ] ; then

printf " ----ATTENTION!! 70 GBYTE or %90 of TAPE DRIVE IS FULL ----- ";

sendmail -bd .......

$a == 0

fi


thanks in advanced..
# 2  
Old 08-12-2009
Code:
cat SUM_OF_FILES.txt > awk '/^-/ {total += $5} END {printf "%15.2f\n",total}'

What is the above line supposed to do?
Where you trying to do this?
Code:
cat SUM_OF_FILES.txt   |   awk '/^-/ {total += $5} END {printf "%15.2f\n",total}'
 
or may be this
 
awk '/^-/ {total += $5} END {printf "%15.2f\n",total}' SUM_OF_FILES.txt

Cannot go through you description.
Just post what does the file SUM_OF_FILES.txt contain.
As you use >>, I presume you must be having more than one line in it.
# 3  
Old 08-12-2009
Quote:
Originally Posted by edidataguy
Code:
cat SUM_OF_FILES.txt > awk '/^-/ {total += $5} END {printf "%15.2f\n",total}'

What is the above line supposed to do?
Where you trying to do this?
Code:
cat SUM_OF_FILES.txt   |   awk '/^-/ {total += $5} END {printf "%15.2f\n",total}'
 
or may be this
 
awk '/^-/ {total += $5} END {printf "%15.2f\n",total}' SUM_OF_FILES.txt

Cannot go through you description.
Just post what does the file SUM_OF_FILES.txt contain.
As you use >>, I presume you must be having more than one line in it.
first of all thanx for your replying,

With that line i want to fetch the last SUM value from SUM_OF_FILES.txt where I just want to save the monthly SUM results (but its not a must). In this txt file there will be each months sum results like
1515.45
1735.33
..
And as u said there will be many lines like above after appending each months sum to the txt file with ">>" so im not sure if awk can fetch the last line data from .txt file? if it's not possible then its not necessary to append monthly results to a new line. The worse I dont know how to use the last month's SUM ($a) in a comparison loop, thats poor that i coudlnt write a correct comparison loop Smilie

im sorry i forgot to tell very important point, im removing the back up files monthly from under the directory in which i wanna calculate the size of files under this directory. So assume that every month new backup data will be under the directory where i wanna use the script.

Last edited by EAGL€; 08-12-2009 at 04:40 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get CRC check sum of files in java EAR file without extracting .jar/.war files to disk.?

unzip -v gives CRC info of each file in a zip(in my case .EAR) file. # unzip -v my-application.ear Archive: my-application.ear Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ---- 197981 Defl:N 183708 7%... (1 Reply)
Discussion started by: kchinnam
1 Replies

2. Shell Programming and Scripting

Sum of numbers in three or more files

I have files : cat file1 15 88 44 667 33 4cat file2 445 66 77 3 56 (12 Replies)
Discussion started by: Natalie
12 Replies

3. Shell Programming and Scripting

Sum fields of different files using awk

I'm trying to sum each field of the second column over many different files. For example: file1: file2: 1 5 1 5 2 6 2 4 3 5 3 3 To get: file3 1 10 2 10 3 8 I found answer when there are only 2 files as... (10 Replies)
Discussion started by: rogeriog.em
10 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 for Dummies Questions & Answers

need [HELP] sum array multiple files

Hi.. I'm very newbie here.. I wonder if somebody can help me.. I have multiple directories with same out file name for each directories.. ./dirA/out.dat ./dirB/out.dat ./dirC/out.dat ..and so on.. for ./dirA/out.dat here is the structure content : for ./dirB/out.dat the same... (4 Replies)
Discussion started by: agiantz
4 Replies

6. Shell Programming and Scripting

need [HELP] sum array multiple files

Hi.. I'm very newbie here.. I wonder if somebody can help me.. I have multiple directories with same out file name for each directories.. ./dirA/out.dat ./dirB/out.dat ./dirC/out.dat ..and so on.. for ./dirA/out.dat here is the structure content : for ./dirB/out.dat the same... (6 Replies)
Discussion started by: agiantz
6 Replies

7. Shell Programming and Scripting

Sum Numbers from different files

Hi All, I need to print the sum of numbers from different files. Input files: file1.out 10 20 30 file2.out 10 20 30 (5 Replies)
Discussion started by: saint2006
5 Replies

8. Shell Programming and Scripting

sum the columns of files

I have several csv files like this: file1.csv 1 12 1 2 8 9 3 9 2 4 5 9 ... file2.csv 1 0 1 2 2 3 3 4 1 ... file3.csv 1 0 1 2 4 0 ... I want the result like this 1 12 3 2 14 12 3 13 3 (10 Replies)
Discussion started by: frewise
10 Replies

9. Shell Programming and Scripting

How to sum 2 files?

i have arq1.txt , like this: 1 2 3 4 5 and another arq2.txt 1 2 3 4 5 how to make this: 2 4 (8 Replies)
Discussion started by: beandj
8 Replies

10. Shell Programming and Scripting

how to sum values from 2 different files?

Hi I am trying to add count values from two different files into one file. Could any body please suggest me best command to do this? My problem was as follows: a.txt b.txt c.txt 10 20 30(needed) i tried cat a.txt b.txt > c.txt (its not adding the values) Thanks in advance.. Praveen (8 Replies)
Discussion started by: npk2210
8 Replies
Login or Register to Ask a Question