1

I'd like to make a .7z archive of my website using 7zip; there are a few directories that contain large files (several gigabytes) not worth backing up, as I already have backups of them. I could specify to backup only specific files or directories, but I'm planning on making a script to do this for me, and it'd be a bit annoying to keep updating the script to include new files, file types, and directories. I can't find for the life of me anything in the documentation about excluding directories; only files. What's the simplest way to go about doing this?

The command I used earlier (before I had large files to avoid) was simply

7z a backup.7z *

done in the working directory.

1

directory is a type of file. man 7z isn't easy to read but it mentions -x:

-x[r[-|0]]]{@listfile|!wildcard}


    Exclude filenames

Let's suppose we have a following directory tree:

$ tree
.
├── dir
│   └── file3
├── dir1
│   └── file4
├── file1
└── file2

2 directories, 4 files

and that we want to ignore dir and dir1:

$ 7z a -x'!dir' -x'!dir1' b.7z  *

After doing that:

$ 7z l b.7z
(...)
   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2018-04-03 22:25:24 ....A            0            0  file1
2018-04-03 22:25:24 ....A            0            0  file2
------------------- ----- ------------ ------------  ------------------------
2018-04-03 22:25:24                  0            0  2 files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.