Sponsored Content
Operating Systems HP-UX Recursive copy of Folders with files Post 302916165 by mhbd on Monday 8th of September 2014 01:57:21 AM
Old 09-08-2014
Hello Guys, thanks for your comments and suggestions.

Here is the current situation. I tried the command mentioned below in our test server which has same

folders structure as LIVE:

Code:
#tar cvpf - fd*/reports | { cd test-copy/ && tar xvpf - ; }

It worked fine. It copied all folders and sub-folders with files with original owner & permission at

once in a signle command. But we don't want to run this command in our LIVE server as the folders & files size is 1200GB involving millions of files and it may fail.

So, I tried to copy folders & files year-wise with following command:

Code:
#tar cvpf - fd*/reports/*2003* | { cd test-copy/ && tar xvpf - ; }

It copied all folders and sub-folders with files of year 2003, size is matching with source but owner &

permission changed i.e. not same as source. It seems to me that the tar command could not keep owner &

permission same as original when I put 2 arguments in the command one is fd* and another is /*2003*

I searched man tar but no clue found.

Note: each parent folder's owner is different. I am running the tar command from root user.

Our source directories are as follows:

Code:
/SQArun>ls -ltr fd000001 fd000010 fd000011

fd000010:
total 88
drwxrwx---   2 fq000010   dsqarun      24576 Jul 20 14:24 bills
drwxrwx---  759 fq000010   dsqarun      20480 Aug 27 13:01 reports

fd000011:
total 72
drwxrwx---   2 fq000011   dsqarun      16384 Sep 10  2013 bills
drwxrwx---  760 fq000011   dsqarun      20480 Aug 27 14:36 reports

fd000001:
total 104
drwxrwx---   2 fq000001   dsqarun      32768 Jul 20 14:24 bills
drwxrwx---  760 fq000001   dsqarun      20480 Aug 27 13:01 reports
/SQArun>

[/ICODE]There are many fd* folders which generated sequentially and total 800+ folders. 

[ICODE]/SQArun/fd000001/reports>ls -ltr -d *2003*
drwxrwx---   2 fq000001   dsqarun         96 May 31  2003 01-31-MAY-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun  2  2003 01-01-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun  2  2003 01-02-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun  4  2003 01-03-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun  4  2003 01-04-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun  9  2003 01-05-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun  9  2003 01-07-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun  9  2003 01-08-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun  9  2003 01-09-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun 10  2003 01-10-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun 11  2003 01-11-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun 12  2003 01-12-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun 14  2003 01-14-JUN-2003
drwxrwx---   2 fq000001   dsqarun         96 Jun 15  2003 01-15-JUN-2003
.
.
.
/SQArun/fd000001/reports>

In this fd000001 folder there are many such date folders where last 4 digits is year and ranging from year 2003 to 2014

Any further suggestions will be appreciated.

Thanks

Last edited by vbe; 09-08-2014 at 08:53 AM.. Reason: code tags please not ICODE!
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

recursive copy of hidden files

I need to know how to copy hidden files recursively? cp -r sourceDir/* targetDir/. ignores the hidden files. Thank you!! (2 Replies)
Discussion started by: usfrog
2 Replies

2. UNIX for Dummies Questions & Answers

copy all files and folders and cjange or remove ownership

So tried: cp -r -p test1/ user@machine:///srv/www/vhosts/domain.co.uk/httpdocs/backup/ but this didn't work either :( Anyone able to help with this? Many thanks Mr M (3 Replies)
Discussion started by: misterm
3 Replies

3. Shell Programming and Scripting

copy some files from users home folders to my folder

i have users home directories in /home all the users have some files starting with character e and i want to copy all these files in a folder in my (root) home using a script i tried the script for i in m5 do cd m5 cp e1* /home/pc/exam cd .. done but get these... (3 Replies)
Discussion started by: pcrana
3 Replies

4. Shell Programming and Scripting

I need script Copy permissions of files and folders from one server to another

Hi.. I have 2 servers with linux suse10. I made a mistake and on one of the servers changed with chmod the permission of root in directory /. In the other servers the permissions are correct Please i need a script, to change the permissions of one server 1, using the same permission of the... (11 Replies)
Discussion started by: ave-phoenix
11 Replies

5. Windows & DOS: Issues & Discussions

Windows mass copy files with same name in differnt folders

I have files existing with same names in the folders with date as display below c:\2010-09-10 <==== folder arr1.jpg arr2.jpg arr3.jpg arr4.jpg c:\2010-09-09 <==== folder arr1.jpg arr2.jpg c:\2010-09-08 <==== folder arr2.jpg arr3.jpg arr4.jpg ... (5 Replies)
Discussion started by: jville
5 Replies

6. Shell Programming and Scripting

recursive saving of files and folders

Hi all I have a bash script, that loops through a folders files and all subfolders for .shtml files. It looks for a string and replaces it, creating a backup of the original file. This all works great, but I'd like, when the backup is done, that the files are then also created in their... (4 Replies)
Discussion started by: terrid
4 Replies

7. UNIX for Dummies Questions & Answers

copy mutilple files to mutiple folders

Hi, I just started to learn shell progamming and just can't get my head around the following problem. I need to do the following: I have a folder which contains 100+ subfolders. Inside these subfolders there is one folder named 'Morph' and several jpg's. I need to copy all the files into... (4 Replies)
Discussion started by: M474746
4 Replies

8. Shell Programming and Scripting

Loop folders, delete files, copy new ones

Folks, I am hopeful that you may be able to help me out with writing a script that can be run nightly (as cron?) to loop through all subfolders within the "/media" directory, delete all of the files in each of them, and then copy in all of the files from the "/home//sansa" directory to each of... (6 Replies)
Discussion started by: acraig
6 Replies

9. Shell Programming and Scripting

Recursive search for files and copy to new directories

So I have extremely limited experience with shell scripting and I was hoping someone could point out a few commands I need to use in order to pull this off with a shell script like BASH or whatnot (this is on OS X). I need to search out for filenames with account numbers in the name itself... (3 Replies)
Discussion started by: flyawaymike
3 Replies

10. Shell Programming and Scripting

How to copy files/folders and show the files/folders?

Hi, So i know we use cp -r as a basic to copy folders/files. I would like this BUT i would like to show the output of the files being copied. With the amazing knowledge i have i have gone as far as this: 1) find source/* -exec cp -r {} target/ \; 2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies
All times are GMT -4. The time now is 07:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy