Help on Backing up all the files in the subdirectories under a parent directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help on Backing up all the files in the subdirectories under a parent directory
# 1  
Old 11-06-2012
Help on Backing up all the files in the subdirectories under a parent directory

Hi,

I am not too familiar with Unix scripting but I have to write code to find all the files under all the sub directories under a parent directory of unix location and move them to the corresponding Windows location.

For eg: I have \home\sreenu\Files\
Under neath this I have multiple sub directories such as:
Quote:
\home\sreenu\Files\MyFiles\archive
\home\sreenu\Files\MyFiles1\One\archive
\home\sreenu\Files\MyFiles2\archive
etc..
.

and I have the corresponding windows structure where I have the mount point created to access these locations from unix:

Quote:
\win001\bkp\Files\MyFiles\archive
\win001\bkp\Files\\MyFiles1\One\archive
\win001\bkp\Files\MyFiles2\archive
Please look into the code below:

Code:
export ALL_FILE_PATH="\home\sreenu\Files\";
export BKP_FILE_PATH="\win001\bkp\Files\";
export BKP_FILE_NAME="Backup_List.txt";

 find $ALL_FILE_PATH/ -mindepth 1 -type d | grep archive$ >> $ALL_FILE_PATH/$BKP_FILE_NAME;

cat $ALL_FILE_PATH/$BKP_FILE_NAME | while read line
do
cd $line;
if [ $(find . -maxdepth 1 -type f | wc -l) == "0" ]
then 
echo "no files";
else 
echo $line | sed -e "s/\$ALL_FILE_PATH/\$BKP_FILE_PATH/g"

Could you please help me as this is very urgent for me.

Awaiting your reply.

Regards,
Raj
# 2  
Old 11-06-2012
is there a reason you don't zip the whole file structure up and unzip it in windows?
# 3  
Old 11-06-2012
I have received the requirement this way. I am not sure with the zipping and unzipping whole of the structure in the Windows location.
# 4  
Old 11-06-2012
Using zip in Unix and then unzipping in Windows

It should work just fine... I would try that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

2. Shell Programming and Scripting

Find/searching files in subdirectories excluding the fiels in Parent Directory

Hi All, requirement is to find and remove the files from sub directories but it should exclude the files from parent directory. At present i am using the below one but it finds and remove files from both parent and sub directories. find ${PATH} -type f \( -name securitas\* -o -name \*gz... (1 Reply)
Discussion started by: Naveenkk
1 Replies

3. Shell Programming and Scripting

How to list all Subdirectories and files with its full path in a parent directory?

How to list all Subdirectories and files with its full path in a parent directory? (1 Reply)
Discussion started by: johnveslin
1 Replies

4. Shell Programming and Scripting

Find files only in current directory...not subdirectories

Hi, I have to find files only in the current directory...not in the sub directories. But when I use Find command ... it searches all the files in the current directory as well as in the subdirectories. I am using AIX-UNIX machine.Please help..I tried to use maxdepth..but it is not working in AIX. (2 Replies)
Discussion started by: vsachan
2 Replies

5. Shell Programming and Scripting

Bash: Gzip files in Directory and itīs Subdirectories

Hello dear Community, I have a task to wrtie a script which will gzip not zipped files in a directory and itīs subdirectories. I succeeded in gzippung the directory but not the subdirectories: #/bin/bash #go to the directory where to zip cd $1 #Zip unzipped files for i in `ls | xargs... (2 Replies)
Discussion started by: JamesCarter
2 Replies

6. UNIX for Dummies Questions & Answers

Listing files in a non-parent directory

Hi, Edit: The title should really read listing files in a non-parent directory, sorry! Im trying to get one of my Bash scripting assignments done for uni and now I'm stuck. This is probably going to be one of those kick yourself moments but, in my script I have a variable usrDir which... (2 Replies)
Discussion started by: Adzi
2 Replies

7. Shell Programming and Scripting

Replace a string in all files under a directory and its subdirectories

Hello Friends, I've been trying to write a script which finds a string and change it with another string. For this i want to search all files (with its arguments) under a spesific directory and its subdirectories. For example lets assume i want to replace an IP= 192.168.0.4 with another... (4 Replies)
Discussion started by: EAGL€
4 Replies

8. UNIX for Dummies Questions & Answers

Find Files in a Directory Excluding Subdirectories

Hi, I have a filename Location.txt in a directory /abc. Similar name file is present in its subdirectory /abc/xyz. I want to find the file which is present only in /abc and not in /abc/xyz. Please any1 of u can provide a quick suggestion. Its very urgent. Thanks, Amol (2 Replies)
Discussion started by: Amol_Dicholkar
2 Replies

9. UNIX for Dummies Questions & Answers

How to remove directory with subdirectories and files?

I'm trying to remove several directories which contains sun-dirs and files inside. I used the command rm -r <dirname> But, it always ask "examine file in directory <dirname> yes/no?" line by line. So, i need to write "y" for every line. How can i skip this step and remove all directories with... (9 Replies)
Discussion started by: ppa108
9 Replies

10. Shell Programming and Scripting

search files in a directory and its subdirectories

Hello my friends, I need to write a simple shell bad file :D that search and delete a file it's name 'Microsoft.txt' in the current directory and its subdirectories? So can you help to guide me how i can write this shell, Just give me the beginning :o thank you. (1 Reply)
Discussion started by: Net-Man
1 Replies
Login or Register to Ask a Question