LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Creating Differential Backups with Tar (https://www.linuxquestions.org/questions/linux-newbie-8/creating-differential-backups-with-tar-638411/)

FeX_05 04-28-2008 11:15 AM

Creating Differential Backups with Tar
 
Hey guys,

Im trying to figure out how to create differential backups using the tar command. I have looked in the man pages and I know that the --diff option is primarily used for this task. However I just having problems figuring the syntax for this.

I have tried tar --diff /backup1 -f /backup2 /home and variations of it but clearly having problems.

In addition, I was wondering if the timestamps option (-g) would work by just creating 1 timestamp and comparing each day of the week with that particular timestamp until a full backup has to be completed.

Something like:

tar cv -g /snapshot -f /backup /home

However wouldnt the snapshot file continue to be updated when I run a new backup command thus resulting back to incremental?

Hope someone can help! Thanks in advanced.

jschiwal 04-29-2008 03:55 AM

A differential backup will backup changes since the first full backup.

You didn't enough of Section 5.2 of the tar info manual. Just after the instructions to create an incremental backup (the first incremental backup), it explains how to create a subsequent level.1 (differential) backup:
Code:

The created archive `archive.2.tar' will contain only these three
members.  This archive is called a "level 1 backup".  Notice that
`/var/log/usr.snar' will be updated with the new data, so if you plan
to create more `level 1' backups, it is necessary to create a working
copy of the snapshot file before running `tar'.  The above example will
then be modified as follows:

    $ cp /var/log/usr.snar /var/log/usr.snar-1
    $ tar --create \
                --file=archive.2.tar \
                --listed-incremental=/var/log/usr.snar-1 \
                /usr

Just keep copying the initial snapshot file and use the copy for the -g (--listed-incremental) argument. Then the files modified from the initial backup will be backed up because you are using the snapshot file from the initial full backup.


All times are GMT -5. The time now is 01:37 AM.