pax is an archive utility somewhere between
tar. This is just because it 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 backup.
In this tutorial, we will see how to protect our daily work by creating an incremental backup with
pax on a Linux system. On certain Linux distributions, this command may not be installed by default. In this case, you’ll need to install it manually. We’ll include instructions for that below.
In this tutorial you will learn:
- How to install
paxon major Linux distros
- How to use
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Install pax in Linux
paxis not already installed on your system by default, you can use the appropriate command below to install it with your system’s package manager.
pax on Ubuntu, Debian, and Linux Mint:
$ sudo apt install pax
pax on Fedora, CentOS, AlmaLinux, and Red Hat:
$ sudo dnf install pax
pax on Arch Linux and Manjaro:
$ sudo pacman -S pax
Frequently Used Options
Once you have some files that need to be backed up, you can use the
pax command to create an initial backup, and then use it again in the future to only back up the incremental changes. This saves a lot of disk space when compared to full backups, and is much faster and more efficient.
See some examples below for an idea on how to get started with
pax Command in Linux Examples
- To make a backup of a directory, we will supply the
-wmeans write, telling
paxthat we wish to write a backup.
-vis just verbose, so that we can see the backup process unfolding as
paxprocesses our request. And
-fallows us to specify the path to our backup file we create.
$ pax -wvfz mybackup.pax ~/myfiles
This command has created a backup named
mybackup.paxof the directory
- To create an incremental backup, we can use the
-Toption to instruct
paxcommand to copy only files changed and created since 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, but the frequency will depend on the nature of your work. Note we also add the date to our incremental backup in the command below.
$ pax -T 0000 -wvf mybackup-$(date +%Y%m%d).pax ~/myfiles
- You can also add the
-zoption to create compressed archives if you are concerned about disk space.
$ pax -wvfz mybackup.pax ~/myfiles
- We can use the
-rcommand to read our pax file and extract its contents. We will still keep the
-foptions in our command in order to see verbose output and specify the pax file we wish to open.
$ pax -rvf mybackup.pax ~/myfiles
You can always use the man command to read more about the pax command and its official documentation. Click the previous link to see how to open the manual pages for any command on a Linux system.
In this tutorial, we saw how to install and use the pax command on a Linux system. Pax is a handy tool, similar to other staples on Linux like
cpio. It works especially well for creating incremental backups because it lets us specify how old a file should be in order to be part of the backup.