Problem with properly creating a tar archive
Hi all,
In a bash script of mine I create a tar archive from a file which contains absolute paths to the files the archive should contain(supplied via the --files-from argument). The lines is of the type /foo/bar/a, /foo/bar/b etc. - all the specified files is in one folder. The problem is, when I untar the archive the whole directory structure is created, foo/bar/ and then the files - I just want all the files in the toplevel of the archive. Any ideas? Suggestions highly appreciated. BTW, does anyone know a good mailinglist/forum for tricky hardware questions? (I don't want to go for LKML) Cheers, ________________Frans |
You want a flat tar archive, right - one where the directory structure does not exist?
|
Yupp! :)
Frans |
What you want doesn't exist - the only workaround is to create the tarball with the -P switch to prevent the stripping of leading '/' characters, and then unnzipping the tarball in the parent directory of the directory structure that you want backed up.
|
Ok. But there must be a solution to my problem:
I have N files spread out over the place, and I want to collect them together in the toplevel of the tar file. (and the files are in different places, some are in /foo/bar/ othere's in /foo/foo) Cheers, Frans |
There is indeed a way. You will probably have to do some scripting, but it isn't that hard.
Lets start with a file, file.lst, that contains all of the fully qualified file names you want to tar: Code:
/var/log/dmesg Code:
TARFILE=/backups/backup_$(date +%G%m%d).tar The tar cvf creates the tar file tar rvf appends to that tar file. Doing the cd inside of parens spawns a separate shell and when it exits you are back in the same place. Hope this helps! |
All times are GMT -5. The time now is 01:56 PM. |