Synchronizing archives with directories

Help
J44xm
2004-11-30
2012-12-07
  • J44xm
    J44xm
    2004-11-30

    I'm new to 7-Zip, but like what I see -- so much, in fact, that I uninstalled WinRAR! Now, I'm trying to figure this one out:

    I use the command-line interface to back up certain directories. I can add new files to the archive and update existing files, but I'm not sure how to delete files within the archive that are no longer present in the source directory.

    Essentially, I want a command to sychronize .7z archives with source directories. Right now, I just use my batch files to delete the existing archives and create new ones, but if there's a way to synchronize the archives with their source directories, and if this will be faster than creating new archives from scratch, how can I do this?

    Here's my current command:

    "c:\program files\(utilities)\(compression)\7-zip\7z.exe" u -t7z -p1234 ".\pegasus_mail.7z" -r "c:\program files\pmail\mail\*"

    (Note: My actual password has been changed. Also, my adding the password command there seems to do nothing as all, as my archives open included files without hesitation. Any ideas on that?)

    Many thanks.

     
    • Igor Pavlov
      Igor Pavlov
      2004-11-30

      Read description of -u switch.
      And also you must switch off solid mode:
      -ms=off

       
      • J44xm
        J44xm
        2004-11-30

        Thanks for replying. Long post short, the help file entry is a bit difficult to understand. I hope someone might be able to help me construct a parameter that does what I need (which is to modifying an existing .7z file so that it synchronizes to changes in my source directory).

        Regarding the <action> table, when it mentions the "old archive," does this also refer, if I'm creating an archive from a directory, to my source directory? That is, does "Copy file (copy from old archive to new)" mean, in this case, to copy said file from the directory to my archive sans compression?

        Also, I'm not sure if the anti-item option is useful in the context of creating or modifying an archive from a directory.

        As for solid mode, that's done. Thanks.

         
        • Igor Pavlov
          Igor Pavlov
          2004-12-01

          from my cpp file:

              enum EEnum
              {
                kNotMasked = 0,
                kOnlyInArchive,
                kOnlyOnDisk,
                kNewInArchive,
                kOldInArchive,
                kSameFiles,
                kUnknowNewerFiles
              };

          const CActionSet kUpdateActionSet =
          {
            NPairAction::kCopy,
            NPairAction::kCopy,
            NPairAction::kCompress,
            NPairAction::kCopy,
            NPairAction::kCompress,
            NPairAction::kCopy,
            NPairAction::kCompress
          };

          const CActionSet kSynchronizeActionSet =
          {
            NPairAction::kCopy,
            NPairAction::kIgnore,
            NPairAction::kCompress,
            NPairAction::kCopy,
            NPairAction::kCompress,
            NPairAction::kCopy,
            NPairAction::kCompress,
          };

          You can check it

          Anti-file is for incremental update and for Synchronizing files on two computers.

           
          • J44xm
            J44xm
            2004-12-01

            At the risk of sounding like a dolt, I'm not sure what that code means. My coding is essentially limited to HTML and batch files. As I understand it, .cpp files are C++ source code files, though.

            So is this what I want to synchronize my archive with my directory: "-up0q3r2x0y2z0w2"? If not, can someone tweak it for me?

             
            • Igor Pavlov
              Igor Pavlov
              2004-12-01

              check it:
              u -uq0

               
              • J44xm
                J44xm
                2004-12-02

                Wow, is that all I really need? So if the "File exists in archive, but doesn't exist on disk," it does nothing, right? Does it delete the file as well? If the file no longer exists on the disk, I don't need it in the archive either.

                Thanks for you help thus far.

                 
                • Igor Pavlov
                  Igor Pavlov
                  2004-12-02

                  Just test it.

                   
                  • J44xm
                    J44xm
                    2004-12-02

                    Done deal. Something must be wrong with my syntax, however. Here's my command:

                    "c:\program files\(utilities)\(compression)\7-zip\7z.exe" u -uq0 -ms=off -p1234 ".\pegasus_mail.7z" -r "c:\program files\pmail\mail\*"

                    And here's what happens:

                    ---------
                    7-Zip 4.10 beta  Copyright (c) 1999-2004 Igor Pavlov  2004-10-21

                    Scanning

                    Updating archive .\pegasus_mail.7z

                    Error:

                    System error:
                    Not implemented
                    ---------

                    I'm not sure what's happening here ...

                     
                    • Igor Pavlov
                      Igor Pavlov
                      2004-12-02

                      Probably previous archive was created in solid mode.
                      So remove it and create again with -ms=off

                       
                      • J44xm
                        J44xm
                        2004-12-02

                        Hot dang! It worked! I really appreciate your help with this, and I apologize if I was a pain.

                        Still, I'd like to understand what happened. Does the command "u" remove archived files that no longer exist in the source directory, or does the "-uq0" switch do it? If the former, then just what does the switch do?

                        Thanks!

                         
                        • Igor Pavlov
                          Igor Pavlov
                          2004-12-02

                          -uq0 changes standard action of update operation:
                          "Ignore" instead of "Copy" (in Update operation) for "OnlyInArchive" case.

                           
                          • J44xm
                            J44xm
                            2004-12-03

                            Ah, I think I see. You've got a convert in me, friend. I'll be spreading the word about 7-Zip! Thanks for your help and patience.  ^_^

                             
    • J44xm
      J44xm
      2004-12-01

      At the risk of sounding like a dolt, I'm not sure what that code means. My coding is essentially limited to HTML and batch files. As I understand it, .cpp files are C++ source code files, though.

      So is this what I want to synchronize my archive with my directory: "-up0q3r2x0y2z0w2"? If not, can someone tweak it for me?