LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 04-22-2011, 01:11 PM   #1
daniesh
LQ Newbie
 
Registered: Apr 2011
Posts: 12

Rep: Reputation: 0
how to copy tar file to other location


Hi Experts,

I have used tar cvf to copy a file to /u03 location.

the command which i run to copy.

cd /u03
tar cvf apps_st.gz /u01/oracle/oradev/apps/apps_st

u03- where i wanted to copy.
apps_st while i wanted to copy.

Is this is the correct copy command using tar.

Now i want to extract it to /u02/backup
which command i used?

Your assistance is much apprecited in this regards,

Thanks and Regards,
 
Old 04-22-2011, 01:25 PM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Hmm,

How about this?

Quote:
tar -xvzf /home/user/Downloads/chkrootkit.tar.gz -C /home/user/Dump
this will "untar" the contents of /home/user/Downloads/chkrootkit.tar.gz in the folder /home/user/Dump and (possibly - depending on what's inside the archive) make its own folder there...

Hopefully helpful...

Thor
 
Old 04-22-2011, 01:34 PM   #3
daniesh
LQ Newbie
 
Registered: Apr 2011
Posts: 12

Original Poster
Rep: Reputation: 0
Hi,

Thanks for the quick response.

In my case, If i want to copy it to /u02/backup.

I have to use the below command.

tar -xvf /u03/apps_st.gz -C /u02/backup

Please advice.
one more thing my command was correct which is used to copy using tar.
Please advice.
Thanks and Regards,
 
Old 04-22-2011, 01:45 PM   #4
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
you forgot the "z" option, I see this is a .gz (read Zip - hence the "z")

Try this instead:

Quote:
tar -xvzf /u03/apps_st.gz -C /u02/backup
By the way, you do realize that you need to use the /full/path/from/the/top ...

The given command assumes folders u03 and u02 to be in the top level, this is not a very clever idea...you may (as normal user) not even have the permissions to do that, if so, you may need to use sudo:

Quote:
sudo tar -xvzf /u03/apps_st.gz -C /u02/backup
at witch point the system will ask the root password.

If, however,these are located in your home folder (say), I'd add the full path

Quote:
tar -xvzf /home/yourfolder/u03/apps_st.gz -C /home/yourfolder/u02/backup
Luck!

Thor
 
Old 04-22-2011, 02:12 PM   #5
Thalha Rahim
LQ Newbie
 
Registered: Apr 2011
Location: INDIA
Posts: 8

Rep: Reputation: 3
Hello Dear

Assuming your "apps_st.gz" achieve is still located in /u03,

You can extract it to "/u02/backup" by using any of the following option


cd /u02/backup
tar -xvzf /u03/apps_st.gz


Or Simply


tar -xvzf /u03/apps_st.gz -C /u02/backup


~thalha~

Last edited by Thalha Rahim; 04-22-2011 at 02:15 PM.
 
Old 04-22-2011, 09:12 PM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
@daniesh:
Why are you using tar to copy files ?
What OS and what tar version are you using ?
 
Old 04-23-2011, 03:23 PM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by Thor_2.0 View Post
you forgot the "z" option, I see this is a .gz (read Zip - hence the "z")
Newer versions of tar automatically detect compression.
 
Old 04-23-2011, 04:03 PM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by MTK358 View Post
Newer versions of tar automatically detect compression.
However, they don't do it when an archive is created (here with a wrong suffix anyway, .gz vs .tgz).
 
Old 04-25-2011, 11:04 AM   #9
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
Are you wanting to just copy files from one place to another maintaining permisssions?
to copy files from your current dir to another dir:
tar Ecf - . | ( cd /directory/where/you/want/to/copy2; tar xfp -)

And Solaris does not support the z option like Linux does.
 
Old 04-25-2011, 11:35 AM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by Blinker_Fluid View Post
Are you wanting to just copy files from one place to another maintaining permisssions?
The cp command can do that (at least the GNU version).
 
Old 04-26-2011, 01:50 AM   #11
daniesh
LQ Newbie
 
Registered: Apr 2011
Posts: 12

Original Poster
Rep: Reputation: 0
Hi,

Thanks for all your assistance.
The command i have used is tar cvf. the name i have given only the name as name.gz format, howver i have not used z in my tar command.I can used tar c /location where i want to copy/ tar xcf.

Thanks and Regards,
 
Old 04-26-2011, 08:49 AM   #12
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
@daniesh

Is you final goal to create a tar archive file, or to copy files?
 
Old 04-27-2011, 05:08 AM   #13
daniesh
LQ Newbie
 
Registered: Apr 2011
Posts: 12

Original Poster
Rep: Reputation: 0
Hi,

I have already take a backup using above tar command.

Now i just wanted to copy to different location, thats it.

Thanks and Regards,
 
Old 04-27-2011, 07:54 AM   #14
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
As you have stored a non relative path in your archive, you can't restore it to a different location with a regular Unix tar. Gnu tar is ignoring the leading slash so that might be a solution but you might be hit by compatibility issues.

With regular Solaris tools, you can restore a tar archive elsewhere by using the pax command.

For example this command extracts to the current directory all the files present in your tar file, removing its hierarchy:

Code:
pax -r -s '/.*\///' -f apps_st.gz

Last edited by jlliagre; 05-02-2011 at 10:51 AM. Reason: typo
 
Old 05-02-2011, 08:21 AM   #15
daniesh
LQ Newbie
 
Registered: Apr 2011
Posts: 12

Original Poster
Rep: Reputation: 0
Hi All,
Thanks for all your help.

I tried to command to copy apps_tar.gz to /u02/oracle/ERPTEST/appltest/ using the below command.

tar -xvfp /u03/backup_23042011/apps_tar.gz -C /u02/oracle/ERPTEST/appltest/

I can see the below output.

x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423192.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423306.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420192.req, 1509 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420171.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422535.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422653.req, 2711 bytes, 6 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423194.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423307.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420190.req, 1509 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420191.req, 2273 bytes, 5 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422537.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422646.req, 4521 bytes, 9 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423187.req, 2253 bytes, 5 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423298.req, 2253 bytes, 5 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420197.req, 2253 bytes, 5 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420200.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422529.req, 4521 bytes, 9 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422657.req, 2591 bytes, 6 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423189.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423310.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420095.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420096.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422585.req, 4521 bytes, 9 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422601.req, 1996 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423242.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423259.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420198.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420199.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422532.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422656.req, 2802 bytes, 6 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423191.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423311.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420202.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420203.req, 1517 bytes, 3 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422530.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l422658.req, 2802 bytes, 6 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423190.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l423312.req, 1593 bytes, 4 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420201.req, 2253 bytes, 5 tape blocks
x /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log/l420204.req, 1517 bytes, 3 tape blocks

From the a above output, I can see that the tar command is trying to copy the /u01/oracle/ERPDEV/appldev//inst/apps/DEV_zanerpuat/logs/appl/conc/log.

When i checked my destination location, I didnt see anything there.
cd /u02/oracle/ERPTEST/appltest
$ ls
$

Please help me on this.

Thanks and Regards,
Daniesh
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] restore tar.gz file to different location smithy2010 Linux - Newbie 2 07-25-2010 10:56 AM
Tar file copy error rays_pks Gentoo 1 06-17-2009 02:38 AM
need copy of tomcat 4 tar file Kaao Linux - Software 1 05-16-2006 12:20 PM
Using Tar/Star to copy a compressed file from tape geokker Linux - Software 1 09-09-2005 07:32 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 11:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration