DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: copy whole directories and subdirs in UNIX

  1. #1
    Join Date
    Oct 2000
    Posts
    56
    This is off t he subject ..
    i'm trying to do a whole archive and i can't remember what the command is the copy a whole dir including subdirs.

    i know it's something like tar cvf /dev/mt /bin

    but it doesn't seem to make a copy of the whole subdirs.. instead it copies it all to the /dev/mt .. with no sub dirs??
    please help

  2. #2
    Join Date
    Jul 2000
    Posts
    147
    did you try ....
    tar cvf /dev/mt /bin/*


  3. #3
    Join Date
    Oct 2000
    Posts
    56
    it comes up with the same thing...it copies all the subdirs and folds into a file . instead of making addtional subdirs. / and copying directory structures

  4. #4
    Join Date
    Jul 2000
    Posts
    147
    if you are archiving to a tape...
    tar -cvf /dev/rmt/0

    Reading from tape.....
    tar -tvf /dev/rmt/0

    restore for tape....
    tar -xvfw /dev/rmt/0

    hope this is what you are looking for...


  5. #5
    Join Date
    Oct 2000
    Posts
    56
    tar -cvf /dev/rmt/0
    i'm archiving from tape.


    when i try this:
    tar -cvf /usr01/dbs/HOU_TRIU_ARCHIVE/SAP2/CREATE /usr/oracle/dba/SAP2/create/
    i get tar: /usr01/dbs/HOU_TRIU_ARCHIVE/SAP2/CREATE: Is a directory

    so i try
    cvf /usr01/dbs/HOU_TRIU_ARCHIVE/SAP2/CREATE/test /usr/oracle/dba/SAP2/create/
    (adding test ) to the end of my CREATE dir

    then i look under the
    /usr01/dbs/HOU_TRIU_ARCHIVE/SAP2/CREATE
    and there is a file called test .. file not a dir
    when i do a vi on it... it gives me all of the stuff that was in the orginal dir... but not in subdirs...or files... but everything is embedded into one file.

  6. #6
    Join Date
    Jul 2000
    Posts
    147
    i'm not sure what is the problem...here is few example from the answerBook.....

    EXAMPLES



    Example 1 - Using the tar Command to Create an Archive of Your Home Directory

    The following is an example using tar to create an archive of your home directory on a tape mounted on drive /dev/rmt/0:

    example% cd
    example% tar cvf /dev/rmt/0 .
    messages from tar


    The c function letter means create the archive; the v function modifier outputs messages explaining what tar is doing; the f function modifier indicates
    that the tarfile is being specified ( /dev/rmt/0 in this example). The dot (.) at the end of the command line indicates the current directory and is the
    argument of the f function modifier.

    Display the table of contents of the tarfile with the following command:

    example% tar tvf /dev/rmt/0



    The output will be similar to the following for the POSIX locale:

    rw-r--r-- 1677/40 2123 Nov 7 18:15 1985 ./test.c
    . . .
    example%



    The columns have the following meanings:

    column 1 is the access permissions to ./test.c

    column 2 is the user-id/group-id of ./test.c

    column 3 is the size of ./test.c in bytes

    column 4 is the modification date of ./test.c. When the LC_TIME category is not set to the POSIX locale, a different format and date order field may be
    used.

    column 5 is the name of ./test.c

    To extract files from the archive:

    example% tar xvf /dev/rmt/0
    messages from tar
    example%



    If there are multiple archive files on a tape, each is separated from the following one by an EOF marker. To have tar read the first and second archives from a
    tape with multiple archives on it, the non-rewinding version of the tape device name must be used with the f function modifier, as follows:

    example% tar xvfp /dev/rmt/0n read first archive from tape
    messages from tar example% tar xvfp /dev/rmt/0n read second archive from tape
    messages from tar example%



    Note that in some earlier releases, the above scenario did not work correctly, and intervention with mt(1) between tar invocations was necessary. To emulate the
    old behavior, use the non-rewind device name containing the letter b for BSD behavior. See the Close Operations section of the mtio(7I) manual page.




    Example 2 - Using Tar To Archive Files From /usr/include And From /etc To Default Tape Drive 0:

    To archive files from /usr/include and from /etc to default tape drive 0:

    example% tar c -C /usr include -C /etc .


    The table of contents from the resulting tarfile would produce output like the following:

    include/
    include/a.out.h
    and all the other files in /usr/include . . .
    ./chown and all the other files in /etc


    To extract all files in the include directory:

    example% tar xv include
    x include/, 0 bytes, 0 tape blocksand all files under include . . .






  7. #7
    Join Date
    Nov 2000
    Posts
    245
    tar -cvf /usr01/dbs/HOU_TRIU_ARCHIVE/SAP2/CREATE /usr/oracle/dba/SAP2/create/

    seems you use TAR to archive file disk to disk not to tape.
    if you tar file(s) disk to disk, you need idetify the "result" file
    not a directory, in your case it should be

    tar -cvf testdiskfile /usr/oracle/dba/SAP2/create/

    all files under create/ will compress into a signel file testdiskfile

    if you want COPY files from one directory tree to another directory with the same tree structure, you should use "cp"


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width