]> git.proxmox.com Git - proxmox-backup.git/blob - docs/administration-guide.rst
docs: fix wrong user in repository explanation
[proxmox-backup.git] / docs / administration-guide.rst
1 Backup Management
2 =================
3
4 .. The administration guide.
5 .. todo:: either add a bit more explanation or remove the previous sentence
6
7 Terminology
8 -----------
9
10 Backup Content
11 ~~~~~~~~~~~~~~
12
13 When doing deduplication, there are different strategies to get
14 optimal results in terms of performance and/or deduplication rates.
15 Depending on the type of data, it can be split into *fixed* or *variable*
16 sized chunks.
17
18 Fixed sized chunking requires minimal CPU power, and is used to
19 backup virtual machine images.
20
21 Variable sized chunking needs more CPU power, but is essential to get
22 good deduplication rates for file archives.
23
24 The Proxmox Backup Server supports both strategies.
25
26
27 Image Archives: ``<name>.img``
28 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29
30 This is used for virtual machine images and other large binary
31 data. Content is split into fixed-sized chunks.
32
33
34 File Archives: ``<name>.pxar``
35 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36
37 .. see https://moinakg.wordpress.com/2013/06/22/high-performance-content-defined-chunking/
38
39 A file archive stores a full directory tree. Content is stored using
40 the :ref:`pxar-format`, split into variable-sized chunks. The format
41 is optimized to achieve good deduplication rates.
42
43
44 Binary Data (BLOBs)
45 ^^^^^^^^^^^^^^^^^^^
46
47 This type is used to store smaller (< 16MB) binary data such as
48 configuration files. Larger files should be stored as image archive.
49
50 .. caution:: Please do not store all files as BLOBs. Instead, use the
51 file archive to store whole directory trees.
52
53
54 Catalog File: ``catalog.pcat1``
55 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56
57 The catalog file is an index for file archives. It contains
58 the list of files and is used to speed up search operations.
59
60
61 The Manifest: ``index.json``
62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
64 The manifest contains the list of all backup files, their
65 sizes and checksums. It is used to verify the consistency of a
66 backup.
67
68
69 Backup Type
70 ~~~~~~~~~~~
71
72 The backup server groups backups by *type*, where *type* is one of:
73
74 ``vm``
75 This type is used for :term:`virtual machine`\ s. Typically
76 consists of the virtual machine's configuration file and an image archive
77 for each disk.
78
79 ``ct``
80 This type is used for :term:`container`\ s. Consists of the container's
81 configuration and a single file archive for the filesystem content.
82
83 ``host``
84 This type is used for backups created from within the backed up machine.
85 Typically this would be a physical host but could also be a virtual machine
86 or container. Such backups may contain file and image archives, there are no restrictions in this regard.
87
88
89 Backup ID
90 ~~~~~~~~~
91
92 A unique ID. Usually the virtual machine or container ID. ``host``
93 type backups normally use the hostname.
94
95
96 Backup Time
97 ~~~~~~~~~~~
98
99 The time when the backup was made.
100
101
102 Backup Group
103 ~~~~~~~~~~~~
104
105 The tuple ``<type>/<ID>`` is called a backup group. Such a group
106 may contain one or more backup snapshots.
107
108
109 Backup Snapshot
110 ~~~~~~~~~~~~~~~
111
112 The triplet ``<type>/<ID>/<time>`` is called a backup snapshot. It
113 uniquely identifies a specific backup within a datastore.
114
115 .. code-block:: console
116 :caption: Backup Snapshot Examples
117
118 vm/104/2019-10-09T08:01:06Z
119 host/elsa/2019-11-08T09:48:14Z
120
121 As you can see, the time format is RFC3399_ with Coordinated
122 Universal Time (UTC_, identified by the trailing *Z*).
123
124 Backup Server Management
125 ------------------------
126
127 The command line tool to configure and manage the backup server is called
128 :command:`proxmox-backup-manager`.
129
130 .. _datastore_intro:
131
132 :term:`DataStore`
133 ~~~~~~~~~~~~~~~~~
134
135 A datastore refers to a location at which backups are stored. The current
136 implementation uses a directory inside a standard unix file system (``ext4``,
137 ``xfs`` or ``zfs``) to store the backup data.
138
139 Datastores are identified by a simple *ID*. You can configure this
140 when setting up the datastore. The configuration information for datastores
141 is stored in the file ``/etc/proxmox-backup/datastore.cfg``.
142
143 .. note:: The `File Layout`_ requires the file system to support at least *65538*
144 subdirectories per directory. That number comes from the 2\ :sup:`16`
145 pre-created chunk namespace directories, and the ``.`` and ``..`` default
146 directory entries. This requirement excludes certain filesystems and
147 filesystem configuration from being supported for a datastore. For example,
148 ``ext3`` as a whole or ``ext4`` with the ``dir_nlink`` feature manually disabled.
149
150 Disk Management
151 ~~~~~~~~~~~~~~~
152
153 .. image:: images/screenshots/pbs-gui-disks.png
154 :align: right
155 :alt: List of disks
156
157 Proxmox Backup Server comes with a set of disk utilities, which are
158 accessed using the ``disk`` subcommand. This subcommand allows you to initialize
159 disks, create various filesystems, and get information about the disks.
160
161 To view the disks connected to the system, navigate to **Administration ->
162 Disks** in the web interface or use the ``list`` subcommand of
163 ``disk``:
164
165 .. code-block:: console
166
167 # proxmox-backup-manager disk list
168 ┌──────┬────────┬─────┬───────────┬─────────────┬───────────────┬─────────┬────────┐
169 │ name │ used │ gpt │ disk-type │ size │ model │ wearout │ status │
170 ╞══════╪════════╪═════╪═══════════╪═════════════╪═══════════════╪═════════╪════════╡
171 │ sda │ lvm │ 1 │ hdd │ 34359738368 │ QEMU_HARDDISK │ - │ passed │
172 ├──────┼────────┼─────┼───────────┼─────────────┼───────────────┼─────────┼────────┤
173 │ sdb │ unused │ 1 │ hdd │ 68719476736 │ QEMU_HARDDISK │ - │ passed │
174 ├──────┼────────┼─────┼───────────┼─────────────┼───────────────┼─────────┼────────┤
175 │ sdc │ unused │ 1 │ hdd │ 68719476736 │ QEMU_HARDDISK │ - │ passed │
176 └──────┴────────┴─────┴───────────┴─────────────┴───────────────┴─────────┴────────┘
177
178 To initialize a disk with a new GPT, use the ``initialize`` subcommand:
179
180 .. code-block:: console
181
182 # proxmox-backup-manager disk initialize sdX
183
184 .. image:: images/screenshots/pbs-gui-disks-dir-create.png
185 :align: right
186 :alt: Create a directory
187
188 You can create an ``ext4`` or ``xfs`` filesystem on a disk using ``fs
189 create``, or by navigating to **Administration -> Disks -> Directory** in the
190 web interface and creating one from there. The following command creates an
191 ``ext4`` filesystem and passes the ``--add-datastore`` parameter, in order to
192 automatically create a datastore on the disk (in this case ``sdd``). This will
193 create a datastore at the location ``/mnt/datastore/store1``:
194
195 .. code-block:: console
196
197 # proxmox-backup-manager disk fs create store1 --disk sdd --filesystem ext4 --add-datastore true
198
199 .. image:: images/screenshots/pbs-gui-disks-zfs-create.png
200 :align: right
201 :alt: Create ZFS
202
203 You can also create a ``zpool`` with various raid levels from **Administration
204 -> Disks -> Zpool** in the web interface, or by using ``zpool create``. The command
205 below creates a mirrored ``zpool`` using two disks (``sdb`` & ``sdc``) and
206 mounts it on the root directory (default):
207
208 .. code-block:: console
209
210 # proxmox-backup-manager disk zpool create zpool1 --devices sdb,sdc --raidlevel mirror
211
212 .. note:: You can also pass the ``--add-datastore`` parameter here, to automatically
213 create a datastore from the disk.
214
215 You can use ``disk fs list`` and ``disk zpool list`` to keep track of your
216 filesystems and zpools respectively.
217
218 Proxmox Backup Server uses the package smartmontools. This is a set of tools
219 used to monitor and control the S.M.A.R.T. system for local hard disks. If a
220 disk supports S.M.A.R.T. capability, and you have this enabled, you can
221 display S.M.A.R.T. attributes from the web interface or by using the command:
222
223 .. code-block:: console
224
225 # proxmox-backup-manager disk smart-attributes sdX
226
227 .. note:: This functionality may also be accessed directly through the use of
228 the ``smartctl`` command, which comes as part of the smartmontools package
229 (see ``man smartctl`` for more details).
230
231
232 Datastore Configuration
233 ~~~~~~~~~~~~~~~~~~~~~~~
234
235 .. image:: images/screenshots/pbs-gui-datastore.png
236 :align: right
237 :alt: Datastore Overview
238
239 You can configure multiple datastores. Minimum one datastore needs to be
240 configured. The datastore is identified by a simple *name* and points to a
241 directory on the filesystem. Each datastore also has associated retention
242 settings of how many backup snapshots for each interval of ``hourly``,
243 ``daily``, ``weekly``, ``monthly``, ``yearly`` as well as a time-independent
244 number of backups to keep in that store. :ref:`Pruning <pruning>` and
245 :ref:`garbage collection <garbage-collection>` can also be configured to run
246 periodically based on a configured schedule (see :ref:`calendar-events`) per datastore.
247
248 Creating a Datastore
249 ^^^^^^^^^^^^^^^^^^^^
250 .. image:: images/screenshots/pbs-gui-datastore-create-general.png
251 :align: right
252 :alt: Create a datastore
253
254 You can create a new datastore from the web GUI, by navigating to **Datastore** in
255 the menu tree and clicking **Create**. Here:
256
257 * *Name* refers to the name of the datastore
258 * *Backing Path* is the path to the directory upon which you want to create the
259 datastore
260 * *GC Schedule* refers to the time and intervals at which garbage collection
261 runs
262 * *Prune Schedule* refers to the frequency at which pruning takes place
263 * *Prune Options* set the amount of backups which you would like to keep (see :ref:`Pruning <pruning>`).
264
265 Alternatively you can create a new datastore from the command line. The
266 following command creates a new datastore called ``store1`` on :file:`/backup/disk1/store1`
267
268 .. code-block:: console
269
270 # proxmox-backup-manager datastore create store1 /backup/disk1/store1
271
272 Managing Datastores
273 ^^^^^^^^^^^^^^^^^^^
274
275 To list existing datastores from the command line run:
276
277 .. code-block:: console
278
279 # proxmox-backup-manager datastore list
280 ┌────────┬──────────────────────┬─────────────────────────────┐
281 │ name │ path │ comment │
282 ╞════════╪══════════════════════╪═════════════════════════════╡
283 │ store1 │ /backup/disk1/store1 │ This is my default storage. │
284 └────────┴──────────────────────┴─────────────────────────────┘
285
286 You can change the garbage collection and prune settings of a datastore, by
287 editing the datastore from the GUI or by using the ``update`` subcommand. For
288 example, the below command changes the garbage collection schedule using the
289 ``update`` subcommand and prints the properties of the datastore with the
290 ``show`` subcommand:
291
292 .. code-block:: console
293
294 # proxmox-backup-manager datastore update store1 --gc-schedule 'Tue 04:27'
295 # proxmox-backup-manager datastore show store1
296 ┌────────────────┬─────────────────────────────┐
297 │ Name │ Value │
298 ╞════════════════╪═════════════════════════════╡
299 │ name │ store1 │
300 ├────────────────┼─────────────────────────────┤
301 │ path │ /backup/disk1/store1 │
302 ├────────────────┼─────────────────────────────┤
303 │ comment │ This is my default storage. │
304 ├────────────────┼─────────────────────────────┤
305 │ gc-schedule │ Tue 04:27 │
306 ├────────────────┼─────────────────────────────┤
307 │ keep-last │ 7 │
308 ├────────────────┼─────────────────────────────┤
309 │ prune-schedule │ daily │
310 └────────────────┴─────────────────────────────┘
311
312 Finally, it is possible to remove the datastore configuration:
313
314 .. code-block:: console
315
316 # proxmox-backup-manager datastore remove store1
317
318 .. note:: The above command removes only the datastore configuration. It does
319 not delete any data from the underlying directory.
320
321
322 File Layout
323 ^^^^^^^^^^^
324
325 After creating a datastore, the following default layout will appear:
326
327 .. code-block:: console
328
329 # ls -arilh /backup/disk1/store1
330 276493 -rw-r--r-- 1 backup backup 0 Jul 8 12:35 .lock
331 276490 drwxr-x--- 1 backup backup 1064960 Jul 8 12:35 .chunks
332
333 `.lock` is an empty file used for process locking.
334
335 The `.chunks` directory contains folders, starting from `0000` and taking hexadecimal values until `ffff`. These
336 directories will store the chunked data after a backup operation has been executed.
337
338 .. code-block:: console
339
340 # ls -arilh /backup/disk1/store1/.chunks
341 545824 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 ffff
342 545823 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffe
343 415621 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffd
344 415620 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffc
345 353187 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffb
346 344995 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffa
347 144079 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fff9
348 144078 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fff8
349 144077 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fff7
350 ...
351 403180 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 000c
352 403179 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 000b
353 403177 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 000a
354 402530 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0009
355 402513 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0008
356 402509 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0007
357 276509 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0006
358 276508 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0005
359 276507 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0004
360 276501 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0003
361 276499 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0002
362 276498 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0001
363 276494 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0000
364 276489 drwxr-xr-x 3 backup backup 4.0K Jul 8 12:35 ..
365 276490 drwxr-x--- 1 backup backup 1.1M Jul 8 12:35 .
366
367 .. _user_mgmt:
368
369 User Management
370 ~~~~~~~~~~~~~~~
371
372 .. image:: images/screenshots/pbs-gui-user-management.png
373 :align: right
374 :alt: User management
375
376 Proxmox Backup Server supports several authentication realms, and you need to
377 choose the realm when you add a new user. Possible realms are:
378
379 :pam: Linux PAM standard authentication. Use this if you want to
380 authenticate as Linux system user (Users need to exist on the
381 system).
382
383 :pbs: Proxmox Backup Server realm. This type stores hashed passwords in
384 ``/etc/proxmox-backup/shadow.json``.
385
386 After installation, there is a single user ``root@pam``, which
387 corresponds to the Unix superuser. User configuration information is stored in the file
388 ``/etc/proxmox-backup/user.cfg``. You can use the
389 ``proxmox-backup-manager`` command line tool to list or manipulate
390 users:
391
392 .. code-block:: console
393
394 # proxmox-backup-manager user list
395 ┌─────────────┬────────┬────────┬───────────┬──────────┬────────────────┬────────────────────┐
396 │ userid │ enable │ expire │ firstname │ lastname │ email │ comment │
397 ╞═════════════╪════════╪════════╪═══════════╪══════════╪════════════════╪════════════════════╡
398 │ root@pam │ 1 │ │ │ │ │ Superuser │
399 └─────────────┴────────┴────────┴───────────┴──────────┴────────────────┴────────────────────┘
400
401 .. image:: images/screenshots/pbs-gui-user-management-add-user.png
402 :align: right
403 :alt: Add a new user
404
405 The superuser has full administration rights on everything, so you
406 normally want to add other users with less privileges. You can create a new
407 user with the ``user create`` subcommand or through the web interface, under
408 **Configuration -> User Management**. The ``create`` subcommand lets you specify
409 many options like ``--email`` or ``--password``. You can update or change any
410 user properties using the ``update`` subcommand later (**Edit** in the GUI):
411
412
413 .. code-block:: console
414
415 # proxmox-backup-manager user create john@pbs --email john@example.com
416 # proxmox-backup-manager user update john@pbs --firstname John --lastname Smith
417 # proxmox-backup-manager user update john@pbs --comment "An example user."
418
419 .. todo:: Mention how to set password without passing plaintext password as cli argument.
420
421
422 The resulting user list looks like this:
423
424 .. code-block:: console
425
426 # proxmox-backup-manager user list
427 ┌──────────┬────────┬────────┬───────────┬──────────┬──────────────────┬──────────────────┐
428 │ userid │ enable │ expire │ firstname │ lastname │ email │ comment │
429 ╞══════════╪════════╪════════╪═══════════╪══════════╪══════════════════╪══════════════════╡
430 │ john@pbs │ 1 │ │ John │ Smith │ john@example.com │ An example user. │
431 ├──────────┼────────┼────────┼───────────┼──────────┼──────────────────┼──────────────────┤
432 │ root@pam │ 1 │ │ │ │ │ Superuser │
433 └──────────┴────────┴────────┴───────────┴──────────┴──────────────────┴──────────────────┘
434
435 Newly created users do not have any permissions. Please read the next
436 section to learn how to set access permissions.
437
438 If you want to disable a user account, you can do that by setting ``--enable`` to ``0``
439
440 .. code-block:: console
441
442 # proxmox-backup-manager user update john@pbs --enable 0
443
444 Or completely remove the user with:
445
446 .. code-block:: console
447
448 # proxmox-backup-manager user remove john@pbs
449
450
451 .. _user_acl:
452
453 Access Control
454 ~~~~~~~~~~~~~~
455
456 By default new users do not have any permission. Instead you need to
457 specify what is allowed and what is not. You can do this by assigning
458 roles to users on specific objects like datastores or remotes. The
459 following roles exist:
460
461 **NoAccess**
462 Disable Access - nothing is allowed.
463
464 **Admin**
465 Can do anything.
466
467 **Audit**
468 Can view things, but is not allowed to change settings.
469
470 **DatastoreAdmin**
471 Can do anything on datastores.
472
473 **DatastoreAudit**
474 Can view datastore settings and list content. But
475 is not allowed to read the actual data.
476
477 **DatastoreReader**
478 Can Inspect datastore content and can do restores.
479
480 **DatastoreBackup**
481 Can backup and restore owned backups.
482
483 **DatastorePowerUser**
484 Can backup, restore, and prune owned backups.
485
486 **RemoteAdmin**
487 Can do anything on remotes.
488
489 **RemoteAudit**
490 Can view remote settings.
491
492 **RemoteSyncOperator**
493 Is allowed to read data from a remote.
494
495 .. image:: images/screenshots/pbs-gui-permissions-add.png
496 :align: right
497 :alt: Add permissions for user
498
499 Access permission information is stored in ``/etc/proxmox-backup/acl.cfg``. The
500 file contains 5 fields, separated using a colon (':') as a delimiter. A typical
501 entry takes the form:
502
503 ``acl:1:/datastore:john@pbs:DatastoreBackup``
504
505 The data represented in each field is as follows:
506
507 #. ``acl`` identifier
508 #. A ``1`` or ``0``, representing whether propagation is enabled or disabled,
509 respectively
510 #. The object on which the permission is set. This can be a specific object
511 (single datastore, remote, etc.) or a top level object, which with
512 propagation enabled, represents all children of the object also.
513 #. The user for which the permission is set
514 #. The role being set
515
516 You can manage datastore permissions from **Configuration -> Permissions** in the
517 web interface. Likewise, you can use the ``acl`` subcommand to manage and
518 monitor user permissions from the command line. For example, the command below
519 will add the user ``john@pbs`` as a **DatastoreAdmin** for the datastore
520 ``store1``, located at ``/backup/disk1/store1``:
521
522 .. code-block:: console
523
524 # proxmox-backup-manager acl update /datastore/store1 DatastoreAdmin --userid john@pbs
525
526 You can monitor the roles of each user using the following command:
527
528 .. code-block:: console
529
530 # proxmox-backup-manager acl list
531 ┌──────────┬──────────────────┬───────────┬────────────────┐
532 │ ugid │ path │ propagate │ roleid │
533 ╞══════════╪══════════════════╪═══════════╪════════════════╡
534 │ john@pbs │ /datastore/disk1 │ 1 │ DatastoreAdmin │
535 └──────────┴──────────────────┴───────────┴────────────────┘
536
537 A single user can be assigned multiple permission sets for different datastores.
538
539 .. Note::
540 Naming convention is important here. For datastores on the host,
541 you must use the convention ``/datastore/{storename}``. For example, to set
542 permissions for a datastore mounted at ``/mnt/backup/disk4/store2``, you would use
543 ``/datastore/store2`` for the path. For remote stores, use the convention
544 ``/remote/{remote}/{storename}``, where ``{remote}`` signifies the name of the
545 remote (see `Remote` below) and ``{storename}`` is the name of the datastore on
546 the remote.
547
548 Network Management
549 ~~~~~~~~~~~~~~~~~~
550
551 Proxmox Backup Server provides both a web interface and a command line tool for
552 network configuration. You can find the configuration options in the web
553 interface under the **Network Interfaces** section of the **Configuration** menu
554 tree item. The command line tool is accessed via the ``network`` subcommand.
555 These interfaces allow you to carry out some basic network management tasks,
556 such as adding, configuring, and removing network interfaces.
557
558 .. note:: Any changes made to the network configuration are not
559 applied, until you click on **Apply Configuration** or enter the ``network
560 reload`` command. This allows you to make many changes at once. It also allows
561 you to ensure that your changes are correct before applying them, as making a
562 mistake here can render the server inaccessible over the network.
563
564 To get a list of available interfaces, use the following command:
565
566 .. code-block:: console
567
568 # proxmox-backup-manager network list
569 ┌───────┬────────┬───────────┬────────┬─────────────┬──────────────┬──────────────┐
570 │ name │ type │ autostart │ method │ address │ gateway │ ports/slaves │
571 ╞═══════╪════════╪═══════════╪════════╪═════════════╪══════════════╪══════════════╡
572 │ bond0 │ bond │ 1 │ static │ x.x.x.x/x │ x.x.x.x │ ens18 ens19 │
573 ├───────┼────────┼───────────┼────────┼─────────────┼──────────────┼──────────────┤
574 │ ens18 │ eth │ 1 │ manual │ │ │ │
575 ├───────┼────────┼───────────┼────────┼─────────────┼──────────────┼──────────────┤
576 │ ens19 │ eth │ 1 │ manual │ │ │ │
577 └───────┴────────┴───────────┴────────┴─────────────┴──────────────┴──────────────┘
578
579 .. image:: images/screenshots/pbs-gui-network-create-bond.png
580 :align: right
581 :alt: Add a network interface
582
583 To add a new network interface, use the ``create`` subcommand with the relevant
584 parameters. For example, you may want to set up a bond, for the purpose of
585 network redundancy. The following command shows a template for creating the bond shown
586 in the list above:
587
588 .. code-block:: console
589
590 # proxmox-backup-manager network create bond0 --type bond --bond_mode active-backup --slaves ens18,ens19 --autostart true --cidr x.x.x.x/x --gateway x.x.x.x
591
592 You can make changes to the configuration of a network interface with the
593 ``update`` subcommand:
594
595 .. code-block:: console
596
597 # proxmox-backup-manager network update bond0 --cidr y.y.y.y/y
598
599 You can also remove a network interface:
600
601 .. code-block:: console
602
603 # proxmox-backup-manager network remove bond0
604
605 The pending changes for the network configuration file will appear at the bottom of the
606 web interface. You can also view these changes, by using the command:
607
608 .. code-block:: console
609
610 # proxmox-backup-manager network changes
611
612 If you would like to cancel all changes at this point, you can either click on
613 the **Revert** button or use the following command:
614
615 .. code-block:: console
616
617 # proxmox-backup-manager network revert
618
619 If you are happy with the changes and would like to write them into the
620 configuration file, select **Apply Configuration**. The corresponding command
621 is:
622
623 .. code-block:: console
624
625 # proxmox-backup-manager network reload
626
627 .. note:: This command and corresponding GUI button rely on the ``ifreload``
628 command, from the package ``ifupdown2``. This package is included within the
629 Proxmox Backup Server installation, however, you may have to install it yourself,
630 if you have installed Proxmox Backup Server on top of Debian or Proxmox VE.
631
632 You can also configure DNS settings, from the **DNS** section
633 of **Configuration** or by using the ``dns`` subcommand of
634 ``proxmox-backup-manager``.
635
636 .. _backup_remote:
637
638 :term:`Remote`
639 ~~~~~~~~~~~~~~
640
641 A remote refers to a separate Proxmox Backup Server installation and a user on that
642 installation, from which you can `sync` datastores to a local datastore with a
643 `Sync Job`. You can configure remotes in the web interface, under **Configuration
644 -> Remotes**. Alternatively, you can use the ``remote`` subcommand. The
645 configuration information for remotes is stored in the file
646 ``/etc/proxmox-backup/remote.cfg``.
647
648 .. image:: images/screenshots/pbs-gui-remote-add.png
649 :align: right
650 :alt: Add a remote
651
652 To add a remote, you need its hostname or ip, a userid and password on the
653 remote, and its certificate fingerprint. To get the fingerprint, use the
654 ``proxmox-backup-manager cert info`` command on the remote, or navigate to
655 **Dashboard** in the remote's web interface and select **Show Fingerprint**.
656
657 .. code-block:: console
658
659 # proxmox-backup-manager cert info |grep Fingerprint
660 Fingerprint (sha256): 64:d3:ff:3a:50:38:53:5a:9b:f7:50:...:ab:fe
661
662 Using the information specified above, you can add a remote from the **Remotes**
663 configuration panel, or by using the command:
664
665 .. code-block:: console
666
667 # proxmox-backup-manager remote create pbs2 --host pbs2.mydomain.example --userid sync@pam --password 'SECRET' --fingerprint 64:d3:ff:3a:50:38:53:5a:9b:f7:50:...:ab:fe
668
669 Use the ``list``, ``show``, ``update``, ``remove`` subcommands of
670 ``proxmox-backup-manager remote`` to manage your remotes:
671
672 .. code-block:: console
673
674 # proxmox-backup-manager remote update pbs2 --host pbs2.example
675 # proxmox-backup-manager remote list
676 ┌──────┬──────────────┬──────────┬───────────────────────────────────────────┬─────────┐
677 │ name │ host │ userid │ fingerprint │ comment │
678 ╞══════╪══════════════╪══════════╪═══════════════════════════════════════════╪═════════╡
679 │ pbs2 │ pbs2.example │ sync@pam │64:d3:ff:3a:50:38:53:5a:9b:f7:50:...:ab:fe │ │
680 └──────┴──────────────┴──────────┴───────────────────────────────────────────┴─────────┘
681 # proxmox-backup-manager remote remove pbs2
682
683 .. _syncjobs:
684
685 Sync Jobs
686 ~~~~~~~~~
687
688 .. image:: images/screenshots/pbs-gui-syncjob-add.png
689 :align: right
690 :alt: Add a Sync Job
691
692 Sync jobs are configured to pull the contents of a datastore on a **Remote** to
693 a local datastore. You can manage sync jobs under **Configuration -> Sync Jobs**
694 in the web interface, or using the ``proxmox-backup-manager sync-job`` command.
695 The configuration information for sync jobs is stored at
696 ``/etc/proxmox-backup/sync.cfg``. To create a new sync job, click the add button
697 in the GUI, or use the ``create`` subcommand. After creating a sync job, you can
698 either start it manually on the GUI or provide it with a schedule (see
699 :ref:`calendar-events`) to run regularly.
700
701 .. code-block:: console
702
703 # proxmox-backup-manager sync-job create pbs2-local --remote pbs2 --remote-store local --store local --schedule 'Wed 02:30'
704 # proxmox-backup-manager sync-job update pbs2-local --comment 'offsite'
705 # proxmox-backup-manager sync-job list
706 ┌────────────┬───────┬────────┬──────────────┬───────────┬─────────┐
707 │ id │ store │ remote │ remote-store │ schedule │ comment │
708 ╞════════════╪═══════╪════════╪══════════════╪═══════════╪═════════╡
709 │ pbs2-local │ local │ pbs2 │ local │ Wed 02:30 │ offsite │
710 └────────────┴───────┴────────┴──────────────┴───────────┴─────────┘
711 # proxmox-backup-manager sync-job remove pbs2-local
712
713
714 Garbage Collection
715 ~~~~~~~~~~~~~~~~~~
716 You can monitor and run :ref:`garbage collection <garbage-collection>` on the
717 Proxmox Backup Server using the ``garbage-collection`` subcommand of
718 ``proxmox-backup-manager``. You can use the ``start`` subcommand to manually start garbage
719 collection on an entire datastore and the ``status`` subcommand to see
720 attributes relating to the :ref:`garbage collection <garbage-collection>`.
721
722
723 Backup Client usage
724 -------------------
725
726 The command line client is called :command:`proxmox-backup-client`.
727
728
729 Repository Locations
730 ~~~~~~~~~~~~~~~~~~~~
731
732 The client uses the following notation to specify a datastore repository
733 on the backup server.
734
735 [[username@]server:]datastore
736
737 The default value for ``username`` ist ``root@pam``. If no server is specified,
738 the default is the local host (``localhost``).
739
740 You can pass the repository with the ``--repository`` command
741 line option, or by setting the ``PBS_REPOSITORY`` environment
742 variable.
743
744
745 Environment Variables
746 ~~~~~~~~~~~~~~~~~~~~~
747
748 ``PBS_REPOSITORY``
749 The default backup repository.
750
751 ``PBS_PASSWORD``
752 When set, this value is used for the password required for the
753 backup server.
754
755 ``PBS_ENCRYPTION_PASSWORD``
756 When set, this value is used to access the secret encryption key (if
757 protected by password).
758
759 ``PBS_FINGERPRINT`` When set, this value is used to verify the server
760 certificate (only used if the system CA certificates cannot
761 validate the certificate).
762
763
764 Output Format
765 ~~~~~~~~~~~~~
766
767 Most commands support the ``--output-format`` parameter. It accepts
768 the following values:
769
770 :``text``: Text format (default). Structured data is rendered as a table.
771
772 :``json``: JSON (single line).
773
774 :``json-pretty``: JSON (multiple lines, nicely formatted).
775
776
777 Please use the following environment variables to modify output behavior:
778
779 ``PROXMOX_OUTPUT_FORMAT``
780 Defines the default output format.
781
782 ``PROXMOX_OUTPUT_NO_BORDER``
783 If set (to any value), do not render table borders.
784
785 ``PROXMOX_OUTPUT_NO_HEADER``
786 If set (to any value), do not render table headers.
787
788 .. note:: The ``text`` format is designed to be human readable, and
789 not meant to be parsed by automation tools. Please use the ``json``
790 format if you need to process the output.
791
792
793 .. _creating-backups:
794
795 Creating Backups
796 ~~~~~~~~~~~~~~~~
797
798 This section explains how to create a backup from within the machine. This can
799 be a physical host, a virtual machine, or a container. Such backups may contain file
800 and image archives. There are no restrictions in this case.
801
802 .. note:: If you want to backup virtual machines or containers on Proxmox VE, see :ref:`pve-integration`.
803
804 For the following example you need to have a backup server set up, working
805 credentials and need to know the repository name.
806 In the following examples we use ``backup-server:store1``.
807
808 .. code-block:: console
809
810 # proxmox-backup-client backup root.pxar:/ --repository backup-server:store1
811 Starting backup: host/elsa/2019-12-03T09:35:01Z
812 Client name: elsa
813 skip mount point: "/boot/efi"
814 skip mount point: "/dev"
815 skip mount point: "/run"
816 skip mount point: "/sys"
817 Uploaded 12129 chunks in 87 seconds (564 MB/s).
818 End Time: 2019-12-03T10:36:29+01:00
819
820 This will prompt you for a password and then uploads a file archive named
821 ``root.pxar`` containing all the files in the ``/`` directory.
822
823 .. Caution:: Please note that the proxmox-backup-client does not
824 automatically include mount points. Instead, you will see a short
825 ``skip mount point`` notice for each of them. The idea is to
826 create a separate file archive for each mounted disk. You can
827 explicitly include them using the ``--include-dev`` option
828 (i.e. ``--include-dev /boot/efi``). You can use this option
829 multiple times for each mount point that should be included.
830
831 The ``--repository`` option can get quite long and is used by all
832 commands. You can avoid having to enter this value by setting the
833 environment variable ``PBS_REPOSITORY``. Note that if you would like this to remain set
834 over multiple sessions, you should instead add the below line to your
835 ``.bashrc`` file.
836
837 .. code-block:: console
838
839 # export PBS_REPOSITORY=backup-server:store1
840
841 After this you can execute all commands without specifying the ``--repository``
842 option.
843
844 One single backup is allowed to contain more than one archive. For example, if
845 you want to backup two disks mounted at ``/mmt/disk1`` and ``/mnt/disk2``:
846
847 .. code-block:: console
848
849 # proxmox-backup-client backup disk1.pxar:/mnt/disk1 disk2.pxar:/mnt/disk2
850
851 This creates a backup of both disks.
852
853 The backup command takes a list of backup specifications, which
854 include the archive name on the server, the type of the archive, and the
855 archive source at the client. The format is:
856
857 <archive-name>.<type>:<source-path>
858
859 Common types are ``.pxar`` for file archives, and ``.img`` for block
860 device images. To create a backup of a block device run the following command:
861
862 .. code-block:: console
863
864 # proxmox-backup-client backup mydata.img:/dev/mylvm/mydata
865
866 Excluding files/folders from a backup
867 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
868
869 Sometimes it is desired to exclude certain files or folders from a backup archive.
870 To tell the Proxmox Backup client when and how to ignore files and directories,
871 place a text file called ``.pxarexclude`` in the filesystem hierarchy.
872 Whenever the backup client encounters such a file in a directory, it interprets
873 each line as glob match patterns for files and directories that are to be excluded
874 from the backup.
875
876 The file must contain a single glob pattern per line. Empty lines are ignored.
877 The same is true for lines starting with ``#``, which indicates a comment.
878 A ``!`` at the beginning of a line reverses the glob match pattern from an exclusion
879 to an explicit inclusion. This makes it possible to exclude all entries in a
880 directory except for a few single files/subdirectories.
881 Lines ending in ``/`` match only on directories.
882 The directory containing the ``.pxarexclude`` file is considered to be the root of
883 the given patterns. It is only possible to match files in this directory and its subdirectories.
884
885 ``\`` is used to escape special glob characters.
886 ``?`` matches any single character.
887 ``*`` matches any character, including an empty string.
888 ``**`` is used to match subdirectories. It can be used to, for example, exclude
889 all files ending in ``.tmp`` within the directory or subdirectories with the
890 following pattern ``**/*.tmp``.
891 ``[...]`` matches a single character from any of the provided characters within
892 the brackets. ``[!...]`` does the complementary and matches any single character
893 not contained within the brackets. It is also possible to specify ranges with two
894 characters separated by ``-``. For example, ``[a-z]`` matches any lowercase
895 alphabetic character and ``[0-9]`` matches any one single digit.
896
897 The order of the glob match patterns defines whether a file is included or
898 excluded, that is to say later entries override previous ones.
899 This is also true for match patterns encountered deeper down the directory tree,
900 which can override a previous exclusion.
901 Be aware that excluded directories will **not** be read by the backup client.
902 Thus, a ``.pxarexclude`` file in an excluded subdirectory will have no effect.
903 ``.pxarexclude`` files are treated as regular files and will be included in the
904 backup archive.
905
906 For example, consider the following directory structure:
907
908 .. code-block:: console
909
910 # ls -aR folder
911 folder/:
912 . .. .pxarexclude subfolder0 subfolder1
913
914 folder/subfolder0:
915 . .. file0 file1 file2 file3 .pxarexclude
916
917 folder/subfolder1:
918 . .. file0 file1 file2 file3
919
920 The different ``.pxarexclude`` files contain the following:
921
922 .. code-block:: console
923
924 # cat folder/.pxarexclude
925 /subfolder0/file1
926 /subfolder1/*
927 !/subfolder1/file2
928
929 .. code-block:: console
930
931 # cat folder/subfolder0/.pxarexclude
932 file3
933
934 This would exclude ``file1`` and ``file3`` in ``subfolder0`` and all of
935 ``subfolder1`` except ``file2``.
936
937 Restoring this backup will result in:
938
939 .. code-block:: console
940
941 ls -aR restored
942 restored/:
943 . .. .pxarexclude subfolder0 subfolder1
944
945 restored/subfolder0:
946 . .. file0 file2 .pxarexclude
947
948 restored/subfolder1:
949 . .. file2
950
951 Encryption
952 ~~~~~~~~~~
953
954 Proxmox Backup supports client-side encryption with AES-256 in GCM_
955 mode. To set this up, you first need to create an encryption key:
956
957 .. code-block:: console
958
959 # proxmox-backup-client key create my-backup.key
960 Encryption Key Password: **************
961
962 The key is password protected by default. If you do not need this
963 extra protection, you can also create it without a password:
964
965 .. code-block:: console
966
967 # proxmox-backup-client key create /path/to/my-backup.key --kdf none
968
969 Having created this key, it is now possible to create an encrypted backup, by
970 passing the ``--keyfile`` parameter, with the path to the key file.
971
972 .. code-block:: console
973
974 # proxmox-backup-client backup etc.pxar:/etc --keyfile /path/to/my-backup.key
975 Password: *********
976 Encryption Key Password: **************
977 ...
978
979 .. Note:: If you do not specify the name of the backup key, the key will be
980 created in the default location
981 ``~/.config/proxmox-backup/encryption-key.json``. ``proxmox-backup-client``
982 will also search this location by default, in case the ``--keyfile``
983 parameter is not specified.
984
985 You can avoid entering the passwords by setting the environment
986 variables ``PBS_PASSWORD`` and ``PBS_ENCRYPTION_PASSWORD``.
987
988 Using a master key to store and recover encryption keys
989 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
990
991 You can also use ``proxmox-backup-client key`` to create an RSA public/private
992 key pair, which can be used to store an encrypted version of the symmetric
993 backup encryption key alongside each backup and recover it later.
994
995 To set up a master key:
996
997 1. Create an encryption key for the backup:
998
999 .. code-block:: console
1000
1001 # proxmox-backup-client key create
1002 creating default key at: "~/.config/proxmox-backup/encryption-key.json"
1003 Encryption Key Password: **********
1004 ...
1005
1006 The resulting file will be saved to ``~/.config/proxmox-backup/encryption-key.json``.
1007
1008 2. Create an RSA public/private key pair:
1009
1010 .. code-block:: console
1011
1012 # proxmox-backup-client key create-master-key
1013 Master Key Password: *********
1014 ...
1015
1016 This will create two files in your current directory, ``master-public.pem``
1017 and ``master-private.pem``.
1018
1019 3. Import the newly created ``master-public.pem`` public certificate, so that
1020 ``proxmox-backup-client`` can find and use it upon backup.
1021
1022 .. code-block:: console
1023
1024 # proxmox-backup-client key import-master-pubkey /path/to/master-public.pem
1025 Imported public master key to "~/.config/proxmox-backup/master-public.pem"
1026
1027 4. With all these files in place, run a backup job:
1028
1029 .. code-block:: console
1030
1031 # proxmox-backup-client backup etc.pxar:/etc
1032
1033 The key will be stored in your backup, under the name ``rsa-encrypted.key``.
1034
1035 .. Note:: The ``--keyfile`` parameter can be excluded, if the encryption key
1036 is in the default path. If you specified another path upon creation, you
1037 must pass the ``--keyfile`` parameter.
1038
1039 5. To test that everything worked, you can restore the key from the backup:
1040
1041 .. code-block:: console
1042
1043 # proxmox-backup-client restore /path/to/backup/ rsa-encrypted.key /path/to/target
1044
1045 .. Note:: You should not need an encryption key to extract this file. However, if
1046 a key exists at the default location
1047 (``~/.config/proxmox-backup/encryption-key.json``) the program will prompt
1048 you for an encryption key password. Simply moving ``encryption-key.json``
1049 out of this directory will fix this issue.
1050
1051 6. Then, use the previously generated master key to decrypt the file:
1052
1053 .. code-block:: console
1054
1055 # openssl rsautl -decrypt -inkey master-private.pem -in rsa-encrypted.key -out /path/to/target
1056 Enter pass phrase for ./master-private.pem: *********
1057
1058 7. The target file will now contain the encryption key information in plain
1059 text. The success of this can be confirmed by passing the resulting ``json``
1060 file, with the ``--keyfile`` parameter, when decrypting files from the backup.
1061
1062 .. warning:: Without their key, backed up files will be inaccessible. Thus, you should
1063 keep keys ordered and in a place that is separate from the contents being
1064 backed up. It can happen, for example, that you back up an entire system, using
1065 a key on that system. If the system then becomes inaccessable for any reason
1066 and needs to be restored, this will not be possible as the encryption key will be
1067 lost along with the broken system. In preparation for the worst case scenario,
1068 you should consider keeping a paper copy of this key locked away in
1069 a safe place.
1070
1071 Restoring Data
1072 ~~~~~~~~~~~~~~
1073
1074 The regular creation of backups is a necessary step to avoiding data
1075 loss. More importantly, however, is the restoration. It is good practice to perform
1076 periodic recovery tests to ensure that you can access the data in
1077 case of problems.
1078
1079 First, you need to find the snapshot which you want to restore. The snapshot
1080 command provides a list of all the snapshots on the server:
1081
1082 .. code-block:: console
1083
1084 # proxmox-backup-client snapshots
1085 ┌────────────────────────────────┬─────────────┬────────────────────────────────────┐
1086 │ snapshot │ size │ files │
1087 ╞════════════════════════════════╪═════════════╪════════════════════════════════════╡
1088 │ host/elsa/2019-12-03T09:30:15Z │ 51788646825 │ root.pxar catalog.pcat1 index.json │
1089 ├────────────────────────────────┼─────────────┼────────────────────────────────────┤
1090 │ host/elsa/2019-12-03T09:35:01Z │ 51790622048 │ root.pxar catalog.pcat1 index.json │
1091 ├────────────────────────────────┼─────────────┼────────────────────────────────────┤
1092 ...
1093
1094 You can inspect the catalog to find specific files.
1095
1096 .. code-block:: console
1097
1098 # proxmox-backup-client catalog dump host/elsa/2019-12-03T09:35:01Z
1099 ...
1100 d "./root.pxar.didx/etc/cifs-utils"
1101 l "./root.pxar.didx/etc/cifs-utils/idmap-plugin"
1102 d "./root.pxar.didx/etc/console-setup"
1103 ...
1104
1105 The restore command lets you restore a single archive from the
1106 backup.
1107
1108 .. code-block:: console
1109
1110 # proxmox-backup-client restore host/elsa/2019-12-03T09:35:01Z root.pxar /target/path/
1111
1112 To get the contents of any archive, you can restore the ``index.json`` file in the
1113 repository to the target path '-'. This will dump the contents to the standard output.
1114
1115 .. code-block:: console
1116
1117 # proxmox-backup-client restore host/elsa/2019-12-03T09:35:01Z index.json -
1118
1119
1120 Interactive Restores
1121 ^^^^^^^^^^^^^^^^^^^^
1122
1123 If you only want to restore a few individual files, it is often easier
1124 to use the interactive recovery shell.
1125
1126 .. code-block:: console
1127
1128 # proxmox-backup-client catalog shell host/elsa/2019-12-03T09:35:01Z root.pxar
1129 Starting interactive shell
1130 pxar:/ > ls
1131 bin boot dev etc home lib lib32
1132 ...
1133
1134 The interactive recovery shell is a minimalistic command line interface that
1135 utilizes the metadata stored in the catalog to quickly list, navigate and
1136 search files in a file archive.
1137 To restore files, you can select them individually or match them with a glob
1138 pattern.
1139
1140 Using the catalog for navigation reduces the overhead considerably because only
1141 the catalog needs to be downloaded and, optionally, decrypted.
1142 The actual chunks are only accessed if the metadata in the catalog is not enough
1143 or for the actual restore.
1144
1145 Similar to common UNIX shells ``cd`` and ``ls`` are the commands used to change
1146 working directory and list directory contents in the archive.
1147 ``pwd`` shows the full path of the current working directory with respect to the
1148 archive root.
1149
1150 Being able to quickly search the contents of the archive is a commmonly needed feature.
1151 That's where the catalog is most valuable.
1152 For example:
1153
1154 .. code-block:: console
1155
1156 pxar:/ > find etc/**/*.txt --select
1157 "/etc/X11/rgb.txt"
1158 pxar:/ > list-selected
1159 etc/**/*.txt
1160 pxar:/ > restore-selected /target/path
1161 ...
1162
1163 This will find and print all files ending in ``.txt`` located in ``etc/`` or a
1164 subdirectory and add the corresponding pattern to the list for subsequent restores.
1165 ``list-selected`` shows these patterns and ``restore-selected`` finally restores
1166 all files in the archive matching the patterns to ``/target/path`` on the local
1167 host. This will scan the whole archive.
1168
1169 With ``restore /target/path`` you can restore the sub-archive given by the current
1170 working directory to the local target path ``/target/path`` on your host.
1171 By additionally passing a glob pattern with ``--pattern <glob>``, the restore is
1172 further limited to files matching the pattern.
1173 For example:
1174
1175 .. code-block:: console
1176
1177 pxar:/ > cd /etc/
1178 pxar:/etc/ > restore /target/ --pattern **/*.conf
1179 ...
1180
1181 The above will scan trough all the directories below ``/etc`` and restore all
1182 files ending in ``.conf``.
1183
1184 .. todo:: Explain interactive restore in more detail
1185
1186 Mounting of Archives via FUSE
1187 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1188
1189 The :term:`FUSE` implementation for the pxar archive allows you to mount a
1190 file archive as a read-only filesystem to a mountpoint on your host.
1191
1192 .. code-block:: console
1193
1194 # proxmox-backup-client mount host/backup-client/2020-01-29T11:29:22Z root.pxar /mnt/mountpoint
1195 # ls /mnt/mountpoint
1196 bin dev home lib32 libx32 media opt root sbin sys usr
1197 boot etc lib lib64 lost+found mnt proc run srv tmp var
1198
1199 This allows you to access the full contents of the archive in a seamless manner.
1200
1201 .. note:: As the FUSE connection needs to fetch and decrypt chunks from the
1202 backup server's datastore, this can cause some additional network and CPU
1203 load on your host, depending on the operations you perform on the mounted
1204 filesystem.
1205
1206 To unmount the filesystem use the ``umount`` command on the mountpoint:
1207
1208 .. code-block:: console
1209
1210 # umount /mnt/mountpoint
1211
1212 Login and Logout
1213 ~~~~~~~~~~~~~~~~
1214
1215 The client tool prompts you to enter the logon password as soon as you
1216 want to access the backup server. The server checks your credentials
1217 and responds with a ticket that is valid for two hours. The client
1218 tool automatically stores that ticket and uses it for further requests
1219 to this server.
1220
1221 You can also manually trigger this login/logout using the login and
1222 logout commands:
1223
1224 .. code-block:: console
1225
1226 # proxmox-backup-client login
1227 Password: **********
1228
1229 To remove the ticket, issue a logout:
1230
1231 .. code-block:: console
1232
1233 # proxmox-backup-client logout
1234
1235
1236 .. _pruning:
1237
1238 Pruning and Removing Backups
1239 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1240
1241 You can manually delete a backup snapshot using the ``forget``
1242 command:
1243
1244 .. code-block:: console
1245
1246 # proxmox-backup-client forget <snapshot>
1247
1248
1249 .. caution:: This command removes all archives in this backup
1250 snapshot. They will be inaccessible and unrecoverable.
1251
1252
1253 Although manual removal is sometimes required, the ``prune``
1254 command is normally used to systematically delete older backups. Prune lets
1255 you specify which backup snapshots you want to keep. The
1256 following retention options are available:
1257
1258 ``--keep-last <N>``
1259 Keep the last ``<N>`` backup snapshots.
1260
1261 ``--keep-hourly <N>``
1262 Keep backups for the last ``<N>`` hours. If there is more than one
1263 backup for a single hour, only the latest is kept.
1264
1265 ``--keep-daily <N>``
1266 Keep backups for the last ``<N>`` days. If there is more than one
1267 backup for a single day, only the latest is kept.
1268
1269 ``--keep-weekly <N>``
1270 Keep backups for the last ``<N>`` weeks. If there is more than one
1271 backup for a single week, only the latest is kept.
1272
1273 .. note:: Weeks start on Monday and end on Sunday. The software
1274 uses the `ISO week date`_ system and handles weeks at
1275 the end of the year correctly.
1276
1277 ``--keep-monthly <N>``
1278 Keep backups for the last ``<N>`` months. If there is more than one
1279 backup for a single month, only the latest is kept.
1280
1281 ``--keep-yearly <N>``
1282 Keep backups for the last ``<N>`` years. If there is more than one
1283 backup for a single year, only the latest is kept.
1284
1285 The retention options are processed in the order given above. Each option
1286 only covers backups within its time period. The next option does not take care
1287 of already covered backups. It will only consider older backups.
1288
1289 Unfinished and incomplete backups will be removed by the prune command unless
1290 they are newer than the last successful backup. In this case, the last failed
1291 backup is retained.
1292
1293 .. code-block:: console
1294
1295 # proxmox-backup-client prune <group> --keep-daily 7 --keep-weekly 4 --keep-monthly 3
1296
1297
1298 You can use the ``--dry-run`` option to test your settings. This only
1299 shows the list of existing snapshots and what actions prune would take.
1300
1301 .. code-block:: console
1302
1303 # proxmox-backup-client prune host/elsa --dry-run --keep-daily 1 --keep-weekly 3
1304 ┌────────────────────────────────┬──────┐
1305 │ snapshot │ keep │
1306 ╞════════════════════════════════╪══════╡
1307 │ host/elsa/2019-12-04T13:20:37Z │ 1 │
1308 ├────────────────────────────────┼──────┤
1309 │ host/elsa/2019-12-03T09:35:01Z │ 0 │
1310 ├────────────────────────────────┼──────┤
1311 │ host/elsa/2019-11-22T11:54:47Z │ 1 │
1312 ├────────────────────────────────┼──────┤
1313 │ host/elsa/2019-11-21T12:36:25Z │ 0 │
1314 ├────────────────────────────────┼──────┤
1315 │ host/elsa/2019-11-10T10:42:20Z │ 1 │
1316 └────────────────────────────────┴──────┘
1317
1318 .. note:: Neither the ``prune`` command nor the ``forget`` command free space
1319 in the chunk-store. The chunk-store still contains the data blocks. To free
1320 space you need to perform :ref:`garbage-collection`.
1321
1322
1323 .. _garbage-collection:
1324
1325 Garbage Collection
1326 ~~~~~~~~~~~~~~~~~~
1327
1328 The ``prune`` command removes only the backup index files, not the data
1329 from the datastore. This task is left to the garbage collection
1330 command. It is recommended to carry out garbage collection on a regular basis.
1331
1332 The garbage collection works in two phases. In the first phase, all
1333 data blocks that are still in use are marked. In the second phase,
1334 unused data blocks are removed.
1335
1336 .. note:: This command needs to read all existing backup index files
1337 and touches the complete chunk-store. This can take a long time
1338 depending on the number of chunks and the speed of the underlying
1339 disks.
1340
1341 .. note:: The garbage collection will only remove chunks that haven't been used
1342 for at least one day (exactly 24h 5m). This grace period is necessary because
1343 chunks in use are marked by touching the chunk which updates the ``atime``
1344 (access time) property. Filesystems are mounted with the ``relatime`` option
1345 by default. This results in a better performance by only updating the
1346 ``atime`` property if the last access has been at least 24 hours ago. The
1347 downside is, that touching a chunk within these 24 hours will not always
1348 update its ``atime`` property.
1349
1350 Chunks in the grace period will be logged at the end of the garbage
1351 collection task as *Pending removals*.
1352
1353 .. code-block:: console
1354
1355 # proxmox-backup-client garbage-collect
1356 starting garbage collection on store store2
1357 Start GC phase1 (mark used chunks)
1358 Start GC phase2 (sweep unused chunks)
1359 percentage done: 1, chunk count: 219
1360 percentage done: 2, chunk count: 453
1361 ...
1362 percentage done: 99, chunk count: 21188
1363 Removed bytes: 411368505
1364 Removed chunks: 203
1365 Original data bytes: 327160886391
1366 Disk bytes: 52767414743 (16 %)
1367 Disk chunks: 21221
1368 Average chunk size: 2486565
1369 TASK OK
1370
1371
1372 .. todo:: howto run garbage-collection at regular intervalls (cron)
1373
1374 Benchmarking
1375 ~~~~~~~~~~~~
1376 The backup client also comes with a benchmarking tool. This tool measures
1377 various metrics relating to compression and encryption speeds. You can run a
1378 benchmark using the ``benchmark`` subcommand of ``proxmox-backup-client``:
1379
1380 .. code-block:: console
1381
1382 # proxmox-backup-client benchmark
1383 Uploaded 656 chunks in 5 seconds.
1384 Time per request: 7659 microseconds.
1385 TLS speed: 547.60 MB/s
1386 SHA256 speed: 585.76 MB/s
1387 Compression speed: 1923.96 MB/s
1388 Decompress speed: 7885.24 MB/s
1389 AES256/GCM speed: 3974.03 MB/s
1390 ┌───────────────────────────────────┬─────────────────────┐
1391 │ Name │ Value │
1392 ╞═══════════════════════════════════╪═════════════════════╡
1393 │ TLS (maximal backup upload speed) │ 547.60 MB/s (93%) │
1394 ├───────────────────────────────────┼─────────────────────┤
1395 │ SHA256 checksum computation speed │ 585.76 MB/s (28%) │
1396 ├───────────────────────────────────┼─────────────────────┤
1397 │ ZStd level 1 compression speed │ 1923.96 MB/s (89%) │
1398 ├───────────────────────────────────┼─────────────────────┤
1399 │ ZStd level 1 decompression speed │ 7885.24 MB/s (98%) │
1400 ├───────────────────────────────────┼─────────────────────┤
1401 │ AES256 GCM encryption speed │ 3974.03 MB/s (104%) │
1402 └───────────────────────────────────┴─────────────────────┘
1403
1404 .. note:: The percentages given in the output table correspond to a
1405 comparison against a Ryzen 7 2700X. The TLS test connects to the
1406 local host, so there is no network involved.
1407
1408 You can also pass the ``--output-format`` parameter to output stats in ``json``,
1409 rather than the default table format.
1410
1411 .. _pve-integration:
1412
1413 `Proxmox VE`_ integration
1414 -------------------------
1415
1416 You need to define a new storage with type 'pbs' on your `Proxmox VE`_
1417 node. The following example uses ``store2`` as storage name, and
1418 assumes the server address is ``localhost``, and you want to connect
1419 as ``user1@pbs``.
1420
1421 .. code-block:: console
1422
1423 # pvesm add pbs store2 --server localhost --datastore store2
1424 # pvesm set store2 --username user1@pbs --password <secret>
1425
1426 .. note:: If you would rather not pass your password as plain text, you can pass
1427 the ``--password`` parameter, without any arguments. This will cause the
1428 program to prompt you for a password upon entering the command.
1429
1430 If your backup server uses a self signed certificate, you need to add
1431 the certificate fingerprint to the configuration. You can get the
1432 fingerprint by running the following command on the backup server:
1433
1434 .. code-block:: console
1435
1436 # proxmox-backup-manager cert info | grep Fingerprint
1437 Fingerprint (sha256): 64:d3:ff:3a:50:38:53:5a:9b:f7:50:...:ab:fe
1438
1439 Please add that fingerprint to your configuration to establish a trust
1440 relationship:
1441
1442 .. code-block:: console
1443
1444 # pvesm set store2 --fingerprint 64:d3:ff:3a:50:38:53:5a:9b:f7:50:...:ab:fe
1445
1446 After that you should be able to see storage status with:
1447
1448 .. code-block:: console
1449
1450 # pvesm status --storage store2
1451 Name Type Status Total Used Available %
1452 store2 pbs active 3905109820 1336687816 2568422004 34.23%
1453
1454 Having added the PBS datastore to `Proxmox VE`_, you can backup VMs and
1455 containers in the same way you would for any other storage device within the
1456 environment (see `PVE Admin Guide: Backup and Restore
1457 <https://pve.proxmox.com/pve-docs/pve-admin-guide.html#chapter_vzdump>`_.
1458
1459
1460 .. include:: command-line-tools.rst
1461
1462 .. include:: services.rst