Why does "tar" create the path directories to my target in the archive?
Hey LQ,
I've got a back up script doing some rsync and tar bz2 to create an archive. So far this is working out pretty good but whenever I go to unpack the archive I always get these extra directories in the archive which I'm not expecting. The target tar directory is something like /home/wh33t/backupdirectory/ and in the archive there will be a /home, a /home/wh33t, and a /home/wh33t/backupdirectory/ which I am not expecting to see there. I just want to see the files and directories at the root of the backupdirectory/. I know there is probably a command switch for this but I'm not even sure what this is referred to. |
it will store the path provided to it... show us the actual script.
|
it sounds like you should do a cd to the backup directory immediately before the tar command.
If you grok 'info tar' in great detail you'll probably find a switch for skipping levels of leading directories on extraction. Mind you, I'm sure that won;t be worth the effort involved. I find 'info tar' a good way of confusing what I already know about tar and a bad way of learning anything. |
tar has an option -C <dir> to go to a location before doing the job, so probably you need something like:
tar -C /home/wh33t <your flags to create an archive> backupdirectory |
Quote:
|
I can't seem to get this to work.
I'm currently doing Quote:
I've tried this command in a few different orders as well to no avail. I've tried doing the -C switch before -cf, after the -cf and after the target directory. Any ideas? |
Uhm,... you put your directories in the path,... I never have to tar stuff up,... but try using ~/wwroot rather than your actual path...
|
Quote:
|
It looks like -C should do what you want http://linux.die.net/man/1/tar, but as above, you could just cd to the target dir first.
|
Quote:
|
Quote:
|
Quote:
|
|
Quote:
tar -C /home/wh33t/wwwroot cf /home/wh33t/test.tar . |
Quote:
Ok well I tried it out and it mostly worked. I'm my tar archive I don't have any /home or /home/wh33t but I do have .. and . and my directories in there are prefixed with .\, so my directories in the root of the tarchive are like .\dir1, .\dir2. Is that to be expected? Is that what happens on your machine? |
All times are GMT -5. The time now is 03:22 PM. |