From Wiki-UX.info

Wiki-UX / Backup Commands / How to use pax
Jump to: navigation, search

How to use pax

Abstract

This article is a quick reference on the usage of the pax command on the HP-UX Operating Environment. A review of the current HP-UX Reference Mainpages is highly advisable for additional examples, syntax description and relevant warnings or notifications.

Contents


Name

pax — extracts, writes, and lists archive files; copies files and directory hierarchies

Synopsis

Writing Archive Files

pax -w [-adituvXy] [-H|-L] [-b blocking] [-f archive] [-o options]... [-s replstr]... [-x format] [file]...

Listing Member Files of Archived Files

pax [-cdnv] [-H|-L] [-f archive] [-o options]... [-s replstr]... [pattern]...

Extracting Archive Files

pax -r [-cdiknuvy] [-H|-L] [-f archive] [-o options]... [-p string]... [-s replstr]... [pattern]...

Copying Files

pax -r -w [-diklntuvXy] [-H|-L] [-o options]... [-p string]... [-s replstr]... [file]... directory

Writing archive

# pax -wv -f /var/tmp/archive.pax /tmp
/tmp/
/tmp/.AgentSockets/
pax: /tmp/.AgentSockets/A : Skipped socket file.
/tmp/lost+found/
/tmp/.kc.trace
/tmp/rpcbind.file
/tmp/ACL.log
/tmp/X11_newfonts.log
/tmp/core
/tmp/install.vars
/tmp/ipv6agt.crashlog
/tmp/portmap.file
/tmp/primary.dd
/tmp/man003006
/tmp/man010501
/tmp/man023686
/tmp/mirror.dd
/tmp/ntlc.3375
/tmp/llbdbase.dat
/tmp/.s.PGSQL.10864.lock
/tmp/sd_ipd_acl.2705
/tmp/swlist
/tmp/kern-verify.17801
pax: /tmp/.s.PGSQL.10864 : Skipped socket file.
/tmp/5991-5974.cdimage
/tmp/reports
/tmp/void.psf
/tmp/root.mail
/tmp/man021907
/tmp/man006071
/tmp/dhcpvalidate
/tmp/vxportal
/tmp/nbp.efi
/tmp/1111io_listener.log
/tmp/ign_configure/
/tmp/vg01.mapfile
/tmp/.s.PGSQL.50006.lock
pax: /tmp/.s.PGSQL.50006 : Skipped socket file.
/tmp/kern-verify.3285
/tmp/test

Listing archive

