Sunday, January 5, 2014

Changing absolute path for tar command in Solaris OS

Changing absolute path for tar command in Solaris OS


When we use tar command in Linux, The / is trimmed, So when we restore from tar file , It will extract the files to directory we wish to to extract without overwriting.

In Solaris, tar command contains the absolute path, When we try to restore , It will restore to the absolute path as source.

This is some times very dangarous where it can overrite the source files or when you need to restore it in other locations, You need to have same file system as source.

To avoid this , Use the below.

$ tar tvf backup_apps.tar

-rwxr-xr-x 205/100  34260 Jan 18 11:14 2006 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/Notepad/Notepad.jar
-rwxr-xr-x 205/100    339 Jan 18 11:14 2006 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/Notepad/README.txt
drwxrwx--- 205/100      0 Jan  2 21:17 2007 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/TableExample/
-rwxr-xr-x 205/100  22353 Jan 18 11:14 2006 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/TableExample/TableExample.jar
drwxrwx--- 205/100      0 Jan  2 21:17 2007 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/TableExample/src/
-rwxr-xr-x 205/100   8613 Jan 18 11:14 2006 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/TableExample/src/TableExample.java
-rwxr-xr-x 205/100   8790 Jan 18 11:14 2006 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/TableExample/src/JDBCAdapter.java
-rwxr-xr-x 205/100   3293 Jan 18 11:14 2006 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/TableExample/src/TableExample2.java
-rwxr-xr-x 205/100   5708 Jan 18 11:14 2006 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/TableExample/src/TableExample3.java
-rwxr-xr-x 205/100   9339 Jan 18 11:14 2006 /tstdp1/prg/oracle/R12/apps/tech_st/10.1.3/jdk/demo/plugin/jfc/TableExample/src/OldJTable.java


-- If you extract using tar -xvf backup_apps.tar command, It will restore to original directory structure if available or errors out if not avaibale.


The work around for this problem is , Use command pax to extract the files in solaris instead of tar -xvf command.


pax -r -s '=^/tstdp1/prg/oracle/R12=/usr/R12=' < backup_apps.tar


Now it will extract to  /usr/R12 folder. 

$ cd /usr/R12

$ls -ltr 
drwxr-xr-x   4 oracle   oinstall       4 Jan  5 15:01 apps

6 comments:

  1. new horizon security services richmond vaI would like to thank you for your nicely written post, its very informative and your writing style encouraged me to read it till end. Thanks

    ReplyDelete
  2. Car Accident Lawyer Rockledge Sinclair Law - Leading Florida Law Firm Attorney Brad Sinclair Represents Personal Injury, Car Accident, Motorcycle Accident Victims in Melbourne.

    ReplyDelete
  3. Oracle fusion HCM Training from ERPTREE gives you the best results to learn your dream course and maintains
    sufficient knowledge on oracle. It provides training by self-paced videos which are very helpful for
    the users to watch at any time according to their schedule. It is globally accepted and having many users undergoing training every day.


    Oracle fusion HCM Online Training

    Oracle Fusion HCM Training

    ReplyDelete
  4. screwtape letters study guide Really Good blog post.provided a helpful information.I hope that you will post more updates like this.

    ReplyDelete
  5. Thanks for sharing great information, Hope you will share many more articles so that it will be helpful for many of us.

    Oracle Fusion Financials Online Training

    ReplyDelete
  6. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.

    Oracle Fusion HCM Online Training

    ReplyDelete