4 The command line client is called :command:`proxmox-backup-client`.
10 The client uses the following notation to specify a datastore repository
13 [[username@]server[:port]:]datastore
15 The default value for ``username`` is ``root@pam``. If no server is specified,
16 the default is the local host (``localhost``).
18 You can specify a port if your backup server is only reachable on a different
19 port (e.g. with NAT and port forwarding).
21 Note that if the server is an IPv6 address, you have to write it with square
22 brackets (for example, `[fe80::01]`).
24 You can pass the repository with the ``--repository`` command line option, or
25 by setting the ``PBS_REPOSITORY`` environment variable.
27 Here some examples of valid repositories and the real values
29 ================================ ================== ================== ===========
30 Example User Host:Port Datastore
31 ================================ ================== ================== ===========
32 mydatastore ``root@pam`` localhost:8007 mydatastore
33 myhostname:mydatastore ``root@pam`` myhostname:8007 mydatastore
34 user@pbs@myhostname:mydatastore ``user@pbs`` myhostname:8007 mydatastore
35 user\@pbs!token@host:store ``user@pbs!token`` myhostname:8007 mydatastore
36 192.168.55.55:1234:mydatastore ``root@pam`` 192.168.55.55:1234 mydatastore
37 [ff80::51]:mydatastore ``root@pam`` [ff80::51]:8007 mydatastore
38 [ff80::51]:1234:mydatastore ``root@pam`` [ff80::51]:1234 mydatastore
39 ================================ ================== ================== ===========
45 The default backup repository.
48 When set, this value is used for the password required for the backup server.
49 You can also set this to a API token secret.
51 ``PBS_ENCRYPTION_PASSWORD``
52 When set, this value is used to access the secret encryption key (if
53 protected by password).
55 ``PBS_FINGERPRINT`` When set, this value is used to verify the server
56 certificate (only used if the system CA certificates cannot validate the
63 Most commands support the ``--output-format`` parameter. It accepts
66 :``text``: Text format (default). Structured data is rendered as a table.
68 :``json``: JSON (single line).
70 :``json-pretty``: JSON (multiple lines, nicely formatted).
73 Please use the following environment variables to modify output behavior:
75 ``PROXMOX_OUTPUT_FORMAT``
76 Defines the default output format.
78 ``PROXMOX_OUTPUT_NO_BORDER``
79 If set (to any value), do not render table borders.
81 ``PROXMOX_OUTPUT_NO_HEADER``
82 If set (to any value), do not render table headers.
84 .. note:: The ``text`` format is designed to be human readable, and
85 not meant to be parsed by automation tools. Please use the ``json``
86 format if you need to process the output.
94 This section explains how to create a backup from within the machine. This can
95 be a physical host, a virtual machine, or a container. Such backups may contain file
96 and image archives. There are no restrictions in this case.
98 .. note:: If you want to backup virtual machines or containers on Proxmox VE, see :ref:`pve-integration`.
100 For the following example you need to have a backup server set up, working
101 credentials and need to know the repository name.
102 In the following examples we use ``backup-server:store1``.
104 .. code-block:: console
106 # proxmox-backup-client backup root.pxar:/ --repository backup-server:store1
107 Starting backup: host/elsa/2019-12-03T09:35:01Z
109 skip mount point: "/boot/efi"
110 skip mount point: "/dev"
111 skip mount point: "/run"
112 skip mount point: "/sys"
113 Uploaded 12129 chunks in 87 seconds (564 MB/s).
114 End Time: 2019-12-03T10:36:29+01:00
116 This will prompt you for a password and then uploads a file archive named
117 ``root.pxar`` containing all the files in the ``/`` directory.
119 .. Caution:: Please note that the proxmox-backup-client does not
120 automatically include mount points. Instead, you will see a short
121 ``skip mount point`` notice for each of them. The idea is to
122 create a separate file archive for each mounted disk. You can
123 explicitly include them using the ``--include-dev`` option
124 (i.e. ``--include-dev /boot/efi``). You can use this option
125 multiple times for each mount point that should be included.
127 The ``--repository`` option can get quite long and is used by all
128 commands. You can avoid having to enter this value by setting the
129 environment variable ``PBS_REPOSITORY``. Note that if you would like this to remain set
130 over multiple sessions, you should instead add the below line to your
133 .. code-block:: console
135 # export PBS_REPOSITORY=backup-server:store1
137 After this you can execute all commands without specifying the ``--repository``
140 One single backup is allowed to contain more than one archive. For example, if
141 you want to backup two disks mounted at ``/mnt/disk1`` and ``/mnt/disk2``:
143 .. code-block:: console
145 # proxmox-backup-client backup disk1.pxar:/mnt/disk1 disk2.pxar:/mnt/disk2
147 This creates a backup of both disks.
149 The backup command takes a list of backup specifications, which
150 include the archive name on the server, the type of the archive, and the
151 archive source at the client. The format is:
153 <archive-name>.<type>:<source-path>
155 Common types are ``.pxar`` for file archives, and ``.img`` for block
156 device images. To create a backup of a block device run the following command:
158 .. code-block:: console
160 # proxmox-backup-client backup mydata.img:/dev/mylvm/mydata
163 Excluding files/folders from a backup
164 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
166 Sometimes it is desired to exclude certain files or folders from a backup archive.
167 To tell the Proxmox Backup client when and how to ignore files and directories,
168 place a text file called ``.pxarexclude`` in the filesystem hierarchy.
169 Whenever the backup client encounters such a file in a directory, it interprets
170 each line as glob match patterns for files and directories that are to be excluded
173 The file must contain a single glob pattern per line. Empty lines are ignored.
174 The same is true for lines starting with ``#``, which indicates a comment.
175 A ``!`` at the beginning of a line reverses the glob match pattern from an exclusion
176 to an explicit inclusion. This makes it possible to exclude all entries in a
177 directory except for a few single files/subdirectories.
178 Lines ending in ``/`` match only on directories.
179 The directory containing the ``.pxarexclude`` file is considered to be the root of
180 the given patterns. It is only possible to match files in this directory and its subdirectories.
182 ``\`` is used to escape special glob characters.
183 ``?`` matches any single character.
184 ``*`` matches any character, including an empty string.
185 ``**`` is used to match subdirectories. It can be used to, for example, exclude
186 all files ending in ``.tmp`` within the directory or subdirectories with the
187 following pattern ``**/*.tmp``.
188 ``[...]`` matches a single character from any of the provided characters within
189 the brackets. ``[!...]`` does the complementary and matches any single character
190 not contained within the brackets. It is also possible to specify ranges with two
191 characters separated by ``-``. For example, ``[a-z]`` matches any lowercase
192 alphabetic character and ``[0-9]`` matches any one single digit.
194 The order of the glob match patterns defines whether a file is included or
195 excluded, that is to say later entries override previous ones.
196 This is also true for match patterns encountered deeper down the directory tree,
197 which can override a previous exclusion.
198 Be aware that excluded directories will **not** be read by the backup client.
199 Thus, a ``.pxarexclude`` file in an excluded subdirectory will have no effect.
200 ``.pxarexclude`` files are treated as regular files and will be included in the
203 For example, consider the following directory structure:
205 .. code-block:: console
209 . .. .pxarexclude subfolder0 subfolder1
212 . .. file0 file1 file2 file3 .pxarexclude
215 . .. file0 file1 file2 file3
217 The different ``.pxarexclude`` files contain the following:
219 .. code-block:: console
221 # cat folder/.pxarexclude
226 .. code-block:: console
228 # cat folder/subfolder0/.pxarexclude
231 This would exclude ``file1`` and ``file3`` in ``subfolder0`` and all of
232 ``subfolder1`` except ``file2``.
234 Restoring this backup will result in:
236 .. code-block:: console
240 . .. .pxarexclude subfolder0 subfolder1
243 . .. file0 file2 .pxarexclude
254 Proxmox Backup supports client-side encryption with AES-256 in GCM_
255 mode. To set this up, you first need to create an encryption key:
257 .. code-block:: console
259 # proxmox-backup-client key create my-backup.key
260 Encryption Key Password: **************
262 The key is password protected by default. If you do not need this
263 extra protection, you can also create it without a password:
265 .. code-block:: console
267 # proxmox-backup-client key create /path/to/my-backup.key --kdf none
269 Having created this key, it is now possible to create an encrypted backup, by
270 passing the ``--keyfile`` parameter, with the path to the key file.
272 .. code-block:: console
274 # proxmox-backup-client backup etc.pxar:/etc --keyfile /path/to/my-backup.key
276 Encryption Key Password: **************
279 .. Note:: If you do not specify the name of the backup key, the key will be
280 created in the default location
281 ``~/.config/proxmox-backup/encryption-key.json``. ``proxmox-backup-client``
282 will also search this location by default, in case the ``--keyfile``
283 parameter is not specified.
285 You can avoid entering the passwords by setting the environment
286 variables ``PBS_PASSWORD`` and ``PBS_ENCRYPTION_PASSWORD``.
289 Using a master key to store and recover encryption keys
290 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
292 You can also use ``proxmox-backup-client key`` to create an RSA public/private
293 key pair, which can be used to store an encrypted version of the symmetric
294 backup encryption key alongside each backup and recover it later.
296 To set up a master key:
298 1. Create an encryption key for the backup:
300 .. code-block:: console
302 # proxmox-backup-client key create
303 creating default key at: "~/.config/proxmox-backup/encryption-key.json"
304 Encryption Key Password: **********
307 The resulting file will be saved to ``~/.config/proxmox-backup/encryption-key.json``.
309 2. Create an RSA public/private key pair:
311 .. code-block:: console
313 # proxmox-backup-client key create-master-key
314 Master Key Password: *********
317 This will create two files in your current directory, ``master-public.pem``
318 and ``master-private.pem``.
320 3. Import the newly created ``master-public.pem`` public certificate, so that
321 ``proxmox-backup-client`` can find and use it upon backup.
323 .. code-block:: console
325 # proxmox-backup-client key import-master-pubkey /path/to/master-public.pem
326 Imported public master key to "~/.config/proxmox-backup/master-public.pem"
328 4. With all these files in place, run a backup job:
330 .. code-block:: console
332 # proxmox-backup-client backup etc.pxar:/etc
334 The key will be stored in your backup, under the name ``rsa-encrypted.key``.
336 .. Note:: The ``--keyfile`` parameter can be excluded, if the encryption key
337 is in the default path. If you specified another path upon creation, you
338 must pass the ``--keyfile`` parameter.
340 5. To test that everything worked, you can restore the key from the backup:
342 .. code-block:: console
344 # proxmox-backup-client restore /path/to/backup/ rsa-encrypted.key /path/to/target
346 .. Note:: You should not need an encryption key to extract this file. However, if
347 a key exists at the default location
348 (``~/.config/proxmox-backup/encryption-key.json``) the program will prompt
349 you for an encryption key password. Simply moving ``encryption-key.json``
350 out of this directory will fix this issue.
352 6. Then, use the previously generated master key to decrypt the file:
354 .. code-block:: console
356 # openssl rsautl -decrypt -inkey master-private.pem -in rsa-encrypted.key -out /path/to/target
357 Enter pass phrase for ./master-private.pem: *********
359 7. The target file will now contain the encryption key information in plain
360 text. The success of this can be confirmed by passing the resulting ``json``
361 file, with the ``--keyfile`` parameter, when decrypting files from the backup.
363 .. warning:: Without their key, backed up files will be inaccessible. Thus, you should
364 keep keys ordered and in a place that is separate from the contents being
365 backed up. It can happen, for example, that you back up an entire system, using
366 a key on that system. If the system then becomes inaccessible for any reason
367 and needs to be restored, this will not be possible as the encryption key will be
368 lost along with the broken system.
370 It is recommended that you keep your master key safe, but easily accessible, in
371 order for quick disaster recovery. For this reason, the best place to store it
372 is in your password manager, where it is immediately recoverable. As a backup to
373 this, you should also save the key to a USB drive and store that in a secure
374 place. This way, it is detached from any system, but is still easy to recover
375 from, in case of emergency. Finally, in preparation for the worst case scenario,
376 you should also consider keeping a paper copy of your master key locked away in
377 a safe place. The ``paperkey`` subcommand can be used to create a QR encoded
378 version of your master key. The following command sends the output of the
379 ``paperkey`` command to a text file, for easy printing.
381 .. code-block:: console
383 proxmox-backup-client key paperkey --output-format text > qrkey.txt
389 The regular creation of backups is a necessary step to avoiding data
390 loss. More importantly, however, is the restoration. It is good practice to perform
391 periodic recovery tests to ensure that you can access the data in
394 First, you need to find the snapshot which you want to restore. The snapshot
395 command provides a list of all the snapshots on the server:
397 .. code-block:: console
399 # proxmox-backup-client snapshots
400 ┌────────────────────────────────┬─────────────┬────────────────────────────────────┐
401 │ snapshot │ size │ files │
402 ╞════════════════════════════════╪═════════════╪════════════════════════════════════╡
403 │ host/elsa/2019-12-03T09:30:15Z │ 51788646825 │ root.pxar catalog.pcat1 index.json │
404 ├────────────────────────────────┼─────────────┼────────────────────────────────────┤
405 │ host/elsa/2019-12-03T09:35:01Z │ 51790622048 │ root.pxar catalog.pcat1 index.json │
406 ├────────────────────────────────┼─────────────┼────────────────────────────────────┤
409 You can inspect the catalog to find specific files.
411 .. code-block:: console
413 # proxmox-backup-client catalog dump host/elsa/2019-12-03T09:35:01Z
415 d "./root.pxar.didx/etc/cifs-utils"
416 l "./root.pxar.didx/etc/cifs-utils/idmap-plugin"
417 d "./root.pxar.didx/etc/console-setup"
420 The restore command lets you restore a single archive from the
423 .. code-block:: console
425 # proxmox-backup-client restore host/elsa/2019-12-03T09:35:01Z root.pxar /target/path/
427 To get the contents of any archive, you can restore the ``index.json`` file in the
428 repository to the target path '-'. This will dump the contents to the standard output.
430 .. code-block:: console
432 # proxmox-backup-client restore host/elsa/2019-12-03T09:35:01Z index.json -
438 If you only want to restore a few individual files, it is often easier
439 to use the interactive recovery shell.
441 .. code-block:: console
443 # proxmox-backup-client catalog shell host/elsa/2019-12-03T09:35:01Z root.pxar
444 Starting interactive shell
446 bin boot dev etc home lib lib32
449 The interactive recovery shell is a minimal command line interface that
450 utilizes the metadata stored in the catalog to quickly list, navigate and
451 search files in a file archive.
452 To restore files, you can select them individually or match them with a glob
455 Using the catalog for navigation reduces the overhead considerably because only
456 the catalog needs to be downloaded and, optionally, decrypted.
457 The actual chunks are only accessed if the metadata in the catalog is not enough
458 or for the actual restore.
460 Similar to common UNIX shells ``cd`` and ``ls`` are the commands used to change
461 working directory and list directory contents in the archive.
462 ``pwd`` shows the full path of the current working directory with respect to the
465 Being able to quickly search the contents of the archive is a commonly needed feature.
466 That's where the catalog is most valuable.
469 .. code-block:: console
471 pxar:/ > find etc/**/*.txt --select
473 pxar:/ > list-selected
475 pxar:/ > restore-selected /target/path
478 This will find and print all files ending in ``.txt`` located in ``etc/`` or a
479 subdirectory and add the corresponding pattern to the list for subsequent restores.
480 ``list-selected`` shows these patterns and ``restore-selected`` finally restores
481 all files in the archive matching the patterns to ``/target/path`` on the local
482 host. This will scan the whole archive.
484 With ``restore /target/path`` you can restore the sub-archive given by the current
485 working directory to the local target path ``/target/path`` on your host.
486 By additionally passing a glob pattern with ``--pattern <glob>``, the restore is
487 further limited to files matching the pattern.
490 .. code-block:: console
493 pxar:/etc/ > restore /target/ --pattern **/*.conf
496 The above will scan trough all the directories below ``/etc`` and restore all
497 files ending in ``.conf``.
499 .. todo:: Explain interactive restore in more detail
501 Mounting of Archives via FUSE
502 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
504 The :term:`FUSE` implementation for the pxar archive allows you to mount a
505 file archive as a read-only filesystem to a mountpoint on your host.
507 .. code-block:: console
509 # proxmox-backup-client mount host/backup-client/2020-01-29T11:29:22Z root.pxar /mnt/mountpoint
511 bin dev home lib32 libx32 media opt root sbin sys usr
512 boot etc lib lib64 lost+found mnt proc run srv tmp var
514 This allows you to access the full contents of the archive in a seamless manner.
516 .. note:: As the FUSE connection needs to fetch and decrypt chunks from the
517 backup server's datastore, this can cause some additional network and CPU
518 load on your host, depending on the operations you perform on the mounted
521 To unmount the filesystem use the ``umount`` command on the mountpoint:
523 .. code-block:: console
525 # umount /mnt/mountpoint
530 The client tool prompts you to enter the logon password as soon as you
531 want to access the backup server. The server checks your credentials
532 and responds with a ticket that is valid for two hours. The client
533 tool automatically stores that ticket and uses it for further requests
536 You can also manually trigger this login/logout using the login and
539 .. code-block:: console
541 # proxmox-backup-client login
544 To remove the ticket, issue a logout:
546 .. code-block:: console
548 # proxmox-backup-client logout
551 .. _changing-backup-owner:
553 Changing the Owner of a Backup Group
554 ------------------------------------
556 By default, the owner of a backup group is the user which was used to originally
557 create that backup group (or in the case of sync jobs, ``root@pam``). This
558 means that if a user ``mike@pbs`` created a backup, another user ``john@pbs``
559 can not be used to create backups in that same backup group. In case you want
560 to change the owner of a backup, you can do so with the below command, using a
561 user that has ``Datastore.Modify`` privileges on the datastore.
563 .. code-block:: console
565 # proxmox-backup-client change-owner vm/103 john@pbs
567 This can also be done from within the web interface, by navigating to the
568 `Content` section of the datastore that contains the backup group and
569 selecting the user icon under the `Actions` column. Common cases for this could
570 be to change the owner of a sync job from ``root@pam``, or to repurpose a
576 Pruning and Removing Backups
577 ----------------------------
579 You can manually delete a backup snapshot using the ``forget``
582 .. code-block:: console
584 # proxmox-backup-client forget <snapshot>
587 .. caution:: This command removes all archives in this backup
588 snapshot. They will be inaccessible and unrecoverable.
591 Although manual removal is sometimes required, the ``prune``
592 command is normally used to systematically delete older backups. Prune lets
593 you specify which backup snapshots you want to keep. The
594 following retention options are available:
597 Keep the last ``<N>`` backup snapshots.
599 ``--keep-hourly <N>``
600 Keep backups for the last ``<N>`` hours. If there is more than one
601 backup for a single hour, only the latest is kept.
604 Keep backups for the last ``<N>`` days. If there is more than one
605 backup for a single day, only the latest is kept.
607 ``--keep-weekly <N>``
608 Keep backups for the last ``<N>`` weeks. If there is more than one
609 backup for a single week, only the latest is kept.
611 .. note:: Weeks start on Monday and end on Sunday. The software
612 uses the `ISO week date`_ system and handles weeks at
613 the end of the year correctly.
615 ``--keep-monthly <N>``
616 Keep backups for the last ``<N>`` months. If there is more than one
617 backup for a single month, only the latest is kept.
619 ``--keep-yearly <N>``
620 Keep backups for the last ``<N>`` years. If there is more than one
621 backup for a single year, only the latest is kept.
623 The retention options are processed in the order given above. Each option
624 only covers backups within its time period. The next option does not take care
625 of already covered backups. It will only consider older backups.
627 Unfinished and incomplete backups will be removed by the prune command unless
628 they are newer than the last successful backup. In this case, the last failed
631 .. code-block:: console
633 # proxmox-backup-client prune <group> --keep-daily 7 --keep-weekly 4 --keep-monthly 3
636 You can use the ``--dry-run`` option to test your settings. This only
637 shows the list of existing snapshots and what actions prune would take.
639 .. code-block:: console
641 # proxmox-backup-client prune host/elsa --dry-run --keep-daily 1 --keep-weekly 3
642 ┌────────────────────────────────┬──────┐
644 ╞════════════════════════════════╪══════╡
645 │ host/elsa/2019-12-04T13:20:37Z │ 1 │
646 ├────────────────────────────────┼──────┤
647 │ host/elsa/2019-12-03T09:35:01Z │ 0 │
648 ├────────────────────────────────┼──────┤
649 │ host/elsa/2019-11-22T11:54:47Z │ 1 │
650 ├────────────────────────────────┼──────┤
651 │ host/elsa/2019-11-21T12:36:25Z │ 0 │
652 ├────────────────────────────────┼──────┤
653 │ host/elsa/2019-11-10T10:42:20Z │ 1 │
654 └────────────────────────────────┴──────┘
656 .. note:: Neither the ``prune`` command nor the ``forget`` command free space
657 in the chunk-store. The chunk-store still contains the data blocks. To free
658 space you need to perform :ref:`garbage-collection`.
661 .. _garbage-collection:
666 The ``prune`` command removes only the backup index files, not the data
667 from the datastore. This task is left to the garbage collection
668 command. It is recommended to carry out garbage collection on a regular basis.
670 The garbage collection works in two phases. In the first phase, all
671 data blocks that are still in use are marked. In the second phase,
672 unused data blocks are removed.
674 .. note:: This command needs to read all existing backup index files
675 and touches the complete chunk-store. This can take a long time
676 depending on the number of chunks and the speed of the underlying
679 .. note:: The garbage collection will only remove chunks that haven't been used
680 for at least one day (exactly 24h 5m). This grace period is necessary because
681 chunks in use are marked by touching the chunk which updates the ``atime``
682 (access time) property. Filesystems are mounted with the ``relatime`` option
683 by default. This results in a better performance by only updating the
684 ``atime`` property if the last access has been at least 24 hours ago. The
685 downside is, that touching a chunk within these 24 hours will not always
686 update its ``atime`` property.
688 Chunks in the grace period will be logged at the end of the garbage
689 collection task as *Pending removals*.
691 .. code-block:: console
693 # proxmox-backup-client garbage-collect
694 starting garbage collection on store store2
695 Start GC phase1 (mark used chunks)
696 Start GC phase2 (sweep unused chunks)
697 percentage done: 1, chunk count: 219
698 percentage done: 2, chunk count: 453
700 percentage done: 99, chunk count: 21188
701 Removed bytes: 411368505
703 Original data bytes: 327160886391
704 Disk bytes: 52767414743 (16 %)
706 Average chunk size: 2486565
710 .. todo:: howto run garbage-collection at regular intervals (cron)
715 The backup client also comes with a benchmarking tool. This tool measures
716 various metrics relating to compression and encryption speeds. You can run a
717 benchmark using the ``benchmark`` subcommand of ``proxmox-backup-client``:
719 .. code-block:: console
721 # proxmox-backup-client benchmark
722 Uploaded 656 chunks in 5 seconds.
723 Time per request: 7659 microseconds.
724 TLS speed: 547.60 MB/s
725 SHA256 speed: 585.76 MB/s
726 Compression speed: 1923.96 MB/s
727 Decompress speed: 7885.24 MB/s
728 AES256/GCM speed: 3974.03 MB/s
729 ┌───────────────────────────────────┬─────────────────────┐
731 ╞═══════════════════════════════════╪═════════════════════╡
732 │ TLS (maximal backup upload speed) │ 547.60 MB/s (93%) │
733 ├───────────────────────────────────┼─────────────────────┤
734 │ SHA256 checksum computation speed │ 585.76 MB/s (28%) │
735 ├───────────────────────────────────┼─────────────────────┤
736 │ ZStd level 1 compression speed │ 1923.96 MB/s (89%) │
737 ├───────────────────────────────────┼─────────────────────┤
738 │ ZStd level 1 decompression speed │ 7885.24 MB/s (98%) │
739 ├───────────────────────────────────┼─────────────────────┤
740 │ AES256 GCM encryption speed │ 3974.03 MB/s (104%) │
741 └───────────────────────────────────┴─────────────────────┘
743 .. note:: The percentages given in the output table correspond to a
744 comparison against a Ryzen 7 2700X. The TLS test connects to the
745 local host, so there is no network involved.
747 You can also pass the ``--output-format`` parameter to output stats in ``json``,
748 rather than the default table format.