Tar and un-tar issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tar and un-tar issue
# 1  
Old 09-25-2014
Question Tar and un-tar issue

In AIX 5.3,

I have these directories:
HTML Code:
/lms
/lms/w_standard
/lms/d_admin
/lms/b_common
/lms/b_prodbus
/lms/d_prod
/lms/d_prod/ccldir
/lms/d_prod/ccluserdir
/lms/d_prod/config
/lms/d_prod/data
/lms/d_prod/log
/lms/d_prod/ocd
/lms/d_prod/print
/lms/d_prod/temp
/lms/reg
/lms/w_standard/prod_wh
and I want to make a tarball for only these directories, and move the tarball to another AIX node (AIX 6.1) and un-tar so that I can keep the exact directories and contents on the AIX 6.1 node.

Can you please advise on
1) how to make a tarball for only these specific directories and their sub-directories
2) how to un-tar the tarball so that it doesn't create duplicate directories on the target AIX node?

Appreciate it!
# 2  
Old 09-25-2014
I am a little confused by your showing /lms and then some subdirectories originated in /lms. So, you do not want ALL files in /lms directory? If this is the case then I'd do following:

Code:
 cd /lms
 tar cvf your_tarball_file_name \
 w_standard \
d_admin \
b_common \
b_prodbus \
d_prod \
d_prod/ccldir \
d_prod/ccluserdir \
d_prod/config \
d_prod/data \
d_prod/log \
d_prod/ocd \
d_prod/print \
d_prod/temp \
reg \
w_standard/prod_wh

This command will place all files from subdirectories specified into a tarball. Copy it to the target machine and extract from it as follows:
Code:
 cd /your/target/folder
 tar xvf your_tarball_file_name

# 3  
Old 09-25-2014
Quote:
Originally Posted by migurus
I am a little confused by your showing /lms and then some subdirectories originated in /lms. So, you do not want ALL files in /lms directory? If this is the case then I'd do following:
migurus,

Some of /lms' sub-directories are mounted. That is why you are seeing the mounted /lms/* directories.
I DO want all of the directories, their sub-directories, and all contents. I want to make everything into a tarball, and un-tar onto the target node.

Quote:
Originally Posted by migurus
cd /your/target/folder
tar xvf your_tarball_file_name
Here, what would be the /your/target/folder? The target AIX node has the same directory structure as the source. So, /your/target/folder would be /lms, or just / ?

Please advise.
# 4  
Old 09-26-2014
Yes, cd /lms on your target system
# 5  
Old 09-26-2014
You can use absolute PATH with Unix tar:
Code:
tar cvf lms.tar \
/lms/w_standard \
/lms/d_admin \
/lms/b_common \
/lms/b_prodbus \
/lms/d_prod \
/lms/d_prod/ccldir \
/lms/d_prod/ccluserdir \
/lms/d_prod/config \
/lms/d_prod/data \
/lms/d_prod/log \
/lms/d_prod/ocd \
/lms/d_prod/print \
/lms/d_prod/temp \
/lms/reg \
/lms/w_standard/prod_wh

and on the destination node
Code:
tar xvf lms.tar

If you have ssh you can do it in one stroke:
Code:
tar cvf - \
/lms/w_standard \
/lms/d_admin \
/lms/b_common \
/lms/b_prodbus \
/lms/d_prod \
/lms/d_prod/ccldir \
/lms/d_prod/ccluserdir \
/lms/d_prod/config \
/lms/d_prod/data \
/lms/d_prod/log \
/lms/d_prod/ocd \
/lms/d_prod/print \
/lms/d_prod/temp \
/lms/reg \
/lms/w_standard/prod_wh | ssh destination_node tar xf -

---------- Post updated at 02:14 PM ---------- Previous update was at 01:55 PM ----------

Another method
Code:
find /lms -xdev -print

If this shows the correct files, transfer them with cpio like this
Code:
find /lms -xdev -print | cpio -o | ssh destination_node cpio -idm


Last edited by MadeInGermany; 09-26-2014 at 04:03 PM.. Reason: corrected the file list
# 6  
Old 09-26-2014
Quote:
Originally Posted by MadeInGermany
You can use absolute PATH with Unix tar:
Code:
tar cvf - \
/lms/w_standard \
/lms/d_admin \
/lms/b_common \
/lms/b_prodbus \
/lms/d_prod \
/lms/d_prod/ccldir \
/lms/d_prod/ccluserdir \
/lms/d_prod/config \
/lms/d_prod/data \
/lms/d_prod/log \
/lms/d_prod/ocd \
/lms/d_prod/print \
/lms/d_prod/temp \
/lms/reg \
/lms/w_standard/prod_wh | ssh destination_node tar xf -

I have ssh set up between the two nodes, so I prefer this method.
I don't see the parent directory /lms on the command line.
What do we do with /lms ? Please advise.
# 7  
Old 09-26-2014
It will create the needed /lms but maybe not with the original permissions (because they are not present in the tar file).
The cpio method will transfer the correct permissions for /lms.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Tar - pre-checking before making the Tar file

Coming from this thread, just wondering if there is an option to check if the Tar of the files/directory will be without any file-errors without actually making the tar. Scenario: Let's say you have a directory of 20GB, but you don't have the space to make Tar file at the moment, and you want... (14 Replies)
Discussion started by: filosophizer
14 Replies

2. AIX

Making Tar of directory and tar file is going to be placed

Quick question, is it possible to make a Tar of completely directory and placing the tar file in it (will this cause even the tar file to tarred ?) sample: /opt/freeware/bin/tar -cvf - /oracle | gzip > /oracle/backup.tgz will the tar file backup.tgz also include backup.tgz ? i tried... (5 Replies)
Discussion started by: filosophizer
5 Replies

3. UNIX for Dummies Questions & Answers

Do I need to extract the entire tar file to confirm the tar folder is fine?

I would like to confirm my file.tar is been tar-ed correctly before I remove them. But I have very limited disc space to untar it. Can I just do the listing instead of actual extract it? Can I say confirm folder integrity if the listing is sucessful without problem? tar tvf file1.tar ... (1 Reply)
Discussion started by: vivien_chu
1 Replies

4. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

5. Shell Programming and Scripting

tar command dont tar to original directory

HI, if I have a tarfile called pmapdata.tar that contains tar -tvf pmapdata.tar -rw-r--r-- 0/0 21 Oct 15 11:00 2009 /var/tmp/pmapdata/pmap4628.txt -rw-r--r-- 0/0 21 Oct 14 20:00 2009 /var/tmp/pmapdata/pmap23752.txt -rw-r--r-- 0/0 1625 Oct 13 20:00 2009... (1 Reply)
Discussion started by: borderblaster
1 Replies

6. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

7. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

8. UNIX for Advanced & Expert Users

Tar utility (untar a .tar file) on VxWorks

Hi All Can someone pls guide me if there any utility to compress file on windows & uncompress on vxworks I tried as - - compressed some folders on windows ... i created .tar ( to maintain directory structure ) and compressed to .gz format. - on VxWorks i have uncompressed it to .tar... (1 Reply)
Discussion started by: uday_01
1 Replies

9. UNIX for Advanced & Expert Users

Does tar do crc checking on a tape or tar file?

Trying to answer a question about whether tar table-of-contents is a good tool for verifying tape data. (1 Reply)
Discussion started by: tjlst15
1 Replies
Login or Register to Ask a Question