Recovering directory timestamps when extracting tar archives

I created a backup using tar, and now I try to extract it, but the problem is that some of the directories do not get the correct timestamps.
As an example, consider the following directory structure:
   dir0/
       file1
       dir1/
           file2
           .DS_Store
           dir2/
               file3
This can be created (in Terminal) by:
    mkdir dir0
    cd dir0
    touch file1
    mkdir dir1
    cd dir1
    touch file2
    mkdir dir2
    cd dir2
    touch file3
    cd ../../..
and then you just navigate to dir0/dir1 in Finder (but not to dir2), which creates the .DS_Store files in both dir0 and dir1. Finally, we delete the .DS_Store in dir0:
    rm dir0/.DS_Store
Now i created the archive (on Mountain Lion, bsdtar 2.8.3, but I have the same issue when I try gnutar 1.17):
    tar -cvf bkup.tar dir0/
Then I extract the archive in a different location, say:
    mkdir different_location
    cd different_location
    tar -xvf ../bkup.tar
The problem: the (modification) timestamp of dir1 is set to the time I extracted the archive, rather then to the creation time of the original dir1 (but dir0 and dir2 have the correct timestamps of the creation time).
How can I ensure that all extracted directories have the modification timestamps set to the same as the original directories?
The problem seems to be related to the .DS_Store file that is in dir1/ but is not in dir0/ and dir2/. I do want to save the .DS_Store files in my original archive. Perhaps this also has something to do with the fact that .DS_Store files have extended attributes (unlike the other files in these directories);
that is, perhaps tar adds the extended attributes after it sets the timestamps of the extracted files, and that step resets the modification times?
So I tried to disable the extended attributes with:
    export COPYFILE_DISABLE=true
but that did not work.
any idea how to recover the original timestamps?

There's a write-up on tar and how it tries to maintain the directory modification times here.
Do you need to use tar, or could zip and unzip (for instance) be used here?   And depending on what you're up to with the backups, using a scratch disk and time machine works, as can using rsync; if it's not working for you here, might there be an alternative to tar?

