PDA

View Full Version : how to tar files in linux


o0O0o.o0O0o
08-06-2009, 01:12 AM
I have folder called .temp in

/backups/full/user/.temp

I have the script which puts database backups and home directory backup(.tar.gz) in that .temp folder.


Now from those two backups i want to create a third full.tar file which will contain those two backups.


The problem is if i use

tar -cf full.tar /backups/full/user/.temp/*

then when i extract my archive , then i have the following directory structure

I got all the folder above like

folder bakcups -->full -->user-->.temp and then the backups

Is there any way that my tar file only contain files in .temp and not all the folders.

tomws
08-06-2009, 02:59 AM
On a Linux system, see the manual pages for command help:
man tar
Or type something like this:
tar --help

The man page says this at the bottom of the Description paragraph:
The use of a directory name always implies that the subdirectories below should be included in the archive.

Check out the -C argument, possibly. Maybe others.

o0O0o.o0O0o
08-06-2009, 03:29 AM
I am trying -C option but it says file not found.
Can you give me some eg like how to use it
i am trying this way

tar -cCf full.tar /backups/full/user/.temp/*


I found how to use -C option

tar -C /path/to/dir -cf abc.tar *

I think the problem now i have is tar file looks for that relative path not absolute path.

is there any way to use absolute path wih tar