Using tar to move directories


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using tar to move directories
# 1  
Old 06-18-2013
[Solved] Using tar to move directories

I have figured out how to create a tar file that holds all the files in a particular directory. The plan is to move the tar to a new system via FTP so that we can test the new system with our files and libraries. What I can't figure out is how to unzip the tar file; I keep getting messages that have to do with file permissions and time/date stamps. I have full read/write/execute access to these files, so I'm not sure what is happening. So my question is this, once I figure out the permission problem, when I unzip a tar file (in this case a directory of files), how do I determine where the resulting unzipped files will go? I've seen many examples, but it seems that they unzip where the .tar file is located - is this true? Is there an easier way to move many files from one system to another, other than using tar? I'm not very knowledgeable regarding Unix commands, so I apologize if this is a menial question. As always, any help is appreciated.
# 2  
Old 06-19-2013
Okay, so a few questions:-
  • How did you create your tar file?
  • Did you specify a full path for the files or relative to where you were?
  • Which account are you running as at the time (output from id would be good)
  • How did you move the file?
    If it's a plain FTP, it may be better to compress the file and binary FTP it.
    Code:
    compress my.tar
    ftp target
    .....credentials bit.....
    bin
    put my.tar.Z

    On the target server you would then have to uncompress it, either with
    Code:
    uncompress my.tar
    tar -xvf my.tar

    or
    Code:
    zcat my.tar.Z | tar -xvf -

  • On the target server, what account are you running as, again output from id would be useful.
    Who owns the files on the source server (user id number is the critical bit)
  • Can you list the permissions of the directories that these files will be extracted to with ls -ld dir

The more clues you can give us, the better.



Thanks, in advance,
Robin
Liverpool/Blackburn
UK
This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 06-19-2013
To create the .tar file, I was in a temp directory and ran the following:
Code:
'tar -cvf myfile.tar /pulsar/paysrc/libsrc'

Then, viewing the tar using
Code:
'tar tvf myfile.tar'

I see that all the contents of libsrc...as an example:
Code:
'-rw-rw-r-- 203 224     521 Jun 10 10:57:17 2002 /pulsar/paysrc/libsrc/exists_file.c
'

So, I will then need to FTP myfile.tar from Unix to my pc and then to a remote Unix server where it will need to be extracted. I am thinking that, since the path is included, it will attempt to extract to the original directory (/pulsar/paysrc/libsrc)...but I am not clear on this. If this is true, then will the directory tree be created or will we have to make the appropriate directories first?

Just for further info - we are testing an upgrade to our Unix server and to the latest version of AIX and the whole purpose of this is to see if all our programs (some of which are very old) will run on the new system. Programs are written in C and in Fortran as well as some shell scripts. The new server is not in-house, but rather is being provided remotely for our testing.

Hope this makes a bit more sense.
# 4  
Old 06-19-2013
Since you archived using absolute path, it will recreate that very same structure from root (or use what it finds if tree exist...)
You didnt say what you are migrating from... ( Is it an old RS6000 ?) what OS and version?
This User Gave Thanks to vbe For This Post:
# 5  
Old 06-19-2013
rbatte1 asked what the id on the target system is...

uid=0(root) gid=0(system) groups=2(bin),3(sys),7(security),8(cron),10(audit),11(lp)

and the permission in the target directory (as well as sub-directories) is...

drwxr-xr-x 7 root system 256 Jun 13 07:36 paysrc

In response to vbe: we are migrating from AIX version 5.3 to 7.1
# 6  
Old 06-19-2013
Thats not so old so all should work... I was expecting aix 4.3 ( I still have a few 4.2.1 boxes running with no hope of migration... they will die when new applications will be finished..)

The ksh has not the same behaviour. in 7.1... You may need to modify some scripts ( I cant rememeber now what it was...) it has to do with test conditions and the man page of aix was of no help... ( I migrated last year server from 6.1 to 7.1 and had some scripts failing...)
# 7  
Old 06-19-2013
@vbe, that is certainly good information. Do you happen to know the restriction on a .tar file size?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Move several files into specific directories with a loop

