Is it a good habit to rm zip file before packing folders?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












I have a folder with some files. I need to backup them daily.



I am using Debian and zsh and I use zip for the tool to backup them.



I am updating the folder from time to time, adding new files, removing old files and updating old files.



I noticed that zip can automatically update a zip file. For instance:



When I run zip -r backup.zip my-folder/ at first, it will add all files.



But when I run the same command zip -r backup.zip my-folder/ again, it will update all the files.



Is that reliable? Or do I need to rm the zip file every time before I pack my folder?







share|improve this question















  • 3




    Another question to consider is whether zip is a good tool for doing backups at all. I would rather consider rsnapshot, borgbackup or similar.
    – Kusalananda
    yesterday
















up vote
0
down vote

favorite












I have a folder with some files. I need to backup them daily.



I am using Debian and zsh and I use zip for the tool to backup them.



I am updating the folder from time to time, adding new files, removing old files and updating old files.



I noticed that zip can automatically update a zip file. For instance:



When I run zip -r backup.zip my-folder/ at first, it will add all files.



But when I run the same command zip -r backup.zip my-folder/ again, it will update all the files.



Is that reliable? Or do I need to rm the zip file every time before I pack my folder?







share|improve this question















  • 3




    Another question to consider is whether zip is a good tool for doing backups at all. I would rather consider rsnapshot, borgbackup or similar.
    – Kusalananda
    yesterday












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a folder with some files. I need to backup them daily.



I am using Debian and zsh and I use zip for the tool to backup them.



I am updating the folder from time to time, adding new files, removing old files and updating old files.



I noticed that zip can automatically update a zip file. For instance:



When I run zip -r backup.zip my-folder/ at first, it will add all files.



But when I run the same command zip -r backup.zip my-folder/ again, it will update all the files.



Is that reliable? Or do I need to rm the zip file every time before I pack my folder?







share|improve this question











I have a folder with some files. I need to backup them daily.



I am using Debian and zsh and I use zip for the tool to backup them.



I am updating the folder from time to time, adding new files, removing old files and updating old files.



I noticed that zip can automatically update a zip file. For instance:



When I run zip -r backup.zip my-folder/ at first, it will add all files.



But when I run the same command zip -r backup.zip my-folder/ again, it will update all the files.



Is that reliable? Or do I need to rm the zip file every time before I pack my folder?









share|improve this question










share|improve this question




share|improve this question









asked yesterday









AGamePlayer

1,826102742




1,826102742







  • 3




    Another question to consider is whether zip is a good tool for doing backups at all. I would rather consider rsnapshot, borgbackup or similar.
    – Kusalananda
    yesterday












  • 3




    Another question to consider is whether zip is a good tool for doing backups at all. I would rather consider rsnapshot, borgbackup or similar.
    – Kusalananda
    yesterday







3




3




Another question to consider is whether zip is a good tool for doing backups at all. I would rather consider rsnapshot, borgbackup or similar.
– Kusalananda
yesterday




Another question to consider is whether zip is a good tool for doing backups at all. I would rather consider rsnapshot, borgbackup or similar.
– Kusalananda
yesterday










1 Answer
1






active

oldest

votes

















up vote
0
down vote













According to man zip



zip will replace identically named entries in the zip archive


So whenever zip says updating: my-folder/<file> (in=0) (out=0) (stored 0%) its actually replacing the existing file in the archive, which is like a Full backup but not an Incremental or Defferential Backup. Checkout the example below:



# du -b dir/*
1073741824 dir/file.txt
2 dir/x
0 dir/xx
0 dir/xy
0 dir/y
0 dir/z


# time zip -rv dir.zip dir
adding: dir/ (in=0) (out=0) (stored 0%)
adding: dir/xy (in=0) (out=0) (stored 0%)
adding: dir/x (in=2) (out=2) (stored 0%)
adding: dir/file.txt ...................................................................................................... (in=1073741824) (out=1042051) (deflated 100%)
adding: dir/xx (in=0) (out=0) (stored 0%)
adding: dir/y (in=0) (out=0) (stored 0%)
adding: dir/z (in=0) (out=0) (stored 0%)
total bytes=1073741826, compressed=1042053 -> 100% savings

real 0m10.990s
user 0m10.827s
sys 0m0.160s

# dd if=/dev/zero of=dir/file.txt count=1040 bs=1048576
1040+0 records in
1040+0 records out
1090519040 bytes (1.1 GB) copied, 8.95635 s, 122 MB/s

