Using find and pipe to tar
am trying to use tar in combination with find, the goal is to all files in /export that have been modified in the last 24 hours (back up purposes), then tar them so I can untar on the backup server, updating just the modified files.
Perhaps there is a better way, however, I have tried using cpio but the problem come in when I copy to the NAS drive (NTFS) I lose all my owner/group and permissions. I have found that if I tar the files, then copy them to the NAS, when I untar on the server, it will retain the owner/group and permissions. So… here is what I have tried: First, I use the find command to see what files should be in the tar archive. Code:
/export $ find . -depth -mtime 0 -print Code:
/export $ find . -depth -mtime 0 -print0 | tar -czvf backup.tar.gz --null -T - |
try adding -type f for just files to feed to tar. it seems like it is sending tar the . directory.
|
I tried -type f and received the same results. this is weird!
|
Exactly where in the command line did you add that option. The tests in find are a logical expression (the implied operator is AND) that is evaluated left-to-right. If the "-type f" comes after the "-print0" then it won't affect the output.
And without that "-type f" the problem is obvious. One of the items found was "./", and that will cause tar to recursively search the entire directory tree. |
Code:
/export $ find . -depth -mtime 0 -print0 -type f | tar -czvf backup.tar.gz --null -T - Code:
/export $ find . -depth -type f -mtime 0 -print0 | tar -czvf backup.tar.gz --null -T - |
All times are GMT -5. The time now is 05:53 PM. |