# pax -vf /var/tmp/archive.pax
USTAR format archive
drwxrwxrwt  0 root     root              Jan  1 16:28 /tmp/
drwx------  0 root     root              Dec 20 15:51 /tmp/.AgentSockets/
drwxr-xr-x  0 root     root              Oct 10 14:16 /tmp/lost+found/
-rw-rw-rw-  0 root     sys           229 Dec 27 12:19 /tmp/.kc.trace
-rw-------  0 root     root         3616 Dec 20 15:45 /tmp/rpcbind.file
-rw-r--r--  0 root     sys             0 Oct 12 15:09 /tmp/ACL.log
-rw-r--r--  0 root     sys           808 Oct 10 19:07 /tmp/X11_newfonts.log
-rw-------  0 root     sys        941856 Oct 24 16:52 /tmp/core
-r--r--r--  0 root     sys          1292 Oct 10 14:18 /tmp/install.vars
-rw-r--r--  0 root     root            0 Dec 20 15:51 /tmp/ipv6agt.crashlog
-rw-------  0 root     root          744 Dec 20 15:45 /tmp/portmap.file
-rw-rw-rw-  0 root     sys          8192 Nov 13 16:20 /tmp/primary.dd
-rw-------  0 root     sys         37498 Oct 11 12:54 /tmp/man003006
-rw-------  0 root     sys         14795 Oct 16 16:32 /tmp/man010501
-rw-------  0 root     sys          6041 Oct 18 17:41 /tmp/man023686
-rw-rw-rw-  0 root     sys          8192 Nov 13 16:20 /tmp/mirror.dd
-rw-r--r--  0 root     sys          9711 Oct 10 21:54 /tmp/ntlc.3375
-r--r--r--  0 root     root            0 Dec 20 15:51 /tmp/llbdbase.dat
-rw-------  0 sfmdb    users          26 Jan  1 16:27 /tmp/.s.PGSQL.10864.lock
-rw-r--r--  0 root     sys            53 Oct 10 21:50 /tmp/sd_ipd_acl.2705
-rw-r--r--  0 root     sys             0 Oct 10 17:38 /tmp/swlist
-rw-r--r--  0 root     sys          3899 Oct 29 07:51 /tmp/kern-verify.17801
-rw-rw-rw-  0 root     sys      17649664 Nov 14 10:21 /tmp/5991-5974.cdimage
-rw-rw-rw-  0 root     sys          1025 Nov 22 11:23 /tmp/reports
-rw-rw-rw-  0 root     sys            34 Nov 22 11:44 /tmp/void.psf
-rw-rw-rw-  0 root     sys        169677 Nov 27 11:36 /tmp/root.mail
-rw-------  0 root     sys          3685 Nov 28 15:14 /tmp/man021907
-rw-------  0 root     sys          7352 Dec  7 14:53 /tmp/man006071
-rw-r--r--  0 root     sys           226 Dec  7 17:02 /tmp/dhcpvalidate
crw-r--r--  0 root     sys       97,   0 Oct 10 17:10 /tmp/vxportal
-rw-r--r--  0 root     sys             0 Dec  7 17:13 /tmp/nbp.efi
-rw-------  0 root     sys             0 Dec 14 17:02 /tmp/1111io_listener.log
drwxr-xr-x  0 root     root              Dec 10 14:08 /tmp/ign_configure/
-rw-rw-rw-  0 root     sys            30 Dec 18 13:24 /tmp/vg01.mapfile
-rw-------  0 hpsmdb   users          27 Jan  1 16:26 /tmp/.s.PGSQL.50006.lock
-rw-r--r--  0 root     sys          4065 Dec 27 12:19 /tmp/kern-verify.3285
-rw-rw-rw-  0 root     sys        177572 Dec 28 10:18 /tmp/test

Extracting archives

# pax -rv -p e -f /var/tmp/archive.pax

Copying Files

# mkdir /var/temp/test
 
# pax -vrw /tmp /var/tmp/test
/var/tmp/test/tmp
/var/tmp/test/tmp/.AgentSockets
pax: /tmp/.AgentSockets/A : Skipped socket file.
/var/tmp/test/tmp/lost+found
/var/tmp/test/tmp/.kc.trace
/var/tmp/test/tmp/rpcbind.file
/var/tmp/test/tmp/ACL.log
/var/tmp/test/tmp/X11_newfonts.log
/var/tmp/test/tmp/core
/var/tmp/test/tmp/install.vars
/var/tmp/test/tmp/ipv6agt.crashlog
/var/tmp/test/tmp/portmap.file
/var/tmp/test/tmp/primary.dd
/var/tmp/test/tmp/man003006
/var/tmp/test/tmp/man010501
/var/tmp/test/tmp/man023686
/var/tmp/test/tmp/mirror.dd
/var/tmp/test/tmp/ntlc.3375
/var/tmp/test/tmp/llbdbase.dat
/var/tmp/test/tmp/.s.PGSQL.10864.lock
/var/tmp/test/tmp/sd_ipd_acl.2705
/var/tmp/test/tmp/swlist
/var/tmp/test/tmp/kern-verify.17801
pax: /tmp/.s.PGSQL.10864 : Skipped socket file.
/var/tmp/test/tmp/5991-5974.cdimage
/var/tmp/test/tmp/reports
/var/tmp/test/tmp/void.psf
/var/tmp/test/tmp/root.mail
/var/tmp/test/tmp/man021907
/var/tmp/test/tmp/man006071
/var/tmp/test/tmp/dhcpvalidate
/var/tmp/test/tmp/vxportal
/var/tmp/test/tmp/nbp.efi
/var/tmp/test/tmp/1111io_listener.log
/var/tmp/test/tmp/ign_configure
/var/tmp/test/tmp/vg01.mapfile
/var/tmp/test/tmp/.s.PGSQL.50006.lock
pax: /tmp/.s.PGSQL.50006 : Skipped socket file.
/var/tmp/test/tmp/kern-verify.3285
/var/tmp/test/tmp/test

