Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
Add/update a file to an existing tar.gz archive?

I have some game files I wish to update daily and they create a tar.gz of the folder, but instead of making a full tar.gz of all the files over again each day I'm trying to find a way to have it check the directory for files changed/added/deleted and update the archive to save time and CPU instead of recreating the archive from scratch every day. How can I do this?

I was trying to use --listed-incremented with no luck so far.

share|improve this question

migrated from serverfault.com Nov 28 '11 at 16:03

This question came from our site for professional system and network administrators.

marked as duplicate by Michael Mrozek Nov 28 '11 at 16:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

You must create a level 0 backup first:

$ tar --create --verbose --listed-incremental ./game.snar --gzip \
    --file game_`date +%F`.tar.gz game/

and the next day, this command compress only files changed since the creation of the ./game.snar:

$ tar --create --verbose --listed-incremental ./game.snar --gzip \
    --file game_`date +%F`.tar.gz game/

This archive is called a level 1 backup.

When you want to restore, put all archive files into a folder and extract each in order of their creation using the --incremental option, something like this:

$ for t in game_2011-10-2*.tar.gz; \
    do tar --verbose --extract --incremental --gzip --file $t; done
share|improve this answer