2023-06-27 14:40:08 +02:00
`` pxar `` is a command-line utility for creating and manipulating archives in the
2020-02-20 18:55:29 +01:00
:ref: `pxar-format` .
It is inspired by `casync file archive format
<http://0pointer.net/blog/casync-a-tool-for-distributing-file-system-images.html> `_,
2020-04-14 17:12:47 +02:00
which caters to a similar use-case.
2023-11-24 18:43:43 +01:00
The `` .pxar `` format is adapted to fulfill the specific needs of the
`Proxmox Backup`_ Server, for example, efficient storage of hard links.
2021-10-11 17:15:19 +02:00
The format is designed to reduce the required storage on the server by
achieving a high level of deduplication.
2020-02-20 18:55:29 +01:00
Creating an Archive
^^^^^^^^^^^^^^^^^^^
Run the following command to create an archive of a folder named `` source `` :
.. code-block :: console
2020-07-28 09:24:04 +02:00
# pxar create archive.pxar /path/to/source
2020-02-20 18:55:29 +01:00
2020-04-14 17:12:47 +02:00
This will create a new archive called `` archive.pxar `` with the contents of the
2020-02-20 18:55:29 +01:00
`` source `` folder.
.. NOTE :: `` pxar `` will not overwrite any existing archives. If an archive with
the same name is already present in the target folder, the creation will
fail.
2021-10-11 17:15:19 +02:00
By default, `` pxar `` will skip certain mount points and will not follow device
2020-02-20 18:55:29 +01:00
boundaries. This design decision is based on the primary use case of creating
2021-10-11 17:15:19 +02:00
archives for backups. It makes sense to ignore the contents of certain
temporary or system specific files in a backup.
2020-04-14 17:12:47 +02:00
To alter this behavior and follow device boundaries, use the
2020-02-20 18:55:29 +01:00
`` --all-file-systems `` flag.
It is possible to exclude certain files and/or folders from the archive by
2020-07-28 09:24:04 +02:00
passing the `` --exclude `` parameter with `` gitignore ` ` \-style match patterns.
2020-02-20 18:55:29 +01:00
For example, you can exclude all files ending in `` .txt `` from the archive
by running:
.. code-block :: console
2020-07-28 09:24:04 +02:00
# pxar create archive.pxar /path/to/source --exclude '**/* .txt'
2020-02-20 18:55:29 +01:00
2021-10-11 17:15:19 +02:00
Be aware that the shell itself will try to expand glob patterns before invoking
`` pxar `` . In order to avoid this, all globs have to be quoted correctly.
2020-10-02 16:12:57 +02:00
2020-07-28 09:24:04 +02:00
It is possible to pass the `` --exclude `` parameter multiple times, in order to
match more than one pattern. This allows you to use more complex
2021-10-11 17:15:19 +02:00
file inclusion/exclusion behavior. However, it is recommended to use
2020-02-20 18:55:29 +01:00
`` .pxarexclude `` files instead for such cases.
2021-10-11 17:15:19 +02:00
For example you might want to exclude all `` .txt `` files except a specific
one from the archive. This would be achieved via the negated match pattern,
prefixed by `` ! `` . All the glob patterns are relative to the `` source ``
directory.
2020-02-20 18:55:29 +01:00
.. code-block :: console
2020-07-28 09:24:04 +02:00
# pxar create archive.pxar /path/to/source --exclude '**/* .txt' --exclude '!/folder/file.txt'
2020-02-20 18:55:29 +01:00
2021-10-11 17:15:19 +02:00
.. NOTE :: The order of the glob match patterns matters, as later ones override
earlier ones. Permutations of the same patterns lead to different results.
2020-02-20 18:55:29 +01:00
`` pxar `` will store the list of glob match patterns passed as parameters via the
2021-10-11 17:15:19 +02:00
command line, in a file called `` .pxarexclude-cli `` , at the root of the archive.
2020-02-20 18:55:29 +01:00
If a file with this name is already present in the source folder during archive
2021-10-11 17:15:19 +02:00
creation, this file is not included in the archive, and the file containing the
new patterns is added to the archive instead. The original file is not altered.
2020-02-20 18:55:29 +01:00
A more convenient and persistent way to exclude files from the archive is by
placing the glob match patterns in `` .pxarexclude `` files.
It is possible to create and place these files in any directory of the filesystem
tree.
2021-10-11 17:15:19 +02:00
These files must contain one pattern per line, and later patterns override
earlier ones.
2020-04-14 17:12:47 +02:00
The patterns control file exclusions of files present within the given directory
2020-02-20 18:55:29 +01:00
or further below it in the tree.
2021-02-05 16:10:29 +01:00
The behavior is the same as described in :ref: `client_creating_backups` .
2020-02-20 18:55:29 +01:00
Extracting an Archive
^^^^^^^^^^^^^^^^^^^^^
2020-08-18 12:48:49 +02:00
An existing archive, `` archive.pxar `` , is extracted to a `` target `` directory
2020-02-20 18:55:29 +01:00
with the following command:
.. code-block :: console
2020-08-18 12:48:49 +02:00
# pxar extract archive.pxar /path/to/target
2020-02-20 18:55:29 +01:00
2021-10-11 17:15:19 +02:00
If no target is provided, the contents of the archive is extracted to the current
2020-02-20 18:55:29 +01:00
working directory.
2020-08-18 12:48:49 +02:00
In order to restore only parts of an archive, single files, and/or folders,
2020-02-20 18:55:29 +01:00
it is possible to pass the corresponding glob match patterns as additional
2020-08-18 12:48:49 +02:00
parameters or to use the patterns stored in a file:
2020-02-20 18:55:29 +01:00
.. code-block :: console
2020-08-18 12:48:49 +02:00
# pxar extract etc.pxar /restore/target/etc --pattern '**/* .conf'
2020-02-20 18:55:29 +01:00
The above example restores all `` .conf `` files encountered in any of the
sub-folders in the archive `` etc.pxar `` to the target `` /restore/target/etc `` .
A path to the file containing match patterns can be specified using the
`` --files-from `` parameter.
2020-04-14 17:12:47 +02:00
List the Contents of an Archive
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020-02-20 18:55:29 +01:00
To display the files and directories contained in an archive `` archive.pxar `` ,
run the following command:
.. code-block :: console
# pxar list archive.pxar
This displays the full path of each file or directory with respect to the
2021-10-11 17:15:19 +02:00
archive's root.
2020-02-20 18:55:29 +01:00
Mounting an Archive
^^^^^^^^^^^^^^^^^^^
`` pxar `` allows you to mount and inspect the contents of an archive via _`FUSE` .
2021-10-11 17:15:19 +02:00
In order to mount an archive named `` archive.pxar `` to the mount point `` /mnt `` ,
2020-02-20 18:55:29 +01:00
run the command:
.. code-block :: console
# pxar mount archive.pxar /mnt
Once the archive is mounted, you can access its content under the given
2021-10-11 17:15:19 +02:00
mount point.
2020-02-20 18:55:29 +01:00
.. code-block :: console
# cd /mnt
# ls
bin dev home lib32 libx32 media opt root sbin sys usr
boot etc lib lib64 lost+found mnt proc run srv tmp var
2019-11-17 17:12:41 +01:00