Similar Messages

  • Extraction tar.gz archives without leaving a .tar archive behind

    Hello!
    When I double-click on a .tar-gz-archive in the Finder, It extracts two things: a tar-archive and the actual content of the file. In 99% of the cases I don't want an additional tar file eating my disk space - is there any way to tell "BomArchiveHelper" (the Program that extracts archives) not to store tar archives?

    Good to know... is there a Linux native format for backups that does incorporate fault tolerance much like the rar format allows for parity or recovery records?

  • Problem occured when extracting archive-- student edition

    Hi, I am trying to install the free student version of CS6 Photoshop on Windows 8. I downloaded both files, but when I try to run the executable one, I get the error message "Problem occurred when extracting archive, please redownload". I have downloaded the files twice, and get the same message. Thanks for helping!

    Moving this discussion to the Downloading, Installing, Setting Up forum.
    Noreenw95 where are you downloading Photoshop CS6 from?  Have you tried downloading from Download CS6 products?

  • Unexpected end of archive when extracting SAPNW2004sABAPTrail_part

    Hi,
    Following are the the two files I downloaded for Webdynpro ABAP.
    1. SAPNW2004sABAPTrail_part1
    2. SAPNW2004sABAPTrail_part2
    When extracting the part 1 file I get the following warning..
    D:\WebDynpro\ABAP\SAPNW2004sABAPTrail_part1.rar: Unexpected end of archive
    D:\WebDynpro\ABAP\SAPNW2004sABAPTrail_part2.rar: Unexpected end of archive
    Please guide me to get rid of this very step 1...
    Thanks,
    Smita

    Hi,
    Perhaps you should try to download the files again.
    Kind regards,
    Klaus

  • Automator workflow to TAR multiple files in a single directory into multiple TAR archives, in succession?

    Good afternoon,
    I have set up an automator service that TAR's a folder into an archive for me and it works quite nicely. Idealy however, I would like to be able to highlight several folders, right click and have automator tar each folder into it's own TAR archive, but do it one by one.
    Example:
    FOLDER 01
    FOLDER 02
    FOLDER 03
    Highlight all - Right Click - "TAR Folder" - Automator takes over at this point and TARs each one into:
    FOLDER 01.tar (Once complete moves onto:)
    FOLDER 02.tar (Once complete moves onto:)
    FOLDER 03.tar (Finished)
    I'm not 100% sure so I guess it would be a good time to verify, is there a problem with having the system try to TAR multiple folders at one time? If it is not a problem then I guess this discussion itself is pointless and I can simple right click on each folder and select "TAR Folder" and just wait until they're all finished. I would think that it would be ideal for the system to do each one individually and not try to do them all at one time.
    Any help would be appreciated.
    Thank you!!

    I don't think I have the following totally fleshed out but you probably can extrapolate on it.   This is a service which you can right click a set of folders  and it will tar the files within those selected folders with then file names "name xxx.tar", where name is the tar'ed file/folder and xxx is a count within the folder.
    I think that is what you originally specified so I am a bit confused by your script with the bit about Archive.tar. 
    Anyway here the basic idea:
    I ran the script directly with a folder argument just to see it indeed tar's up all the stuff inside, one tar per item.

  • Extracting .tar files

    I have the com.ice.tar package from http://www.trustice.com/java/tar/ and I have the code shown below compiling just fine. However, I need to extract .tar files and this code will only extract tar.gz files. Does anyone know what I need to change to my code to get it to extract .tar files? Thanks,
    import com.ice.tar.*;
    import javax.activation.*;
    import java.io.*;
    import java.util.zip.GZIPInputStream;
    public class untarFiles
    public static void main(String args[]) {
    try {
    untar("c:/Files/AnyFile.tar.gz",new File("c:/Files/"));
    catch(Exception e) {
    e.printStackTrace();
    System.out.println(e.getMessage());
    private static void untar(String tarFileName, File dest) throws IOException {
    //assuming the file you pass in is not a dir
    dest.mkdir();
    //create tar input stream from a .tar.gz file
    TarInputStream tin = new TarInputStream( new GZIPInputStream
    ( new FileInputStream(new File(tarFileName))));
    //get the first entry in the archive
    TarEntry tarEntry = tin.getNextEntry();
    while (tarEntry != null){//create a file with the same name as the tarEntry
    File destPath = new File(dest.toString() + File.separatorChar + tarEntry.getName());
    if(tarEntry.isDirectory()){
    destPath.mkdir();
    } else {
    FileOutputStream fout = new FileOutputStream(destPath);
    tin.copyEntryContents(fout);
    fout.close();
    tarEntry = tin.getNextEntry();
    tin.close();
    }

    hey ppl, i have the same assignment of extracting tar.Z files using java.
    I have the same trustice.com library com.ice.tar
    I've used basically the same code given in the previous post.
    It is givin me the followin exception when i try using tar.Z files :
    com.ice.tar.InvalidHeaderException: bad header in block 0 record 0, header magic is not 'ustar' or unix-style zeros, it is '-50112-51-424592-71', or (dec) -50, 112, -51, -42, 45, 92, -71
         at com.ice.tar.TarInputStream.getNextEntry(Unknown Source)
         at filterdialog.readTar(filterdialog.java:101)
         at filterdialog$1.actionPerformed(filterdialog.java:80)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

  • Acrobat crashes when extracting pages

    Version Adobe Acrobat X 10.1.12
    When extracting and emailing pages from a pdf multiple times, Acrobat crashes.  Here is the process:
    1. Open pdf
    2. Tools -> Pages -> Extract
    3. Select any number of pages -> delete after extracting -> Yes at prompt
    4. In the extracted page(s) pdf, Share -> Send Files -> Attach to Email -> Attach
    5. Default email app opens -> Send email
    6. Close extracted page(s) pdf without saving.
    7. Go back to original pdf
    8. Try to repeat steps 1-6.
    The Acrobat crashes every time at step 4 on the 2nd extraction and email.  As soon as the share button is pressed (or using File -> Attach to Email), Acrobat crashes with the below error code.
    I have tried multiple different pdfs from different sources (i.e. downloaded from the web, scanned from a printer, generated from a word doc, etc.) as well updating Acrobat, uninstalling and re-installing (using the cleaner tool in between) and repairing install.  The issue happens on multiple machines, all running Win 7 Pro, and there are no add ins installed.
    Problem signature:
      Problem Event Name: APPCRASH
      Application Name: Acrobat.exe
      Application Version: 10.1.12.15
      Application Timestamp: 54084723
      Fault Module Name: Acrobat.dll
      Fault Module Version: 10.1.12.15
      Fault Module Timestamp: 540856d6
      Exception Code: c0000005
      Exception Offset: 00893320
      OS Version: 6.1.7601.2.1.0.256.48
      Locale ID: 1033
      Additional Information 1: 0a9e
      Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
      Additional Information 3: 0a9e
      Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

    My scanner cables never become disconnected, by the way (as the 2nd error message suggests).

  • Blank spaces(hex 00) inserted when extracting data

    I'm trying to extract data from a file with select-string and a regular expression.
    The data are SWIFT messages and I'm reading all files in a directory and then extracting the part I want with a regular expression which works fine, with the exception that a blank(hex 00) is inserted between all characters in the resulting file,
    which causes problems later.
    As far as I can see does this happen in the statement
    $tempvar = (Get-Content $basePath$inputPathElement | Out-String)
    but I haven't so far been able to figure out how to correct the script.
    One of the rows do e.g. look like this
    :28C:0/1
    which in hex will be:3a 32 38 43 3a 30 2f 31 0d 0a
    but in the resulting file will look
    3a 00 32
    00 38 00 43
    00 3a 00 30
    00 2f 00 31
    00 0d 00 0a
    00
    $date = Get-Date -Format "yyyyMMdd"
    $accountList =@(
                        ("123","File01.$date.DAT"),  
                        ("456","File02.$date.DAT"),
    $basePath = '\\Server\Folder01\'
    $archive = 'archive\'
    $extracted = 'extracted\'
    $inputPath = get-childitem *.DAT -path $basePath
    foreach($inputPathElement in $inputPath)
        $tempvar = (Get-Content $basePath$inputPathElement | Out-String)
        foreach($element in $accountList)
            $account = $element[0]
            $output_file = $element[1]
            $regex ="(?<header>{1:.*\s)(?<Tag2>:2[0-4]:.*\s){1,}(?<Tag25>:25:$account\s\s)((?<Tag28>:28.:.*\s)|(?<Tag6x>:6\d\w*:[\d\w,]*\s\s)|(?<Tag61>:61\w*:[\d\w,\\/\s]*){1,}|(?<Tag86>:86:[\w/\s]*))*(?<Trailer>.*(?<=adm}}))"
            if($tempvar -match  $regex)
                select-string -InputObject $tempvar -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $basePath$extracted$output_file
        Move-Item  $basePath$inputPathElement -Destination $basePath$archive -Force
    Any help would be appreciated.
    /Frank

    Hi,
    PS defaults to using UTF-16, so that's why you get the extra hex 00.
    Try changing the line
     select-string -InputObject $tempvar -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $basePath$extracted$output_file
    to
     select-string -InputObject $tempvar -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } | Out-File $basePath$extracted$output_file -Encoding UTF8 -append
    Regards,
    René

  • Higher precision of timestamp when wrinting to txt

    Hello,
    I would like to have a higher precision (--->miliseconds) of the timestamp when saving waveforms to .txt. Labview only prints the date and the time in HH:MMS. As I am acquiring data with a rate of 1k, 1000 data values have the same time description in the .txt-file.
    Note: This problem only occurs when writing to .txt, it is no problem to get a higher precision by using the graph or the chart. 
    Any help or suggestions would be appreciated.

    Thanks so far.....
    Maybe I was not precise enough. What I am looking for is the opportunity to easily manipulate the format of  the timestamp, which comes with my data and then write it to .txt. I already used the "Format Date/Time String"-VI to get the time with the miliseconds part and joined this time information with the data of the waveforms, which I also had to extract from the waveforms before, afterwards, but I thought there would be a more elegant way, because if I can extract the ms-part from the timestamp it must have been in it before, right ? ;-) So why can´t I tell Labview to also display the ms-part, when using the "write waveforms to .txt"-VI? I attached a .txt-file with a short excerpt of data, which should visualise the problem.
    Regards
    Message Edited by Marauder on 03-10-2006 03:20 PM
    Attachments:
    data_with_same_timestamp.txt ‏10 KB

  • Extract *.tar.gz file, error tar: 0511-164 There is a media read or write b

    when try to:
    $gzip -dc /dbdump/patch/oraInventory_BK.tar.gz | tar xf /tmp/t
    tar: 0511-164 There is a media read or write block size error.
    how to unzip/ extract tar sucussfully?
    AIX box
    thanks

    Preferably Unix questions are answered by consulting man pages or an Unix forum.
    Your questions is 100 percent of topic here. Kindly stop posting Unix questions here.
    Sybrand Bakker
    Senior Oracle DBA

  • Extracting tar.bz2 files.

    How can i extract tar.bz2 files?. zip, jar, tar can be extracted within java. But how tar.bz2?.

    Some tars have built-in knowledge of the bz2 (bunzip) compression format.
    Tar ("tape archive") is to package several files in one archive or to extract them. The archive files can be called "*.tar".

  • Could not extract the archive since it is corrupted. Errorcode = 2

    Hi All,
    I have downloaded the jdevstudio11116install.exe, when trying to install the exe I am getting the following error message,
    "could not extract the archive since it is corrupted. Errorcode = 2". Also when I tried to unzip the file by using winrar it is giving me the following error.
    ! C:\Users\demo\Downloads\Programs\jdevstudio11116install.exe: CRC failed in media\adfr_11116_COMP_win32ccjk.jar. The file is corrupt
    ! C:\Users\demo\Downloads\Programs\jdevstudio11116install.exe: CRC failed in media\jdevf_11116_COMP_win32ccjk.jar. The file is corrupt
    Any one please help me in this issue.
    Thanking you,
    rgds
    Parameswaran Bose

    Hi timo, unfortunately I run my anti virus software while downloading... Is it possible to download the following jar files seperately and do anything...
    ! C:\Users\demo\Downloads\Programs\jdevstudio11116install.exe: CRC failed in media\adfr_11116_COMP_win32ccjk.jar. The file is corrupt
    ! C:\Users\demo\Downloads\Programs\jdevstudio11116install.exe: CRC failed in media\jdevf_11116_COMP_win32ccjk.jar. The file is corrupt
    with thanks and regards
    Parameswaran Bose

  • " could not extract the archive since it is corrupted. Error code = 50"

    HI,
    I am trying to install "Oracle WebLogic Server 11gR1 (10.3.4) + Coherence -
    Package Installer 10.3.3" on my system,but when i double on the GUI self extractor for WLS,,, i am getting the following error.
    " could not extract the archive since it is corrupted. Error code = 50".
    so i tried to download another copy at another location,,,,even then the same error continues.
    please help me with this.
    thank you,
    raghuram.k

    请暂停杀毒软件就可以安装了。
    PLS stop your antivirus software,then you can fix it.

  • Update turbotax 2013 error can't extract from archive  on install and launch

    I installed my turbotax 2013. Then it said to update. I downloaded the update. Then it said install and relaunch. Up comes this message, "An error occurred while extracting the archive. Please try again later. No matter what I try. It comes up with same error message. I was online with intuit techs and they haven't solved it yet. Any ideas?

    First off, you are not seeing a kernel panic but an inability to load the kernel file "mach_kernel," which is damaged or missing.
    This is apparently because of a file system error (Invalid Key Length), a serious error Disk Utility is not designed to repair, since the repair usually involves loss of data & that app is very conservative about such things.
    It is almost impossible that the update itself is responsible for creating this error but very common for one to exacerbate it if it already exists. This is because file system errors corrupt files when the OS writes files to the disk, & updates write a lot of files to the disk.
    If you have implemented a backup strategy, the fix is straightforward, if a little time consuming: reformat the drive, do a new install of the OS from the installer disks, & restore your data from your backups.
    If you have not implemented a backup strategy, you now know why one is essential: no data you cannot afford to lose should reside only in one place like your internal hard drive. Data is lost every day because of human error, theft, hardware failure, or a host of other reasons. Only a good backup strategy can prevent this.
    Assuming the second situation applies to you, your best bet is to purchase a more powerful disk repair utility like DiskWarrior to see if it can repair the file system damage with minimal data loss. Be sure you read & heed the app's manual before using it! Failure to do so, or attempting to use the computer before the errors are repaired, will almost certainly result in more data loss.

  • Could not extract the archive since it is corrupted. Error code =2

    hi
    iaam trying to install bea workshop portal 8.1 SP4 in the d drive and it throws me this error. can anyone plz give me a reason for this
    Thanks
    --C                                                                                                                                                                                                                                                                                                           

    Hi,
    I have the same problem as Vishal had.
    I have installed weblogic portal 92, and worked fine for months. Because of the disk space problem while running the portal application, I increased the free disk space to 10GB, uninstalled the portal 92 platform, but now when i try to download and install weblogic portal 92 platform it gives me the following error:
    could not extract the archive since it is corrupted error code = 2.
    Any suggestions?
    Thank You
    Jian Wang

Maybe you are looking for