# du -b dir/file.txt
1090519040 dir/file.txt


Now the file dir/file.txt has been updated with some extra bytes. Now lets run zip again:



# time zip -rv dir.zip dir
updating: dir/ (in=0) (out=0) (stored 0%)
updating: dir/xy (in=0) (out=0) (stored 0%)
updating: dir/x (in=2) (out=2) (stored 0%)
updating: dir/file.txt ........................................................................................................ (in=1090519040) (out=1058320) (deflated 100%)
updating: dir/xx (in=0) (out=0) (stored 0%)
updating: dir/y (in=0) (out=0) (stored 0%)
updating: dir/z (in=0) (out=0) (stored 0%)
total bytes=1090519042, compressed=1058322 -> 100% savings

real 0m11.246s
user 0m11.021s
sys 0m0.223s


It just replaced the dir/file.txt with recently modified file with the same name. This is the same case even if the file doesn't have new content. There are different types of backups like Full, Incremental, Differential available. Typically Incremental and Differential will come into the picture if the Backup mechanism is designed and put in place for the Data.



In that case as @kusalananda mentioned it would be good if you looked at more versatile tools available to take backups.



For instance rsync could be of help.



Also rm need not be run on the existing archived file every time you run the zip command.



If you want to stick with zip, go through zip's add, update, freshen. For example, Update case:



# time zip -ruv dir.zip dir
zip diagnostic: dir/ up to date
zip diagnostic: dir/xy up to date
zip diagnostic: dir/x up to date
zip diagnostic: dir/xx up to date
zip diagnostic: dir/y up to date
zip diagnostic: dir/z up to date
updating: dir/file.txt .......................................................................................................... (in=1111490560) (out=1078679) (deflated 100%)
total bytes=1111490562, compressed=1078681 -> 100% savings

real 0m11.351s
user 0m11.178s
sys 0m0.171s


If zip is run again:



# time zip -ruv dir.zip dir
zip diagnostic: dir/ up to date
zip diagnostic: dir/xy up to date
zip diagnostic: dir/x up to date
zip diagnostic: dir/file.txt up to date
zip diagnostic: dir/xx up to date
zip diagnostic: dir/y up to date
zip diagnostic: dir/z up to date

real 0m0.003s
user 0m0.002s
sys 0m0.001s