Hello, I'm a first time poster looking for help in scripting a task in my daily routine. I am new in unix but i am attracted to its use as a mac user. Bear with me... I have several files (20) that I manually drag via the mouse into several named directories over a network. I've used rsync... (14 Replies)
Discussion started by: SonnyClark
14 Replies

2. Shell Programming and Scripting

Move directories in script.sh doesn't work

Dear All, I would like move some directories in another location. Basically, my ls -lis drwxr-xr-x 3 XXXXXXXXXXXXXXXXXXXX 4096 Feb 24 02:18 data.N701_N502.ABCDE -rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX 185865797 Feb 23 11:27 data.N701_N502.ABCDE_file1 -rw-r--r-- 1 XXXXXXXXXXXXXXXXXXXX... (2 Replies)
Discussion started by: giuliangiuseppe
2 Replies

3. UNIX for Dummies Questions & Answers

Move multipe files to corresponding directories

Hi, In a parent directory there are several files in the form IDENTIFIER1x IDENTIFIER1.yyy IDENTIFIER1_Z, etc IDENTIFIER2x IDENTIFIER2.yyy IDENTIFIER2_Z, etc IDENTIFIER3x IDENTIFIER3.yyy, IDENTIFIER3_Z, etcIn the same parent directory there are corresponding directories named... (7 Replies)
Discussion started by: spirospap
7 Replies

4. UNIX for Advanced & Expert Users

Move files while making a tar

I have the following folder structure code/f1/ code/lib/t1 code/lib/t2 code/lib/t3 code/lib/t3 code/lib_1/t1 code/exc I would like to create a tar with a folder structure below and I can use the following tar command f1 lib/t1 lib/t2 lib/t3 tar -cvf code.tar -C code f1 lib... (4 Replies)
Discussion started by: alpboys
4 Replies

5. Shell Programming and Scripting

move directories up one level

hi , could you help me with shell scripting in a shell script i have these commands a=`ls -R $dir | grep ./ ` cp -R ./$a/* ./$output/ with the first command i have all the directories with the second command i want to copy them in a new directory something like this... (2 Replies)
Discussion started by: faethon
2 Replies

6. UNIX Desktop Questions & Answers

Help with Script to Move Directories

Hi I am after a simple script to move folders/files from one directory into another directory on the same server. I want to run a cron so this can run at midnight. Issue is there will not always be data in the source folder. This script works fine but it errors if nothing exists in the source... (3 Replies)
Discussion started by: treds
3 Replies

7. Shell Programming and Scripting

Loop to move files in different directories

Hi, I have various log files in different paths. e.g. a/b/c/d/e/server.log a/b/c/d/f/server.log a/b/c/d/g/server.log a/b/c/h/e/server.log a/b/c/h/f/server.log a/b/c/h/g/server.log a/b/c/i/e/server.log a/b/c/i/e/server.log a/b/c/i/e/server.log and above these have an archive folder... (6 Replies)
Discussion started by: acc01
6 Replies

8. UNIX for Dummies Questions & Answers

tar, zip multiple separate directories and move the results to another volume

TIA, I'm using FreeBSD 6 I have a series of Directories (A,B,C,...Z). Each directory has files and other directories within it. I want to compress the contents of each top directory into a single file so that I get an archive of each directory (for example, A.gzip) AND and want to move... (5 Replies)
Discussion started by: jccbin
5 Replies

9. UNIX for Dummies Questions & Answers

Tar only the Directories and Sub Directories

Hi all, I want to only tar the Directories and the Sub Directories. I dont want the files which are created in those directories. Can you please help me out in this issue. Regards Andy (3 Replies)
Discussion started by: Andysundar
3 Replies

10. UNIX for Dummies Questions & Answers

Compare directories then move similar ones

I would like to know how to compare a listing of directories that begin with the same four numbers ie. /1234cat /1234tree /1234fish and move all these directories into one directory Thanks in advance (2 Replies)
Discussion started by: tgibson2
2 Replies
Login or Register to Ask a Question