shell scripting with directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell scripting with directory
# 1  
Old 01-08-2009
shell scripting with directory

I have a directory /ndata/nmk

I want to have 4 copies of my daily database backups like /ndata/nmk/copy1
/ndata/nmk/copy2 till copy4 .

where copy1-copy4 are directories having my db backups .

Once my db backups reach 4 directories like copy4 i want to again write from copy1 to copy4 .

basically i want to keep 4 copies of my db backups at any given time .

I want a script which will at least simulate the directory copy to 4 directories under /ndata/nmk .
# 2  
Old 01-08-2009
Quote:
cd /ndata/nmk/
mkdir new
cp db* new
rm -rf copy4
mv copy3 copy4
mv copy2 copy3
mv copy1 copy2
mv new copy1
This is just renaming the directories after the backups been taken. copy1 is always the latest and copy4 is the oldest.

Jerry
# 3  
Old 01-08-2009
shell scripting with directory

Jerry
This is what I need as part of a automated shell script .

I have a database backup script called eod.sh which backups the database and puts the directory named fullDB_timestamp to directory /ndata/nmk/backup.Its a cron job and creates the directory every midnight.

What I want is to have 4 diff copies of fullDB_timestamp i.e to have 4 consecutive days of backups under /nsdata/nmk .ie copy each days fullDB** under /ndata/nmk/backup to /nsdata/nmk/copy1-4 .On the fifth day it should overwrite the first and so on .

thanks
# 4  
Old 01-08-2009
I admit my solution doesn't do exactly what you want, but it does create 4 backups. Instead of overwriting 1 on the 5th day, 2 on the 6th day...1 again on the 33rd day etc, it simply creates copy1 which is yesterday's, copy2 for 2 days ago, copy3 for 3 days and copy4 for 4 days. copy5 is thrown away.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

2. Shell Programming and Scripting

Shell Scripting on files in directory

Hi, The requirement is below: There are 5 files in a unix directory and i need to pick up latest file from the directory that i can do like this ls -lrt | tail -1 and this file can be processed. now the actual requirement is some times what will happen the second third...on files i.e(ls -lrt... (4 Replies)
Discussion started by: prawinmca
4 Replies

3. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

4. UNIX for Dummies Questions & Answers

Extract directory name from the full directory path in UNIX using shell scripting

My input is as below : /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt /splunk/scrubbed/triumph/ifind.triumph.txt From the above input I want to extract the file names only . Basically I want to... (5 Replies)
Discussion started by: IshuGupta
5 Replies

5. Shell Programming and Scripting

how to find files and replace them in a directory in Shell scripting

I have a directory /java/unix/data In data directory i have so many files from which i want to find some files who look alike below.(there are number of such below such files as well different files too in the data directory) -68395#svg.xml -56789#ghi.xml -67894#gjk.org -56734#gil.txt I... (6 Replies)
Discussion started by: pratima.kumari
6 Replies

6. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

7. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

8. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

9. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

10. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
Login or Register to Ask a Question