share|improve this answer























    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f460604%2fis-it-a-good-habit-to-rm-zip-file-before-packing-folders%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    According to man zip



    zip will replace identically named entries in the zip archive


    So whenever zip says updating: my-folder/<file> (in=0) (out=0) (stored 0%) its actually replacing the existing file in the archive, which is like a Full backup but not an Incremental or Defferential Backup. Checkout the example below:



    # du -b dir/*
    1073741824 dir/file.txt
    2 dir/x
    0 dir/xx
    0 dir/xy
    0 dir/y
    0 dir/z


    # time zip -rv dir.zip dir
    adding: dir/ (in=0) (out=0) (stored 0%)
    adding: dir/xy (in=0) (out=0) (stored 0%)
    adding: dir/x (in=2) (out=2) (stored 0%)
    adding: dir/file.txt ...................................................................................................... (in=1073741824) (out=1042051) (deflated 100%)
    adding: dir/xx (in=0) (out=0) (stored 0%)
    adding: dir/y (in=0) (out=0) (stored 0%)
    adding: dir/z (in=0) (out=0) (stored 0%)
    total bytes=1073741826, compressed=1042053 -> 100% savings

    real 0m10.990s
    user 0m10.827s
    sys 0m0.160s

    # dd if=/dev/zero of=dir/file.txt count=1040 bs=1048576
    1040+0 records in
    1040+0 records out
    1090519040 bytes (1.1 GB) copied, 8.95635 s, 122 MB/s

    # du -b dir/file.txt
    1090519040 dir/file.txt


    Now the file dir/file.txt has been updated with some extra bytes. Now lets run zip again:



    # time zip -rv dir.zip dir
    updating: dir/ (in=0) (out=0) (stored 0%)
    updating: dir/xy (in=0) (out=0) (stored 0%)
    updating: dir/x (in=2) (out=2) (stored 0%)
    updating: dir/file.txt ........................................................................................................ (in=1090519040) (out=1058320) (deflated 100%)
    updating: dir/xx (in=0) (out=0) (stored 0%)
    updating: dir/y (in=0) (out=0) (stored 0%)
    updating: dir/z (in=0) (out=0) (stored 0%)
    total bytes=1090519042, compressed=1058322 -> 100% savings

    real 0m11.246s
    user 0m11.021s
    sys 0m0.223s


    It just replaced the dir/file.txt with recently modified file with the same name. This is the same case even if the file doesn't have new content. There are different types of backups like Full, Incremental, Differential available. Typically Incremental and Differential will come into the picture if the Backup mechanism is designed and put in place for the Data.



    In that case as @kusalananda mentioned it would be good if you looked at more versatile tools available to take backups.



    For instance rsync could be of help.



    Also rm need not be run on the existing archived file every time you run the zip command.



    If you want to stick with zip, go through zip's add, update, freshen. For example, Update case:



    # time zip -ruv dir.zip dir
    zip diagnostic: dir/ up to date
    zip diagnostic: dir/xy up to date
    zip diagnostic: dir/x up to date
    zip diagnostic: dir/xx up to date
    zip diagnostic: dir/y up to date
    zip diagnostic: dir/z up to date
    updating: dir/file.txt .......................................................................................................... (in=1111490560) (out=1078679) (deflated 100%)
    total bytes=1111490562, compressed=1078681 -> 100% savings

    real 0m11.351s
    user 0m11.178s
    sys 0m0.171s


    If zip is run again:



    # time zip -ruv dir.zip dir
    zip diagnostic: dir/ up to date
    zip diagnostic: dir/xy up to date
    zip diagnostic: dir/x up to date
    zip diagnostic: dir/file.txt up to date
    zip diagnostic: dir/xx up to date
    zip diagnostic: dir/y up to date
    zip diagnostic: dir/z up to date

    real 0m0.003s
    user 0m0.002s
    sys 0m0.001s





    share|improve this answer



























      up vote
      0
      down vote













      According to man zip



      zip will replace identically named entries in the zip archive


      So whenever zip says updating: my-folder/<file> (in=0) (out=0) (stored 0%) its actually replacing the existing file in the archive, which is like a Full backup but not an Incremental or Defferential Backup. Checkout the example below:



      # du -b dir/*
      1073741824 dir/file.txt
      2 dir/x
      0 dir/xx
      0 dir/xy
      0 dir/y
      0 dir/z


      # time zip -rv dir.zip dir
      adding: dir/ (in=0) (out=0) (stored 0%)
      adding: dir/xy (in=0) (out=0) (stored 0%)
      adding: dir/x (in=2) (out=2) (stored 0%)
      adding: dir/file.txt ...................................................................................................... (in=1073741824) (out=1042051) (deflated 100%)
      adding: dir/xx (in=0) (out=0) (stored 0%)
      adding: dir/y (in=0) (out=0) (stored 0%)
      adding: dir/z (in=0) (out=0) (stored 0%)
      total bytes=1073741826, compressed=1042053 -> 100% savings

      real 0m10.990s
      user 0m10.827s
      sys 0m0.160s

      # dd if=/dev/zero of=dir/file.txt count=1040 bs=1048576
      1040+0 records in
      1040+0 records out
      1090519040 bytes (1.1 GB) copied, 8.95635 s, 122 MB/s

      # du -b dir/file.txt
      1090519040 dir/file.txt


      Now the file dir/file.txt has been updated with some extra bytes. Now lets run zip again:



      # time zip -rv dir.zip dir
      updating: dir/ (in=0) (out=0) (stored 0%)
      updating: dir/xy (in=0) (out=0) (stored 0%)
      updating: dir/x (in=2) (out=2) (stored 0%)
      updating: dir/file.txt ........................................................................................................ (in=1090519040) (out=1058320) (deflated 100%)
      updating: dir/xx (in=0) (out=0) (stored 0%)
      updating: dir/y (in=0) (out=0) (stored 0%)
      updating: dir/z (in=0) (out=0) (stored 0%)
      total bytes=1090519042, compressed=1058322 -> 100% savings

      real 0m11.246s
      user 0m11.021s
      sys 0m0.223s


      It just replaced the dir/file.txt with recently modified file with the same name. This is the same case even if the file doesn't have new content. There are different types of backups like Full, Incremental, Differential available. Typically Incremental and Differential will come into the picture if the Backup mechanism is designed and put in place for the Data.



      In that case as @kusalananda mentioned it would be good if you looked at more versatile tools available to take backups.



      For instance rsync could be of help.



      Also rm need not be run on the existing archived file every time you run the zip command.



      If you want to stick with zip, go through zip's add, update, freshen. For example, Update case:



      # time zip -ruv dir.zip dir
      zip diagnostic: dir/ up to date
      zip diagnostic: dir/xy up to date
      zip diagnostic: dir/x up to date
      zip diagnostic: dir/xx up to date
      zip diagnostic: dir/y up to date
      zip diagnostic: dir/z up to date
      updating: dir/file.txt .......................................................................................................... (in=1111490560) (out=1078679) (deflated 100%)
      total bytes=1111490562, compressed=1078681 -> 100% savings

      real 0m11.351s
      user 0m11.178s
      sys 0m0.171s


      If zip is run again:



      # time zip -ruv dir.zip dir
      zip diagnostic: dir/ up to date
      zip diagnostic: dir/xy up to date
      zip diagnostic: dir/x up to date
      zip diagnostic: dir/file.txt up to date
      zip diagnostic: dir/xx up to date
      zip diagnostic: dir/y up to date
      zip diagnostic: dir/z up to date

      real 0m0.003s
      user 0m0.002s
      sys 0m0.001s





      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        According to man zip



        zip will replace identically named entries in the zip archive


        So whenever zip says updating: my-folder/<file> (in=0) (out=0) (stored 0%) its actually replacing the existing file in the archive, which is like a Full backup but not an Incremental or Defferential Backup. Checkout the example below:



        # du -b dir/*
        1073741824 dir/file.txt
        2 dir/x
        0 dir/xx
        0 dir/xy
        0 dir/y
        0 dir/z


        # time zip -rv dir.zip dir
        adding: dir/ (in=0) (out=0) (stored 0%)
        adding: dir/xy (in=0) (out=0) (stored 0%)
        adding: dir/x (in=2) (out=2) (stored 0%)
        adding: dir/file.txt ...................................................................................................... (in=1073741824) (out=1042051) (deflated 100%)
        adding: dir/xx (in=0) (out=0) (stored 0%)
        adding: dir/y (in=0) (out=0) (stored 0%)
        adding: dir/z (in=0) (out=0) (stored 0%)
        total bytes=1073741826, compressed=1042053 -> 100% savings

        real 0m10.990s
        user 0m10.827s
        sys 0m0.160s

        # dd if=/dev/zero of=dir/file.txt count=1040 bs=1048576
        1040+0 records in
        1040+0 records out
        1090519040 bytes (1.1 GB) copied, 8.95635 s, 122 MB/s

        # du -b dir/file.txt
        1090519040 dir/file.txt


        Now the file dir/file.txt has been updated with some extra bytes. Now lets run zip again:



        # time zip -rv dir.zip dir
        updating: dir/ (in=0) (out=0) (stored 0%)
        updating: dir/xy (in=0) (out=0) (stored 0%)
        updating: dir/x (in=2) (out=2) (stored 0%)
        updating: dir/file.txt ........................................................................................................ (in=1090519040) (out=1058320) (deflated 100%)
        updating: dir/xx (in=0) (out=0) (stored 0%)
        updating: dir/y (in=0) (out=0) (stored 0%)
        updating: dir/z (in=0) (out=0) (stored 0%)
        total bytes=1090519042, compressed=1058322 -> 100% savings

        real 0m11.246s
        user 0m11.021s
        sys 0m0.223s


        It just replaced the dir/file.txt with recently modified file with the same name. This is the same case even if the file doesn't have new content. There are different types of backups like Full, Incremental, Differential available. Typically Incremental and Differential will come into the picture if the Backup mechanism is designed and put in place for the Data.



        In that case as @kusalananda mentioned it would be good if you looked at more versatile tools available to take backups.



        For instance rsync could be of help.



        Also rm need not be run on the existing archived file every time you run the zip command.



        If you want to stick with zip, go through zip's add, update, freshen. For example, Update case:



        # time zip -ruv dir.zip dir
        zip diagnostic: dir/ up to date
        zip diagnostic: dir/xy up to date
        zip diagnostic: dir/x up to date
        zip diagnostic: dir/xx up to date
        zip diagnostic: dir/y up to date
        zip diagnostic: dir/z up to date
        updating: dir/file.txt .......................................................................................................... (in=1111490560) (out=1078679) (deflated 100%)
        total bytes=1111490562, compressed=1078681 -> 100% savings

        real 0m11.351s
        user 0m11.178s
        sys 0m0.171s


        If zip is run again:



        # time zip -ruv dir.zip dir
        zip diagnostic: dir/ up to date
        zip diagnostic: dir/xy up to date
        zip diagnostic: dir/x up to date
        zip diagnostic: dir/file.txt up to date
        zip diagnostic: dir/xx up to date
        zip diagnostic: dir/y up to date
        zip diagnostic: dir/z up to date

        real 0m0.003s
        user 0m0.002s
        sys 0m0.001s





        share|improve this answer















        According to man zip



        zip will replace identically named entries in the zip archive


        So whenever zip says updating: my-folder/<file> (in=0) (out=0) (stored 0%) its actually replacing the existing file in the archive, which is like a Full backup but not an Incremental or Defferential Backup. Checkout the example below:



        # du -b dir/*
        1073741824 dir/file.txt
        2 dir/x
        0 dir/xx
        0 dir/xy
        0 dir/y
        0 dir/z


        # time zip -rv dir.zip dir
        adding: dir/ (in=0) (out=0) (stored 0%)
        adding: dir/xy (in=0) (out=0) (stored 0%)
        adding: dir/x (in=2) (out=2) (stored 0%)
        adding: dir/file.txt ...................................................................................................... (in=1073741824) (out=1042051) (deflated 100%)
        adding: dir/xx (in=0) (out=0) (stored 0%)
        adding: dir/y (in=0) (out=0) (stored 0%)
        adding: dir/z (in=0) (out=0) (stored 0%)
        total bytes=1073741826, compressed=1042053 -> 100% savings

        real 0m10.990s
        user 0m10.827s
        sys 0m0.160s

        # dd if=/dev/zero of=dir/file.txt count=1040 bs=1048576
        1040+0 records in
        1040+0 records out
        1090519040 bytes (1.1 GB) copied, 8.95635 s, 122 MB/s

        # du -b dir/file.txt
        1090519040 dir/file.txt


        Now the file dir/file.txt has been updated with some extra bytes. Now lets run zip again:



        # time zip -rv dir.zip dir
        updating: dir/ (in=0) (out=0) (stored 0%)
        updating: dir/xy (in=0) (out=0) (stored 0%)
        updating: dir/x (in=2) (out=2) (stored 0%)
        updating: dir/file.txt ........................................................................................................ (in=1090519040) (out=1058320) (deflated 100%)
        updating: dir/xx (in=0) (out=0) (stored 0%)
        updating: dir/y (in=0) (out=0) (stored 0%)
        updating: dir/z (in=0) (out=0) (stored 0%)
        total bytes=1090519042, compressed=1058322 -> 100% savings

        real 0m11.246s
        user 0m11.021s
        sys 0m0.223s


        It just replaced the dir/file.txt with recently modified file with the same name. This is the same case even if the file doesn't have new content. There are different types of backups like Full, Incremental, Differential available. Typically Incremental and Differential will come into the picture if the Backup mechanism is designed and put in place for the Data.



        In that case as @kusalananda mentioned it would be good if you looked at more versatile tools available to take backups.



        For instance rsync could be of help.



        Also rm need not be run on the existing archived file every time you run the zip command.



        If you want to stick with zip, go through zip's add, update, freshen. For example, Update case:



        # time zip -ruv dir.zip dir
        zip diagnostic: dir/ up to date
        zip diagnostic: dir/xy up to date
        zip diagnostic: dir/x up to date
        zip diagnostic: dir/xx up to date
        zip diagnostic: dir/y up to date
        zip diagnostic: dir/z up to date
        updating: dir/file.txt .......................................................................................................... (in=1111490560) (out=1078679) (deflated 100%)
        total bytes=1111490562, compressed=1078681 -> 100% savings

        real 0m11.351s
        user 0m11.178s
        sys 0m0.171s


        If zip is run again:



        # time zip -ruv dir.zip dir
        zip diagnostic: dir/ up to date
        zip diagnostic: dir/xy up to date
        zip diagnostic: dir/x up to date
        zip diagnostic: dir/file.txt up to date
        zip diagnostic: dir/xx up to date
        zip diagnostic: dir/y up to date
        zip diagnostic: dir/z up to date

        real 0m0.003s
        user 0m0.002s
        sys 0m0.001s






        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited 14 hours ago


























        answered 15 hours ago









        sai sasanka

        51517




        51517






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f460604%2fis-it-a-good-habit-to-rm-zip-file-before-packing-folders%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay