3 ms·
I'm kind of annoyed that tar doesn't back up directories starting with a period unless you throw in a command flag. I wish I knew this before taking a backup
by doublerabbit 2y ago
I'm kind of annoyed that tar doesn't back up directories starting with a period unless you throw in a command flag.
I wish I knew this before taking a backup and reformatting.
Always test your backups I guess..
- vorakl 2y agoThis is an interesting one. What was the version of tar? Was it gnu tar? I wonder, how did you create that archive? I'm asking this because I was trying to reproduce the same situation and everything seems to be working fine: $ tar -C /tmp/root3 -cvf test.tar . ./ ./.config/ ./.config/test ./.local/ ./var/ ./var/db/ ./var/db/xbps/ or even like this $ tar -cvf test2.tar root3/ root3/ root3/.config/ root3/.config/test root3/.local/ root3/var/ root3/var/db/ root3/var/db/xbps/ No special options were needed. But, if I do it this way, then, there are definitely missing all dot directories: $ tar -cvf test2.tar root3/* root3/usr/ root3/usr/bin/ root3/usr/bin/xbps-uunshare But this problem is not a tar's problem. That's only because "*" mask doesn't match dot files: $ echo root3/* root3/usr root3/var For that purpose, you need to clearly add a dot: $ echo root3/.* root3/.config root3/.local Thus, the solution might be $ tar -cvf test2.tar root3/.* root3/* root3/.config/ root3/.config/test root3/.local/ root3/usr/ root3/usr/bin/ But, I'd rather stick to "-C dir/" option instead of relying on "*" mask in this case.
- doublerabbit 2y agotar -cvf mytar.tar /home/myuser/* Was definitely the syntax I ran. I'm on FreeBSD so just tar.
- vorakl 2y agoThen, this explains why. BTW, this is an expected Shell behavior, specified in the POSIX standard: If a filename begins with a <period> ( '.' ), the <period> shall be explicitly matched by using a <period> as the first character of the pattern or immediately following a <slash> character. The leading <period> shall not be matched by: * The <asterisk> or <question-mark> special characters https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_03 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V... Interesting fact about the FreeBSD tar's origins: GNU tar was included as the standard system tar in FreeBSD beginning with FreeBSD 1.0. This is a complete re-implementation based on the libarchive(3) library. It was first released with FreeBSD 5.4 in May, 2005. https://man.freebsd.org/cgi/man.cgi?query=tar https://man.freebsd.org/cgi/man.cgi?query=tar My personal journey with FreeBSD began with version 5.3 (the first stable release on the 5th branch) in November 2004. I was completely unaware of such a significant tar change, and apparently I didn't care at the time. However, the entire 5th branch has been so revolutionary compared to the 4th branch that this change is just a drop in the bucket ;)