The previous procedure will replicate the full directory hierarchy. That means that under /var/tmp/test a new "test" directory will be created, ending with "/var/tmp/test/tmp/".

To copy the "/tmp" contents without creating the directory hierarchy use relative paths. For example:

# mkdir /var/temp
 
# cd /tmp
 
# pwd
  /tmp
 
# pax -vrw –p e ./ /var/temp
  • Note: Notice the use of the -p e option to retain the files permissions.

Extracting archives to relative directories

The -s flag allows the path file name substitution. You can use the following pattern to easily extract a pax archive to a relative directory: -s '%^/%<relative_path>/%'

# pax -rv -p e -s '%^/%/var/tmp/test/%' -f /var/tmp/archive.pax
USTAR format archive
/var/tmp/test/tmp/
/var/tmp/test/tmp/.AgentSockets/
/var/tmp/test/tmp/lost+found/
/var/tmp/test/tmp/.kc.trace
/var/tmp/test/tmp/rpcbind.file
/var/tmp/test/tmp/ACL.log
/var/tmp/test/tmp/X11_newfonts.log
/var/tmp/test/tmp/core
/var/tmp/test/tmp/install.vars
/var/tmp/test/tmp/ipv6agt.crashlog
/var/tmp/test/tmp/portmap.file
/var/tmp/test/tmp/primary.dd
/var/tmp/test/tmp/man003006
/var/tmp/test/tmp/man010501
/var/tmp/test/tmp/man023686
/var/tmp/test/tmp/mirror.dd
/var/tmp/test/tmp/ntlc.3375
/var/tmp/test/tmp/llbdbase.dat
/var/tmp/test/tmp/.s.PGSQL.10864.lock
/var/tmp/test/tmp/sd_ipd_acl.2705
/var/tmp/test/tmp/swlist
/var/tmp/test/tmp/kern-verify.17801
/var/tmp/test/tmp/5991-5974.cdimage
/var/tmp/test/tmp/reports
/var/tmp/test/tmp/void.psf
/var/tmp/test/tmp/root.mail
/var/tmp/test/tmp/man021907
/var/tmp/test/tmp/man006071
/var/tmp/test/tmp/dhcpvalidate
/var/tmp/test/tmp/vxportal
/var/tmp/test/tmp/nbp.efi
/var/tmp/test/tmp/1111io_listener.log
/var/tmp/test/tmp/ign_configure/
/var/tmp/test/tmp/vg01.mapfile
/var/tmp/test/tmp/.s.PGSQL.50006.lock
/var/tmp/test/tmp/kern-verify.3285
/var/tmp/test/tmp/test

Archiving files larger than 8 GB

The pax command defaults to ustar interchange format. That format does not support archiving files larger than 8 GB. Files larger than 8GB can be saved using pax using the pax interchange format (18,446,744,073,709,551,616 bytes). To enable this format, use -x pax flag.

Example:

# pax -x pax -wv -p e -f /var/tmp/archive.pax /tmp
NOTE: Files larger than 8GB are supported by default on the pax command version included on HP-UX 11i v3. On HP-UX 11i v2 installing the PAX-Enh bundle is required to extend the size limits of the pax command. This bundle requires patch PHCO_38165 or superseded version. The software is available at HP Software Depot: PAX-Enh


