Simply put, I did an exhaustive library update on my network to be compatible with XBMC. Now that it's done, I thought it wouldn't hurt to periodically make a backup of the nfo,bub,srt,jpg,tbn files (everything except any video file) that are in the various directories and subdirectories in my TV Shows folder. I also wanted to zip it by date. After playing around, I got this to semi-work:
find '/volume2/MyMedia/TV Shows/' -type f \( -name \*\.sub -o -name \*\.srt -o -name \*\.nfo -o -name \*\.jpg -o -name \*\.tbn \) -print0 | xargs -0 tar -pvczf '/volume2/Backups/XBMC Backups/'XBMC-TVShows-NFO-JPG-TBN-SUB-Backup-$(date +%m-%d-%y).tar.gz
It goes through the motions (scanning every directory and finding the files), and I see the zip file grow, but then suddenly the tar.gz goes down to 0 bytes and counts up again. I think it's doing that once it hits a new directory to scan.
At the end, I get a 1.8MB file with only the last directory it scanned through. Inside that, is almost everything, except it omitted 1 of the subdirectories. IE: It zipped up '30 Rock' and all of the files I specified, but, it did that for all folders except Season 2.
So I am at a loss. Everything looks clear to me in the code. For some reason it's not running properly. I think I have tunnel vision on the project now. A fresh set of eyes would be magnificent!
Here is an output: http://pastebin.com/ywctQ5Sf
Here is what the final tar.gz contained: http://s23.postimg.org/6pc22h7yz/output.png
Final note: The directories of the shows that it backs up do have whitespaces in them. So there is a directory structure like so:
>volume2
->MyMedia
-->TV Shows
--->Fullmetal Alchemist Brotherhood
---->Season 1
----->Fullmetal Alchemist Brotherhood.S01E01.Fullmetal Alchemist.nfo
Thank you for any help!
That's because xargs
splits the huge list of files across multiple tar
commands, which each try to create a new file. Try using the -A
option instead of -vczf ...
and pipe the whole command to gzip
:
find ... -print0 | xargs -0 tar -A | gzip - > "....tar.gz"