BusyBox's tar --exclude and -X option do not appear to be working (version 1.26.x)

Denys Vlasenko vda.linux at googlemail.com
Fri Nov 10 20:36:01 UTC 2017


On Sat, Nov 4, 2017 at 5:39 PM, gestos <gestos at ftp83plus.net> wrote:
> Hello to all,
>
> for my first post on this list, an issue I am experiencing with BusyBox
> 1.26.x version of tar (mipsel architecture). I want to dump a system image
> from a combo USB3.0 / WiFi / Ethernet hard drive. The OS seems to reside on
> a small flash chip, while the storage drive is internally connected by USB
> and mounted at /data. Since the current system seems to be using a
> customised version of BusyBox 1.12 where options have been removed, I simply
> downloaded a more recent version in a user-accessible folder and called the
> newer binary instead.
>
> command is exactly:
> ./busybox-mipsel tar -czf
> /data/UsbDisk1/Volume1/Share/Direct/Images/System.tar.gz / -X /data
>
> But I also tried, without success:
> ./busybox-mipsel tar -czf
> /data/UsbDisk1/Volume1/Share/Direct/Images/System.tar.gz / -X=/data

This is wrong, it says "exclude patterns listed in file '=/data'"

> ./busybox-mipsel tar -czf
> /data/UsbDisk1/Volume1/Share/Direct/Images/System.tar.gz / --exclude=/data
> ./busybox-mipsel tar -czf
> /data/UsbDisk1/Volume1/Share/Direct/Images/System.tar.gz / --exclude=/data/*
>
> However, for some reason this command doesn't exclude the /data sub-tree,
> and instead starts on generating an enormous System.tar.gz file, which is
> obviously not the correct one.
>
> What is the exact syntax for excluding a given sub-tree?

There isn't one. You can only exclude a name, not a whole subtree.
This works for me - does not include /media directory:

busybox tar -cvzf z.tar.gz /m* --exclude=media
tar: removing leading '/' from member names
mnt/
mnt/sdb/
mnt/sdb1/

However:
(1) it would also exclude any files named "media"
anywhere under /mnt as well.
(2) GNU tar fails to exclude /media

You may have better luck if you prepare a list of files/directories
you want to INCLUDE, rather than exclude, and use:

busybox tar -cvzf z.tar.gz -T FILE_WITH_LIST


More information about the busybox mailing list