0

I've been tasked to update a few of our sites and so, before doing so, I have to zip the public_html folder so I have a backup.

Problem is, public_html has a bunch of other ZIPs that are older backups that I don't want to delete in case my backup fails or for some other reason, we need to go back 2-3 backups.

But, since they are there and get caught in every backup, the backup file grows and grows because it contains basically every single previous backup within it.

So is there a way to tweak the zip command line call so it gets all files, except any .zip or .gzip file it finds?

3
  • 1
    Maybe store the final zip files above/outside of the public_html directory?
    – Jeff Schaller
    Nov 2, 2021 at 17:21
  • I'm not the one making the procedures here but yeah, i'll push for that next meeting. Just them being kept on the server is kinda dumb in the first place.
    – Fredy31
    Nov 2, 2021 at 17:25
  • Linking in a similar Q/A: unix.stackexchange.com/q/27362/117549
    – Jeff Schaller
    Nov 2, 2021 at 17:26

1 Answer 1

3

The quick answer is to exclude the existing zip files:

zip -r foo /path/to/public_html -x '*.zip' -x '*.gzip'

Add/remove the -x options to match your existing naming convention for zip and gzip files.

The long-term answer would be to store the backup files outside the public_html folder so that you don't keep catching them in the backups.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .