I'm trying to compress some backup data. I've rsync'ed some directories to another partition, /mnt/backup. I want to compress /mnt/backup/home/first with 7z so that I can burn it to a CD. However, I want to exclude some directories from the 7z file, because they are huge (oggs and digicam photos), and I don't need to back them up to CD. I want to exclude these directories: /mnt/backup/home/first/Music /mnt/backup/home/first/Images/Pictures/Picasa /mnt/backup/home/first/Images/Pictures/Photos/Picasa So I created a file with a list of directories to exclude: /mnt/backup/7z.home.exclude.list ==== Music/* Images/Pictures/Picasa/* Images/Pictures/Photos/Picasa/* ==== Then I ran this command: # 7z a /mnt/backup/home/first.7z /mnt/backup/home/first/* -x@/mnt/backup/7z.home.exclude.list 7z works, and it does not complain like it does if I specify an invalid file list, but it does not exclude those directories. So I tried using absolute paths in the exclude file list: /mnt/backup/7z.home.exclude.list ==== /mnt/backup/home/first/Music/* /mnt/backup/home/first/Images/Pictures/Picasa/* /mnt/backup/home/first/Images/Pictures/Photos/Picasa/* ==== Then I ran the same command, but 7z still did not exclude those directories. Finally I tried removing the "/*" at the end of each line: /mnt/backup/7z.home.exclude.list ==== /mnt/backup/home/first/Music /mnt/backup/home/first/Images/Pictures/Picasa /mnt/backup/home/first/Images/Pictures/Photos/Picasa ==== Then I ran the same command, and it still will not exclude the directories. I also tried removing the "/*" and using relative paths: /mnt/backup/7z.home.exclude.list ==== Music Images/Pictures/Picasa Images/Pictures/Photos/Picasa ==== That, of course, didn't work either. Is there any way to exclude directories from being included??? Am I doing something wrong, or is this a bug?
tag 296665 upstream thanks Concerning excluding directories, a similar bug has already been reported at "upstream's upstream" (that's to say at 7-zip for Windows itself = Igor Pavlov) here: http://sourceforge.net/tracker/index.php?func=detail&aid=1072327&group_id=14481&atid=114481 Upstream can't answer about this and he is waiting for this to be fixed by Igor Pavlov. Perhaps following http://sourceforge.net/forum/forum.php?thread_id=1211890&forum_id=45798 trick would work. 7-Zip, as it is currently, is not intended for backup purpose, if not used with tar.
Just FYI, this still doesn't work with 4.18-1. I checked the upstream bug report, but no progress has been made on it.
the syntax you gave to me in this bug report.
[0] http://adn.diwi.org/debian/p7zip/excluding-dirs.sh.txt
[1] http://adn.diwi.org/debian/p7zip/excluding-dirs.sh
Here[2] is the output.
[2] http://adn.diwi.org/debian/p7zip/excluding-dirs.sh.txt
Conclusion: one has to put the relative paths to the directories from
the directory from where you are adding to archive.
May I close this report? I think I will add some information about this
in next upload's documentation.
Mohammed Adnène Trojette wrote: Thanks for following up. I ran your script and checked the output, and now I understand what you mean. (Running version "4.29 beta", BTW.) It seems to work in a fairly logical manner now. However, I did notice one thing that is still confusing, and should at least be noted, IMO. I used your script, but changed the archive command to this: $ 7z a directory.7z directory/* -x@exclude.list That results in the exact same archive as your unmodified script. The confusing part is, it would seem to me that adding the "/*" should cause not the directory itself to be added to the archive, but only the contents of the directory; i.e. instead of the archive containing a "directory/contents of directory" structure, it should only contain the contents of "directory", with no parent directory. I guess that's a separate issue, so I don't see any reason to not close this bug. (Finally!) But I do think it should be mentioned in the man page, at least, because it doesn't do what one would think it should do (IMHO).
Actually, though, the more I think about it, shouldn't you be able to use absolute paths when you're excluding files and directories, regardless of the working directory when you create the archive? Shouldn't you be able to use absolute paths to exclude when you use absolute paths to create the archive? Doesn't tar let you do that?
Ok, last reply this round, I promise. I still don't think 7z does it right. You can work around it by using the method you discovered, but I don't think 7z does the "right thing." I did another version of the script like this: $ 7z a /tmp/directory.7z /tmp/directory -x@exclude.list The result? Nothing ever got excluded. Even when the exclude list was: $ echo /tmp/directory/1 >> exclude.list $ echo /tmp/directory/10 >> exclude.list Surely that is not proper behavior. I apologize for saying the bug was ok to close earlier, but honestly, this just doesn't seem right.