nixoid
nixoid

Reputation: 25

How to find and compress multiple directories with files to one archive?

I have over 200 different domains with wordpress installed on my server and want all of their uploaded files for year 2013 to be compressed into one file keeping the directory structure.

I need all files and folders from

domain1.com/wp-content/uploads/2013/
domain2.com/wp-content/uploads/2013/
domain3.com/wp-content/uploads/2013/
domain4.com/wp-content/uploads/2013/

to be compressed into one archive. The problem is there many folders with the same name (month number) and possibly files with similar name. How to compress them all and overwrite compressed files if some already exist in the archive?

Upvotes: 0

Views: 438

Answers (2)

Barmar
Barmar

Reputation: 780724

tar cfz archive.tar.gz */wp-content/uploads/2013

This will retain the directory structure.

It's not possible to replace files in a tar file. You can append new versions of a file to an uncompressed archive, but when it's compressed you can't do that, either. You could make an incremental archive of all the files that have changed since the last archive.

Upvotes: 1

drew.cuthbert
drew.cuthbert

Reputation: 1015

Just create a local directory for each domain and copy that domain's files to it. So create a directory called domain1-wp-content, copy the contents of domain1.com/wp-content/uploads/2013 into it, and repeat for the other directories. Then compress all of your newly created local directories together.

Upvotes: 0

Related Questions