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:
#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:
#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:
/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>
There are many fd* folders which generated sequentially and total 800+ folders.
/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