hi all,
i know how to create a tar, lets say i have a dir i want to tar up -
/mnt/backup/data/centos_isos/
i cd to /mnt/backup/data/
in there i run
tar -cf centos_isos.tar centos_isos/
it creates the tar file here
/mnt/backup/data/centos_isos.tar
how do i change where to create it in that dir, i want it saved to /mnt/local/
how would i do this please
many thanks,
rob
2 Spice ups
Append a filepath before the name of the tar and you are good to go!
Example: /path/to/archive.tar
2 Spice ups
pigdog
(pigdog)
3
Using Robert’s command, but with Ben’s instruction:
tar -cf /path/to/centos_isos.tar centos_isos/
or
tar -cf /mnt/local/centos_isos.tar centos_isos/
2 Spice ups
so what is the option C for as i thought you used it for this exact thing
-c means create an archive, -f means from the files specified. -cf means create an archive from these files.
If you want to know what any option does for X command, just look up the man pages. man tar
man ls
man yum
etc…
1 Spice up
i know cf mean create file but i mean -C not -c
this is what i mean
Local file selection:
–add-file=FILE
add given FILE to the archive (useful if its name starts with a dash)
–backup[=CONTROL]
backup before removal, choose version CONTROL
-C, --directory=DIR
change to directory DIR
D’oh!
You would use C if you are outside of the directory in which the files you want to tar, or cd into the directory you want to extract a tar to.
pigdog
(pigdog)
9
EDIT:
Ben is correct. My advice below is incorrect. You can use " -C " to change into a directory prior to creating an archive, as well as extracting an archive.
But you have to be careful if you do. You might run into problems with globbing, because the glob will expand based on your current directory (I think).
Test it and see if it is easier for you, though.
My bogus advice below here:
I believe the “C” option for change directory is only operative when extracting. That is "C"hange to the specified directory prior to "x"tracting the tar.
Test it with tar "c"reate, but I doubt it will do anything useful.
thanks guys, this forum rocks
mmm… im getting errors when running this command -
cd /vol/cha-work/_ARCHIVE/to_be_archived/audio/robert_test/
tar -cf /vol/cha-archive/audio/after_louise_1606.tar after_louise_1606/
tar: after_louise_1606/renders_from/from_clipster/160922_after_louise_prores422_cont_51_clp_jd: file changed as we read it
tar: after_louise_1606/renders_from/from_clipster: file changed as we read it
tar: after_louise_1606/renders_from: file changed as we read it
tar: after_louise_1606/conform_materials/feature/offlines/161019: file changed as we read it
i really dont get this as the files havnt been altered for the directory after_louise_1606/
here is the ls -lah for that dir -
drwxrwxrwx 12 root cha-work 307 Mar 9 12:34 .
drwxrwxrwx 3 root cha-work 35 Mar 10 09:21 …
drwxrwxrwx 12 root cha-work 368 Mar 9 11:51 audio
drwxrwxrwx 4 root cha-work 62 Mar 9 11:53 blfx
drwxrwxrwx 4 root cha-work 102 Mar 9 11:04 conform_materials
drwxrwxrwx 4 root cha-work 100 Mar 9 10:34 DCI
-rwxrwxrwx 1 root cha-work 4.0K Mar 9 11:04 ._.DS_Store
-rwxrwxrwx 1 root cha-work 6.1K Mar 9 11:48 .DS_Store
drwxrwxrwx 7 root cha-work 185 Mar 9 11:53 gfx
drwxrwxrwx 5 root cha-work 104 Mar 9 11:52 media
drwxrwxrwx 10 root cha-work 285 Mar 9 12:34 renders_for
drwxrwxrwx 8 root cha-work 182 Mar 9 11:04 renders_from
drwxrwxrwx 2 root cha-work 0 Mar 9 11:53 _temp
drwxrwxrwx 5 root cha-work 168 Mar 9 12:35 _tests
pigdog
(pigdog)
13
There are only 2 “regular files” in your “ls -lah” listing above. Everything else in the list is a “directory file.”
A directory timestamp won’t tell you if an existing file within the directory has changed.
A directory timestamp will change when an entry in the directory is created, deleted, linked, or renamed. That is, anything that writes to a directory will change the directory timestamp.
So creating a file will update the directory’s timestamp, but edits to an existing file will not change its directory’s timestamp.
Do something like
find . -newermt "Mar 9 8:00 AM" -ls
Edit the date/time inside the quotes to whatever is applicable,
mmm…
looks like its working as i have created a 10gig file using the dd comand and its located in untitledfolder/
tar -cf /vol/cha-archive/audio/untitledfolder.tar untitledfolder/
and that works without any warnings about file changed as we read it
but i cant work it out because the folder after_louise_1606 i know 100% def it is not being written/read to at all so i dont know why its giving me these warnings and then failing on the tar
oh well
pigdog
(pigdog)
15
What is your working directory when you enter this command?
tar -cf /vol/cha-archive/audio/untitledfolder.tar untitledfolder/
If you are putting the "untitledfolder.tar " file into a path from which you are also getting files that become part of the archive, that could be your problem.
Try something like:
tar -cf /tmp/untitledfolder.tar untitledfolder/
and see if the errors go away.
what about if i use any of these option with the tar command
–ignore-failed-read
–ignore-command-error
i cd to this dir -
cd /vol/cha-work/_ARCHIVE/to_be_archived/audio/robert_test/
and in there is untitledfolder/
so i do this -
tar -cf /vol/cha-archive/audio/untitledfolder.tar untitledfolder/
i would never use the tar command in the directory i want to tar up as your asking for trouble
pigdog
(pigdog)
18
Don’t ignore the messages until you’ve convinced yourself that the archive is sound.
Maybe you should extract those files from the archive for which you received the message. Extract them into a different directory. Them sum them (eg, md5sum) against the live files.
yes your right i could do a md5sum for the source directory im tarring up and once the tar has finished untar it and do another md5sum ?
You think its still tarring up those individual files its producing the warning for or it just gives up altogether and fails the whole tar as its producing loads of warnings for individual files?