pax is an archive utility somewhere between cpio and tar. This is just because is independent of the specific archive format, and supports a wide variety of different archive formats. It can perform simple tasks as creating a compressed archive of a selected directory or it can as much easily create a daily incremental backups. In this short article we will see how to protect our daily work by creating an incremental backup with pax.

First we need to create a directory where we intend to store our daily backups. As a root user create a directory /usr/local/backup/lilo and make an user liloto be an owner:

# mkdir -p /usr/local/backup/lilo
# chown lilo.lilo /usr/local/backup/lilo 

At this point we are ready. Since we do not have any backup yet first we need to create a full backup. Switch back to a user lilo ( use your user name ) and execute:

$ pax -wvf /usr/local/backup/lilo/$(date +%Y%m%d) ~/

The command above will create a directory as a today's date and copy all of your data from your home directory to a new backup directory. The backup for today is done. Next day after work we create an incremental backup ( copy only new or changed files ) with a following command:

$ pax -T 0000 -wvf /usr/local/backup/lilo/$(date +%Y%m%d) ~/

Note that -T option will instruct a pax command to copy only files changed and created since last midnight. You can continue to do an incremental backup indefinitely. However, it is recommended to do a full back at least once a week or month, this depends on the nature of your work. You can also consider to use pax's -z option to create compressed archives if you are concerned about a disk space.

It is obvious that the backup example we have just shown, would not safe us from a hardware failure of our hard drive as we have only copied all data locally within a single file system. From this reason consider to backup onto your USB removable media or using remotely using NFS and etc.

Free Linux eBooks

Go to top