LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   how to copy tar file to other location (https://www.linuxquestions.org/questions/solaris-opensolaris-20/how-to-copy-tar-file-to-other-location-876543/)

daniesh 04-22-2011 01:11 PM

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,

ButterflyMelissa 04-22-2011 01:25 PM

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

daniesh 04-22-2011 01:34 PM

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,

ButterflyMelissa 04-22-2011 01:45 PM

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

Thalha Rahim 04-22-2011 02:12 PM

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~

jlliagre 04-22-2011 09:12 PM

@daniesh:
Why are you using tar to copy files ?
What OS and what tar version are you using ?

MTK358 04-23-2011 03:23 PM

Quote:

Originally Posted by Thor_2.0 (Post 4332839)
you forgot the "z" option, I see this is a .gz (read Zip - hence the "z")

Newer versions of tar automatically detect compression.

jlliagre 04-23-2011 04:03 PM

Quote:

Originally Posted by MTK358 (Post 4333847)
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).

Blinker_Fluid 04-25-2011 11:04 AM

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. :(

MTK358 04-25-2011 11:35 AM

Quote:

Originally Posted by Blinker_Fluid (Post 4335705)
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).

daniesh 04-26-2011 01:50 AM

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,

MTK358 04-26-2011 08:49 AM

@daniesh

Is you final goal to create a tar archive file, or to copy files?

daniesh 04-27-2011 05:08 AM

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,

jlliagre 04-27-2011 07:54 AM

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

daniesh 05-02-2011 08:21 AM

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


All times are GMT -5. The time now is 09:05 PM.