You are not logged in.

#1 2015-06-12 19:05:50

Soukyuu
Member
Registered: 2014-04-08
Posts: 854

Getting tar to include all dot files but also exclude specific folders

This is driving me mad. According to this I can use --exclude-from=file.txt to exclude any entries I want, one per line. I was using exactly the same file with rsync for root directory (so backing up /*)
Now, I want to do the same for my home, but here I need to also include the dot files. According to various pages (e. g. here), I am supposed to use '.' or rather '* .*' to include dot files as well, so my current command looks like this:

tar cf /path/to/archive/home.tar --exclude-from=exclude-list.txt * .*

And my ~/exclude-list.txt contains entries like this:

Folder1/
Folder2/
Folder3/

All of the folders are in my home dir. I am also starting the script from my home dir.
Yet looking at the tar, I can see it include all the three excluded folders!

I have also tried to exclude folders separately:

tar cf /path/to/archive/home.tar * .* --exclude='Folder1/'

Folder1 still gets included.


[ Arch x86_64 | linux | Framework 13 | AMD Ryzen™ 5 7640U | 32GB RAM | KDE Plasma Wayland ]

Offline

#2 2015-06-12 19:23:04

oliver
Member
Registered: 2007-12-12
Posts: 448

Re: Getting tar to include all dot files but also exclude specific folders

would this work for you?

cd; tar cf /path/to/archive/home.tar --exclude-from=exclude-list.txt .

with excludes like:

./Folder1
./Folder2
./Folder3

Last edited by oliver (2015-06-12 19:25:29)

Offline

#3 2015-06-12 19:31:54

Soukyuu
Member
Registered: 2014-04-08
Posts: 854

Re: Getting tar to include all dot files but also exclude specific folders

This seems to work, thanks! I just wonder why it worked with rsync but doesn't with tar...


[ Arch x86_64 | linux | Framework 13 | AMD Ryzen™ 5 7640U | 32GB RAM | KDE Plasma Wayland ]

Offline

Board footer

Powered by FluxBB