Next | Prev | Up | Top | Contents | Index

Saving Data With tar

This section describes how to backup files with the tar command, and how you can back up files that have been modified since a certain specific time, or relative to the last backup (incrementally).


Backing Up Files With tar

To back up individual files with tar, use the command:

tar c file


Saving Files by Modification Date

The tar command does not have the capability of saving files by modification date built in. However, you can use the find command to archive files that have not been modified in a particular number of days:

find /usr -mtime 5 -local -type f -o -type othertypes -print | tar cv -

The find command locates regular, local (non-NFS) files that have not been modified in five days. The find command sends its output to the tar command.


Incremental Backups With tar

Although tar does not have a built-in mechanisms for incremental backups, you can use other system commands to accomplish this task.

The following example uses the same incremental scheme presented in the preceding section to back up the /usr filesystem. It uses the find command to determine which files to archive:

  1. Go to the top of the filesystem that you want to back up. For example:

    cd /usr

  2. Create a complete backup of the filesystem:

    tar cv .

  3. Each day, back up the files that have changed since the previous daily backup:

    find /usr -mtime 1 -local -print | tar cvf -

  4. Every week, back up the files that have changed since the last weekly backup:

    find /usr -mtime 7 -local -type f -print | tar cvf -

  5. At the end of four weeks, perform a complete backup and start the process over.

Next | Prev | Up | Top | Contents | Index