How Can I Update a Tar. Gz File?
I Have Created a Tar. Gz File (Using the Gui, Not the Command Line). How Can I Update It with a Command That New Files Are Added and Modified Files Are...
I have created a tar.gz file (using the GUI, not the command line). How can I update it with a command that new files are added and modified files are updated, too?
4 Answers
You'd normally use the -u flag for this. From tar's man page:
-u, --update only append files newer than copy in archive
so this sequence will do what you need:
# First create the tar file. It has to be UNCOMPRESSED for -u to work
tar -cvf my.tar some-directory/
# ... update some files in some-directory
# ... add files in some-directory
# Now update only the changed and added files
tar -uvf my.tar some-directory/
# Compress if desired
gzip my.tar
For a slightly more detailed look, see here:
Must Read
Solution / Workaround
You can not update compressed TAR archive (.tar.gz) in one step. But, if you have enough free space you can do this:
Extract .tar file from .tar.gz file:
gunzip filename.tar.gzUpdate uncompressed .tar file with
tar -ucommand:tar -uf filename.tar new_fileCompress the updated .tar file:
gzip filename.tar