NOTE: The pax command does not support files larger that 8GB on HP-UX 11i v1.


Using pax to backup splitted /dev/vg00

This is a very common backup procedure used to have a snapshot backup of /dev/vg00 or any other volume group using the LVM "lvsplit / lvmerge" commands. This is a highly adapted script based on a VIRGINIA MILITARY INSTITUTE case 3600479314. The main idea is to create a fbackup graph file compatible method using the pax command, since fbackup has been superseded on HP-UX 11i Version 3 (11.31).

Graph File

# cat /mnt/backup/split_vg00.graph
i /lvol1b
i /lvol3b
i /lvol4b
i /lvol5b
i /lvol6b
i /lvol7b
i /lvol8b
i /lvol9b
#/usr/bin/sh
# History: This program was written on 2008.01.01 as a fbackup to pax conversion
# modeled on a Virginia Militar Institute script. The script ommits /dev/vg00/lvol2
# since this is the swap logical volume.
 
LOGFILE=/mnt/backup/logs/`date +"%0y%m%d.%R"`
GRAPH=/mnt/backup/split_vg00.graph
STOREMED=/mnt/backup/latest.pax
 
# STEP 1. Splitting the mirrors
 
for COUNT in 1 3 4 5 6 7 8 9
do
   /usr/sbin/lvsplit /dev/vg00/lvol$COUNT
done
 
# STEP 2. Check and mount the volumes
 
/sbin/fsck -F hfs /dev/vg00/rlvol1b
/sbin/mkdir /lvol1b
/sbin/mount -F hfs -o ro /dev/vg00/lvol1b /lvol1b
 
for COUNT in 3 4 5 6 7 8 9
do
   /sbin/fsck -F vxfs /dev/vg00/rlvol$COUNTb
   /sbin/mkdir /lvol$COUNTb
   /usr/sbin/mount -F vxfs -o ro /dev/vg00/lvol$COUNTb /lvol$COUNTb
done
 
# STEP 3. Make backup to tape using pax
# -w: Puts the pax in writing mode.
# -v: Verbose mode, output redirected ( 2> ) to proper log file.
# -f: file or tape device on $STOREMED
# Pax do not use graph files. Usage awk code to convert fbackup graph file to pax compatible command line
 
/sbin/pax -wv -x pax -p e -f $STOREMED 2> $LOGFILE `cat $GRAPH | awk '{if ($1 == "i") printf "%s ", $2}'`
 
# STEP 4. Unmount and remege the mirrors
 
for COUNT in 1 3 4 5 6 7 8 9 # lvol2 ommited
do
   fuser -k /dev/vg00/lvol$COUNTb # Ensure there are not running processes on the logical volume
   /sbin/umount /lvol$COUNTb
   /sbin/lvmerge /dev/vg00/lvol$COUNTb /dev/vg00/lvol$COUNT
   /usr/bin/rmdir /lvol$COUNTb
done
# History: This program was written on 2008.01.01 as a fbackup to pax conversion
# modeled on a Virginia Militar Institute script. The script recovers the content
# of the backup in a temporary directory /tmp/tapetest with enough space to contain
# the full volume group.
 
GRAPH=/mnt/backup/split_vg00.graph
STOREMED=/mnt/backup/latest.pax
 
# Step 1. Clean the directory to start fresh
 
if [ -d /tmp/tapetest ]
   then rm -rf /tmp/tapetest/* ]
fi
 
if [ ! -d /tmp/tapetest ]
   then mkdir /tmp/tapetest ]
fi
 
# Step 2. Extract the select files / directories from a fbackup compatible graph file.
 
/sbin/pax -rv -p e -s '%^/%/tmp/tapetest/%' -f $STOREMED

Reference

Authors

Editor

This page was last modified on 20 April 2011, at 19:44. This page has been accessed 5,173 times.