]> git.proxmox.com Git - proxmox-backup.git/blob - docs/administration-guide.rst
2be495752b1864d76c6fd98ab45b29d76ed1f4fa
[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 File Archives: ``<name>.pxar``
28 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29
30 .. see https://moinakg.wordpress.com/2013/06/22/high-performance-content-defined-chunking/
31
32 A file archive stores a full directory tree. Content is stored using
33 the :ref:`pxar-format`, split into variable-sized chunks. The format
34 is optimized to achieve good deduplication rates.
35
36
37 Image Archives: ``<name>.img``
38 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39
40 This is used for virtual machine images and other large binary
41 data. Content is split into fixed-sized chunks.
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
131
132 :term:`DataStore`
133 ~~~~~~~~~~~~~~~~~
134
135 A datastore is a place where backups are stored. The current implementation
136 uses a directory inside a standard unix file system (``ext4``, ``xfs``
137 or ``zfs``) to store the backup data.
138
139 Datastores are identified by a simple *ID*. You can configure it
140 when setting up the backup server.
141
142 .. note:: The `File Layout`_ requires the file system to support at least *65538*
143 subdirectories per directory. That number comes from the 2\ :sup:`16`
144 pre-created chunk namespace directories, and the ``.`` and ``..`` default
145 directory entries. This requirement excludes certain filesystems and
146 filesystem configuration from being supported for a datastore. For example,
147 ``ext3`` as a whole or ``ext4`` with the ``dir_nlink`` feature manually disabled.
148
149
150 Datastore Configuration
151 ~~~~~~~~~~~~~~~~~~~~~~~
152
153 You can configure multiple datastores. Minimum one datastore needs to be
154 configured. The datastore is identified by a simple `name` and points to a
155 directory on the filesystem. Each datastore also has associated retention
156 settings of how many backup snapshots for each interval of ``hourly``,
157 ``daily``, ``weekly``, ``monthly``, ``yearly`` as well as a time-independent
158 number of backups to keep in that store. :ref:`Pruning <pruning>` and
159 :ref:`garbage collection <garbage-collection>` can also be configured to run
160 periodically based on a configured :term:`schedule` per datastore.
161
162 The following command creates a new datastore called ``store1`` on :file:`/backup/disk1/store1`
163
164 .. code-block:: console
165
166 # proxmox-backup-manager datastore create store1 /backup/disk1/store1
167
168 To list existing datastores run:
169
170 .. code-block:: console
171
172 # proxmox-backup-manager datastore list
173 ┌────────┬──────────────────────┬─────────────────────────────┐
174 │ name │ path │ comment │
175 ╞════════╪══════════════════════╪═════════════════════════════╡
176 │ store1 │ /backup/disk1/store1 │ This is my default storage. │
177 └────────┴──────────────────────┴─────────────────────────────┘
178
179 You can change settings of a datastore, for example to set a prune and garbage
180 collection schedule or retention settings using ``update`` subcommand and view
181 a datastore with the ``show`` subcommand:
182
183 .. code-block:: console
184
185 # proxmox-backup-manager datastore update store1 --keep-last 7 --prune-schedule daily --gc-schedule 'Tue 04:27'
186 # proxmox-backup-manager datastore show store1
187 ┌────────────────┬─────────────────────────────┐
188 │ Name │ Value │
189 ╞════════════════╪═════════════════════════════╡
190 │ name │ store1 │
191 ├────────────────┼─────────────────────────────┤
192 │ path │ /backup/disk1/store1 │
193 ├────────────────┼─────────────────────────────┤
194 │ comment │ This is my default storage. │
195 ├────────────────┼─────────────────────────────┤
196 │ gc-schedule │ Tue 04:27 │
197 ├────────────────┼─────────────────────────────┤
198 │ keep-last │ 7 │
199 ├────────────────┼─────────────────────────────┤
200 │ prune-schedule │ daily │
201 └────────────────┴─────────────────────────────┘
202
203 Finally, it is possible to remove the datastore configuration:
204
205 .. code-block:: console
206
207 # proxmox-backup-manager datastore remove store1
208
209 .. note:: The above command removes only the datastore configuration. It does
210 not delete any data from the underlying directory.
211
212
213 File Layout
214 ^^^^^^^^^^^
215
216 After creating a datastore, the following default layout will appear:
217
218 .. code-block:: console
219
220 # ls -arilh /backup/disk1/store1
221 276493 -rw-r--r-- 1 backup backup 0 Jul 8 12:35 .lock
222 276490 drwxr-x--- 1 backup backup 1064960 Jul 8 12:35 .chunks
223
224 `.lock` is an empty file used for process locking.
225
226 The `.chunks` directory contains folders, starting from `0000` and taking hexadecimal values until `ffff`. These
227 directories will store the chunked data after a backup operation has been executed.
228
229 .. code-block:: console
230
231 # ls -arilh /backup/disk1/store1/.chunks
232 545824 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 ffff
233 545823 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffe
234 415621 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffd
235 415620 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffc
236 353187 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffb
237 344995 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fffa
238 144079 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fff9
239 144078 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fff8
240 144077 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 fff7
241 ...
242 403180 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 000c
243 403179 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 000b
244 403177 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 000a
245 402530 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0009
246 402513 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0008
247 402509 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0007
248 276509 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0006
249 276508 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0005
250 276507 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0004
251 276501 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0003
252 276499 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0002
253 276498 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0001
254 276494 drwxr-x--- 2 backup backup 4.0K Jul 8 12:35 0000
255 276489 drwxr-xr-x 3 backup backup 4.0K Jul 8 12:35 ..
256 276490 drwxr-x--- 1 backup backup 1.1M Jul 8 12:35 .
257
258
259
260 User Management
261 ~~~~~~~~~~~~~~~
262
263 Proxmox Backup Server supports several authentication realms, and you need to
264 choose the realm when you add a new user. Possible realms are:
265
266 :pam: Linux PAM standard authentication. Use this if you want to
267 authenticate as Linux system user (Users need to exist on the
268 system).
269
270 :pbs: Proxmox Backup Server realm. This type stores hashed passwords in
271 ``/etc/proxmox-backup/shadow.json``.
272
273 After installation, there is a single user ``root@pam``, which
274 corresponds to the Unix superuser. You can use the
275 ``proxmox-backup-manager`` command line tool to list or manipulate
276 users:
277
278 .. code-block:: console
279
280 # proxmox-backup-manager user list
281 ┌─────────────┬────────┬────────┬───────────┬──────────┬────────────────┬────────────────────┐
282 │ userid │ enable │ expire │ firstname │ lastname │ email │ comment │
283 ╞═════════════╪════════╪════════╪═══════════╪══════════╪════════════════╪════════════════════╡
284 │ root@pam │ 1 │ │ │ │ │ Superuser │
285 └─────────────┴────────┴────────┴───────────┴──────────┴────────────────┴────────────────────┘
286
287 The superuser has full administration rights on everything, so you
288 normally want to add other users with less privileges:
289
290 .. code-block:: console
291
292 # proxmox-backup-manager user create john@pbs --email john@example.com
293
294 The create command lets you specify many options like ``--email`` or
295 ``--password``. You can update or change any of them using the
296 update command later:
297
298 .. code-block:: console
299
300 # proxmox-backup-manager user update john@pbs --firstname John --lastname Smith
301 # proxmox-backup-manager user update john@pbs --comment "An example user."
302
303 .. todo:: Mention how to set password without passing plaintext password as cli argument.
304
305
306 The resulting user list looks like this:
307
308 .. code-block:: console
309
310 # proxmox-backup-manager user list
311 ┌──────────┬────────┬────────┬───────────┬──────────┬──────────────────┬──────────────────┐
312 │ userid │ enable │ expire │ firstname │ lastname │ email │ comment │
313 ╞══════════╪════════╪════════╪═══════════╪══════════╪══════════════════╪══════════════════╡
314 │ john@pbs │ 1 │ │ John │ Smith │ john@example.com │ An example user. │
315 ├──────────┼────────┼────────┼───────────┼──────────┼──────────────────┼──────────────────┤
316 │ root@pam │ 1 │ │ │ │ │ Superuser │
317 └──────────┴────────┴────────┴───────────┴──────────┴──────────────────┴──────────────────┘
318
319 Newly created users do not have any permissions. Please read the next
320 section to learn how to set access permissions.
321
322 If you want to disable a user account, you can do that by setting ``--enable`` to ``0``
323
324 .. code-block:: console
325
326 # proxmox-backup-manager user update john@pbs --enable 0
327
328 Or completely remove the user with:
329
330 .. code-block:: console
331
332 # proxmox-backup-manager user remove john@pbs
333
334
335 Access Control
336 ~~~~~~~~~~~~~~
337
338 By default new users do not have any permission. Instead you need to
339 specify what is allowed and what is not. You can do this by assigning
340 roles to users on specific objects like datastores or remotes. The
341 following roles exist:
342
343 **NoAccess**
344 Disable Access - nothing is allowed.
345
346 **Admin**
347 Can do anything.
348
349 **Audit**
350 Can view things, but is not allowed to change settings.
351
352 **DatastoreAdmin**
353 Can do anything on datastores.
354
355 **DatastoreAudit**
356 Can view datastore settings and list content. But
357 is not allowed to read the actual data.
358
359 **DatastoreReader**
360 Can Inspect datastore content and can do restores.
361
362 **DatastoreBackup**
363 Can backup and restore owned backups.
364
365 **DatastorePowerUser**
366 Can backup, restore, and prune owned backups.
367
368 **RemoteAdmin**
369 Can do anything on remotes.
370
371 **RemoteAudit**
372 Can view remote settings.
373
374 **RemoteSyncOperator**
375 Is allowed to read data from a remote.
376
377
378 :term:`Remote`
379 ~~~~~~~~~~~~~~
380
381 A remote refers to a separate Proxmox Backup Server installation and a user on that
382 installation, from which you can `sync` datastores to a local datastore with a
383 `Sync Job`.
384
385 To add a remote, you need its hostname or ip, a userid and password on the
386 remote, and its certificate fingerprint. To get the fingerprint, use the
387 ``proxmox-backup-manager cert info`` command on the remote.
388
389 .. code-block:: console
390
391 # proxmox-backup-manager cert info |grep Fingerprint
392 Fingerprint (sha256): 64:d3:ff:3a:50:38:53:5a:9b:f7:50:...:ab:fe
393
394 Using the information specified above, add the remote with:
395
396 .. code-block:: console
397
398 # 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
399
400 Use the ``list``, ``show``, ``update``, ``remove`` subcommands of
401 ``proxmox-backup-manager remote`` to manage your remotes:
402
403 .. code-block:: console
404
405 # proxmox-backup-manager remote update pbs2 --host pbs2.example
406 # proxmox-backup-manager remote list
407 ┌──────┬──────────────┬──────────┬───────────────────────────────────────────┬─────────┐
408 │ name │ host │ userid │ fingerprint │ comment │
409 ╞══════╪══════════════╪══════════╪═══════════════════════════════════════════╪═════════╡
410 │ pbs2 │ pbs2.example │ sync@pam │64:d3:ff:3a:50:38:53:5a:9b:f7:50:...:ab:fe │ │
411 └──────┴──────────────┴──────────┴───────────────────────────────────────────┴─────────┘
412 # proxmox-backup-manager remote remove pbs2
413
414
415 Sync Jobs
416 ~~~~~~~~~
417
418 Sync jobs are configured to pull the contents of a datastore on a `Remote` to a
419 local datastore. You can either start the sync job manually on the GUI or
420 provide it with a :term:`schedule` to run regularly. The
421 ``proxmox-backup-manager sync-job`` command is used to manage sync jobs:
422
423 .. code-block:: console
424
425 # proxmox-backup-manager sync-job create pbs2-local --remote pbs2 --remote-store local --store local --schedule 'Wed 02:30'
426 # proxmox-backup-manager sync-job update pbs2-local --comment 'offsite'
427 # proxmox-backup-manager sync-job list
428 ┌────────────┬───────┬────────┬──────────────┬───────────┬─────────┐
429 │ id │ store │ remote │ remote-store │ schedule │ comment │
430 ╞════════════╪═══════╪════════╪══════════════╪═══════════╪═════════╡
431 │ pbs2-local │ local │ pbs2 │ local │ Wed 02:30 │ offsite │
432 └────────────┴───────┴────────┴──────────────┴───────────┴─────────┘
433 # proxmox-backup-manager sync-job remove pbs2-local
434
435
436 Backup Client usage
437 -------------------
438
439 The command line client is called :command:`proxmox-backup-client`.
440
441
442 Repository Locations
443 ~~~~~~~~~~~~~~~~~~~~
444
445 The client uses the following notation to specify a datastore repository
446 on the backup server.
447
448 [[username@]server:]datastore
449
450 The default value for ``username`` ist ``root``. If no server is specified,
451 the default is the local host (``localhost``).
452
453 You can pass the repository with the ``--repository`` command
454 line option, or by setting the ``PBS_REPOSITORY`` environment
455 variable.
456
457
458 Environment Variables
459 ~~~~~~~~~~~~~~~~~~~~~
460
461 ``PBS_REPOSITORY``
462 The default backup repository.
463
464 ``PBS_PASSWORD``
465 When set, this value is used for the password required for the
466 backup server.
467
468 ``PBS_ENCRYPTION_PASSWORD``
469 When set, this value is used to access the secret encryption key (if
470 protected by password).
471
472 ``PBS_FINGERPRINT`` When set, this value is used to verify the server
473 certificate (only used if the system CA certificates cannot
474 validate the certificate).
475
476
477 Output Format
478 ~~~~~~~~~~~~~
479
480 Most commands support the ``--output-format`` parameter. It accepts
481 the following values:
482
483 :``text``: Text format (default). Structured data is rendered as a table.
484
485 :``json``: JSON (single line).
486
487 :``json-pretty``: JSON (multiple lines, nicely formatted).
488
489
490 Please use the following environment variables to modify output behavior:
491
492 ``PROXMOX_OUTPUT_FORMAT``
493 Defines the default output format.
494
495 ``PROXMOX_OUTPUT_NO_BORDER``
496 If set (to any value), do not render table borders.
497
498 ``PROXMOX_OUTPUT_NO_HEADER``
499 If set (to any value), do not render table headers.
500
501 .. note:: The ``text`` format is designed to be human readable, and
502 not meant to be parsed by automation tools. Please use the ``json``
503 format if you need to process the output.
504
505
506 .. _creating-backups:
507
508 Creating Backups
509 ~~~~~~~~~~~~~~~~
510
511 This section explains how to create a backup from within the machine. This can
512 be a physical host, a virtual machine, or a container. Such backups may contain file
513 and image archives. There are no restrictions in this case.
514
515 .. note:: If you want to backup virtual machines or containers on Proxmox VE, see :ref:`pve-integration`.
516
517 For the following example you need to have a backup server set up, working
518 credentials and need to know the repository name.
519 In the following examples we use ``backup-server:store1``.
520
521 .. code-block:: console
522
523 # proxmox-backup-client backup root.pxar:/ --repository backup-server:store1
524 Starting backup: host/elsa/2019-12-03T09:35:01Z
525 Client name: elsa
526 skip mount point: "/boot/efi"
527 skip mount point: "/dev"
528 skip mount point: "/run"
529 skip mount point: "/sys"
530 Uploaded 12129 chunks in 87 seconds (564 MB/s).
531 End Time: 2019-12-03T10:36:29+01:00
532
533 This will prompt you for a password and then uploads a file archive named
534 ``root.pxar`` containing all the files in the ``/`` directory.
535
536 .. Caution:: Please note that the proxmox-backup-client does not
537 automatically include mount points. Instead, you will see a short
538 ``skip mount point`` notice for each of them. The idea is to
539 create a separate file archive for each mounted disk. You can
540 explicitly include them using the ``--include-dev`` option
541 (i.e. ``--include-dev /boot/efi``). You can use this option
542 multiple times for each mount point that should be included.
543
544 The ``--repository`` option can get quite long and is used by all
545 commands. You can avoid having to enter this value by setting the
546 environment variable ``PBS_REPOSITORY``. Note that if you would like this to remain set
547 over multiple sessions, you should instead add the below line to your
548 ``.bashrc`` file.
549
550 .. code-block:: console
551
552 # export PBS_REPOSITORY=backup-server:store1
553
554 After this you can execute all commands without specifying the ``--repository``
555 option.
556
557 One single backup is allowed to contain more than one archive. For example, if
558 you want to backup two disks mounted at ``/mmt/disk1`` and ``/mnt/disk2``:
559
560 .. code-block:: console
561
562 # proxmox-backup-client backup disk1.pxar:/mnt/disk1 disk2.pxar:/mnt/disk2
563
564 This creates a backup of both disks.
565
566 The backup command takes a list of backup specifications, which
567 include the archive name on the server, the type of the archive, and the
568 archive source at the client. The format is:
569
570 <archive-name>.<type>:<source-path>
571
572 Common types are ``.pxar`` for file archives, and ``.img`` for block
573 device images. To create a backup of a block device run the following command:
574
575 .. code-block:: console
576
577 # proxmox-backup-client backup mydata.img:/dev/mylvm/mydata
578
579 Excluding files/folders from a backup
580 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
581
582 Sometimes it is desired to exclude certain files or folders from a backup archive.
583 To tell the Proxmox Backup client when and how to ignore files and directories,
584 place a text file called ``.pxarexclude`` in the filesystem hierarchy.
585 Whenever the backup client encounters such a file in a directory, it interprets
586 each line as glob match patterns for files and directories that are to be excluded
587 from the backup.
588
589 The file must contain a single glob pattern per line. Empty lines are ignored.
590 The same is true for lines starting with ``#``, which indicates a comment.
591 A ``!`` at the beginning of a line reverses the glob match pattern from an exclusion
592 to an explicit inclusion. This makes it possible to exclude all entries in a
593 directory except for a few single files/subdirectories.
594 Lines ending in ``/`` match only on directories.
595 The directory containing the ``.pxarexclude`` file is considered to be the root of
596 the given patterns. It is only possible to match files in this directory and its subdirectories.
597
598 ``\`` is used to escape special glob characters.
599 ``?`` matches any single character.
600 ``*`` matches any character, including an empty string.
601 ``**`` is used to match subdirectories. It can be used to, for example, exclude
602 all files ending in ``.tmp`` within the directory or subdirectories with the
603 following pattern ``**/*.tmp``.
604 ``[...]`` matches a single character from any of the provided characters within
605 the brackets. ``[!...]`` does the complementary and matches any single character
606 not contained within the brackets. It is also possible to specify ranges with two
607 characters separated by ``-``. For example, ``[a-z]`` matches any lowercase
608 alphabetic character and ``[0-9]`` matches any one single digit.
609
610 The order of the glob match patterns defines whether a file is included or
611 excluded, that is to say later entries override previous ones.
612 This is also true for match patterns encountered deeper down the directory tree,
613 which can override a previous exclusion.
614 Be aware that excluded directories will **not** be read by the backup client.
615 Thus, a ``.pxarexclude`` file in an excluded subdirectory will have no effect.
616 ``.pxarexclude`` files are treated as regular files and will be included in the
617 backup archive.
618
619 For example, consider the following directory structure:
620
621 .. code-block:: console
622
623 # ls -aR folder
624 folder/:
625 . .. .pxarexclude subfolder0 subfolder1
626
627 folder/subfolder0:
628 . .. file0 file1 file2 file3 .pxarexclude
629
630 folder/subfolder1:
631 . .. file0 file1 file2 file3
632
633 The different ``.pxarexclude`` files contain the following:
634
635 .. code-block:: console
636
637 # cat folder/.pxarexclude
638 /subfolder0/file1
639 /subfolder1/*
640 !/subfolder1/file2
641
642 .. code-block:: console
643
644 # cat folder/subfolder0/.pxarexclude
645 file3
646
647 This would exclude ``file1`` and ``file3`` in ``subfolder0`` and all of
648 ``subfolder1`` except ``file2``.
649
650 Restoring this backup will result in:
651
652 .. code-block:: console
653
654 ls -aR restored
655 restored/:
656 . .. .pxarexclude subfolder0 subfolder1
657
658 restored/subfolder0:
659 . .. file0 file2 .pxarexclude
660
661 restored/subfolder1:
662 . .. file2
663
664 Encryption
665 ~~~~~~~~~~
666
667 Proxmox Backup supports client-side encryption with AES-256 in GCM_
668 mode. To set this up, you first need to create an encryption key:
669
670 .. code-block:: console
671
672 # proxmox-backup-client key create my-backup.key
673 Encryption Key Password: **************
674
675 The key is password protected by default. If you do not need this
676 extra protection, you can also create it without a password:
677
678 .. code-block:: console
679
680 # proxmox-backup-client key create /path/to/my-backup.key --kdf none
681
682 Having created this key, it is now possible to create an encrypted backup, by
683 passing the ``--keyfile`` parameter, with the path to the key file.
684
685 .. code-block:: console
686
687 # proxmox-backup-client backup etc.pxar:/etc --keyfile /path/to/my-backup.key
688 Password: *********
689 Encryption Key Password: **************
690 ...
691
692 .. Note:: If you do not specify the name of the backup key, the key will be
693 created in the default location
694 ``~/.config/proxmox-backup/encryption-key.json``. ``proxmox-backup-client``
695 will also search this location by default, in case the ``--keyfile``
696 parameter is not specified.
697
698 You can avoid entering the passwords by setting the environment
699 variables ``PBS_PASSWORD`` and ``PBS_ENCRYPTION_PASSWORD``.
700
701 Using a master key to store and recover encryption keys
702 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
703
704 You can also use ``proxmox-backup-client key`` to create an RSA public/private
705 key pair, which can be used to store an encrypted version of the symmetric
706 backup encryption key alongside each backup and recover it later.
707
708 To set up a master key:
709
710 1. Create an encryption key for the backup:
711
712 .. code-block:: console
713
714 # proxmox-backup-client key create
715 creating default key at: "~/.config/proxmox-backup/encryption-key.json"
716 Encryption Key Password: **********
717 ...
718
719 The resulting file will be saved to ``~/.config/proxmox-backup/encryption-key.json``.
720
721 2. Create an RSA public/private key pair:
722
723 .. code-block:: console
724
725 # proxmox-backup-client key create-master-key
726 Master Key Password: *********
727 ...
728
729 This will create two files in your current directory, ``master-public.pem``
730 and ``master-private.pem``.
731
732 3. Import the newly created ``master-public.pem`` public certificate, so that
733 ``proxmox-backup-client`` can find and use it upon backup.
734
735 .. code-block:: console
736
737 # proxmox-backup-client key import-master-pubkey /path/to/master-public.pem
738 Imported public master key to "~/.config/proxmox-backup/master-public.pem"
739
740 4. With all these files in place, run a backup job:
741
742 .. code-block:: console
743
744 # proxmox-backup-client backup etc.pxar:/etc
745
746 The key will be stored in your backup, under the name ``rsa-encrypted.key``.
747
748 .. Note:: The ``--keyfile`` parameter can be excluded, if the encryption key
749 is in the default path. If you specified another path upon creation, you
750 must pass the ``--keyfile`` parameter.
751
752 5. To test that everything worked, you can restore the key from the backup:
753
754 .. code-block:: console
755
756 # proxmox-backup-client restore /path/to/backup/ rsa-encrypted.key /path/to/target
757
758 .. Note:: You should not need an encryption key to extract this file. However, if
759 a key exists at the default location
760 (``~/.config/proxmox-backup/encryption-key.json``) the program will prompt
761 you for an encryption key password. Simply moving ``encryption-key.json``
762 out of this directory will fix this issue.
763
764 6. Then, use the previously generated master key to decrypt the file:
765
766 .. code-block:: console
767
768 # openssl rsautl -decrypt -inkey master-private.pem -in rsa-encrypted.key -out /path/to/target
769 Enter pass phrase for ./master-private.pem: *********
770
771 7. The target file will now contain the encryption key information in plain
772 text. The success of this can be confirmed by passing the resulting ``json``
773 file, with the ``--keyfile`` parameter, when decrypting files from the backup.
774
775 .. warning:: Without their key, backed up files will be inaccessible. Thus, you should
776 keep keys ordered and in a place that is separate from the contents being
777 backed up. It can happen, for example, that you back up an entire system, using
778 a key on that system. If the system then becomes inaccessable for any reason
779 and needs to be restored, this will not be possible as the encryption key will be
780 lost along with the broken system. In preparation for the worst case scenario,
781 you should consider keeping a paper copy of this key locked away in
782 a safe place.
783
784 Restoring Data
785 ~~~~~~~~~~~~~~
786
787 The regular creation of backups is a necessary step to avoiding data
788 loss. More importantly, however, is the restoration. It is good practice to perform
789 periodic recovery tests to ensure that you can access the data in
790 case of problems.
791
792 First, you need to find the snapshot which you want to restore. The snapshot
793 command provides a list of all the snapshots on the server:
794
795 .. code-block:: console
796
797 # proxmox-backup-client snapshots
798 ┌────────────────────────────────┬─────────────┬────────────────────────────────────┐
799 │ snapshot │ size │ files │
800 ╞════════════════════════════════╪═════════════╪════════════════════════════════════╡
801 │ host/elsa/2019-12-03T09:30:15Z │ 51788646825 │ root.pxar catalog.pcat1 index.json │
802 ├────────────────────────────────┼─────────────┼────────────────────────────────────┤
803 │ host/elsa/2019-12-03T09:35:01Z │ 51790622048 │ root.pxar catalog.pcat1 index.json │
804 ├────────────────────────────────┼─────────────┼────────────────────────────────────┤
805 ...
806
807 You can inspect the catalog to find specific files.
808
809 .. code-block:: console
810
811 # proxmox-backup-client catalog dump host/elsa/2019-12-03T09:35:01Z
812 ...
813 d "./root.pxar.didx/etc/cifs-utils"
814 l "./root.pxar.didx/etc/cifs-utils/idmap-plugin"
815 d "./root.pxar.didx/etc/console-setup"
816 ...
817
818 The restore command lets you restore a single archive from the
819 backup.
820
821 .. code-block:: console
822
823 # proxmox-backup-client restore host/elsa/2019-12-03T09:35:01Z root.pxar /target/path/
824
825 To get the contents of any archive, you can restore the ``index.json`` file in the
826 repository to the target path '-'. This will dump the contents to the standard output.
827
828 .. code-block:: console
829
830 # proxmox-backup-client restore host/elsa/2019-12-03T09:35:01Z index.json -
831
832
833 Interactive Restores
834 ^^^^^^^^^^^^^^^^^^^^
835
836 If you only want to restore a few individual files, it is often easier
837 to use the interactive recovery shell.
838
839 .. code-block:: console
840
841 # proxmox-backup-client catalog shell host/elsa/2019-12-03T09:35:01Z root.pxar
842 Starting interactive shell
843 pxar:/ > ls
844 bin boot dev etc home lib lib32
845 ...
846
847 The interactive recovery shell is a minimalistic command line interface that
848 utilizes the metadata stored in the catalog to quickly list, navigate and
849 search files in a file archive.
850 To restore files, you can select them individually or match them with a glob
851 pattern.
852
853 Using the catalog for navigation reduces the overhead considerably because only
854 the catalog needs to be downloaded and, optionally, decrypted.
855 The actual chunks are only accessed if the metadata in the catalog is not enough
856 or for the actual restore.
857
858 Similar to common UNIX shells ``cd`` and ``ls`` are the commands used to change
859 working directory and list directory contents in the archive.
860 ``pwd`` shows the full path of the current working directory with respect to the
861 archive root.
862
863 Being able to quickly search the contents of the archive is a commmonly needed feature.
864 That's where the catalog is most valuable.
865 For example:
866
867 .. code-block:: console
868
869 pxar:/ > find etc/**/*.txt --select
870 "/etc/X11/rgb.txt"
871 pxar:/ > list-selected
872 etc/**/*.txt
873 pxar:/ > restore-selected /target/path
874 ...
875
876 This will find and print all files ending in ``.txt`` located in ``etc/`` or a
877 subdirectory and add the corresponding pattern to the list for subsequent restores.
878 ``list-selected`` shows these patterns and ``restore-selected`` finally restores
879 all files in the archive matching the patterns to ``/target/path`` on the local
880 host. This will scan the whole archive.
881
882 With ``restore /target/path`` you can restore the sub-archive given by the current
883 working directory to the local target path ``/target/path`` on your host.
884 By additionally passing a glob pattern with ``--pattern <glob>``, the restore is
885 further limited to files matching the pattern.
886 For example:
887
888 .. code-block:: console
889
890 pxar:/ > cd /etc/
891 pxar:/etc/ > restore /target/ --pattern **/*.conf
892 ...
893
894 The above will scan trough all the directories below ``/etc`` and restore all
895 files ending in ``.conf``.
896
897 .. todo:: Explain interactive restore in more detail
898
899 Mounting of Archives via FUSE
900 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
901
902 The :term:`FUSE` implementation for the pxar archive allows you to mount a
903 file archive as a read-only filesystem to a mountpoint on your host.
904
905 .. code-block:: console
906
907 # proxmox-backup-client mount host/backup-client/2020-01-29T11:29:22Z root.pxar /mnt/mountpoint
908 # ls /mnt/mountpoint
909 bin dev home lib32 libx32 media opt root sbin sys usr
910 boot etc lib lib64 lost+found mnt proc run srv tmp var
911
912 This allows you to access the full contents of the archive in a seamless manner.
913
914 .. note:: As the FUSE connection needs to fetch and decrypt chunks from the
915 backup server's datastore, this can cause some additional network and CPU
916 load on your host, depending on the operations you perform on the mounted
917 filesystem.
918
919 To unmount the filesystem use the ``umount`` command on the mountpoint:
920
921 .. code-block:: console
922
923 # umount /mnt/mountpoint
924
925 Login and Logout
926 ~~~~~~~~~~~~~~~~
927
928 The client tool prompts you to enter the logon password as soon as you
929 want to access the backup server. The server checks your credentials
930 and responds with a ticket that is valid for two hours. The client
931 tool automatically stores that ticket and uses it for further requests
932 to this server.
933
934 You can also manually trigger this login/logout using the login and
935 logout commands:
936
937 .. code-block:: console
938
939 # proxmox-backup-client login
940 Password: **********
941
942 To remove the ticket, issue a logout:
943
944 .. code-block:: console
945
946 # proxmox-backup-client logout
947
948
949 .. _pruning:
950
951 Pruning and Removing Backups
952 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
953
954 You can manually delete a backup snapshot using the ``forget``
955 command:
956
957 .. code-block:: console
958
959 # proxmox-backup-client forget <snapshot>
960
961
962 .. caution:: This command removes all archives in this backup
963 snapshot. They will be inaccessible and unrecoverable.
964
965
966 Although manual removal is sometimes required, the ``prune``
967 command is normally used to systematically delete older backups. Prune lets
968 you specify which backup snapshots you want to keep. The
969 following retention options are available:
970
971 ``--keep-last <N>``
972 Keep the last ``<N>`` backup snapshots.
973
974 ``--keep-hourly <N>``
975 Keep backups for the last ``<N>`` hours. If there is more than one
976 backup for a single hour, only the latest is kept.
977
978 ``--keep-daily <N>``
979 Keep backups for the last ``<N>`` days. If there is more than one
980 backup for a single day, only the latest is kept.
981
982 ``--keep-weekly <N>``
983 Keep backups for the last ``<N>`` weeks. If there is more than one
984 backup for a single week, only the latest is kept.
985
986 .. note:: Weeks start on Monday and end on Sunday. The software
987 uses the `ISO week date`_ system and handles weeks at
988 the end of the year correctly.
989
990 ``--keep-monthly <N>``
991 Keep backups for the last ``<N>`` months. If there is more than one
992 backup for a single month, only the latest is kept.
993
994 ``--keep-yearly <N>``
995 Keep backups for the last ``<N>`` years. If there is more than one
996 backup for a single year, only the latest is kept.
997
998 The retention options are processed in the order given above. Each option
999 only covers backups within its time period. The next option does not take care
1000 of already covered backups. It will only consider older backups.
1001
1002 Unfinished and incomplete backups will be removed by the prune command unless
1003 they are newer than the last successful backup. In this case, the last failed
1004 backup is retained.
1005
1006 .. code-block:: console
1007
1008 # proxmox-backup-client prune <group> --keep-daily 7 --keep-weekly 4 --keep-monthly 3
1009
1010
1011 You can use the ``--dry-run`` option to test your settings. This only
1012 shows the list of existing snapshots and what actions prune would take.
1013
1014 .. code-block:: console
1015
1016 # proxmox-backup-client prune host/elsa --dry-run --keep-daily 1 --keep-weekly 3
1017 ┌────────────────────────────────┬──────┐
1018 │ snapshot │ keep │
1019 ╞════════════════════════════════╪══════╡
1020 │ host/elsa/2019-12-04T13:20:37Z │ 1 │
1021 ├────────────────────────────────┼──────┤
1022 │ host/elsa/2019-12-03T09:35:01Z │ 0 │
1023 ├────────────────────────────────┼──────┤
1024 │ host/elsa/2019-11-22T11:54:47Z │ 1 │
1025 ├────────────────────────────────┼──────┤
1026 │ host/elsa/2019-11-21T12:36:25Z │ 0 │
1027 ├────────────────────────────────┼──────┤
1028 │ host/elsa/2019-11-10T10:42:20Z │ 1 │
1029 └────────────────────────────────┴──────┘
1030
1031 .. note:: Neither the ``prune`` command nor the ``forget`` command free space
1032 in the chunk-store. The chunk-store still contains the data blocks. To free
1033 space you need to perform :ref:`garbage-collection`.
1034
1035
1036 .. _garbage-collection:
1037
1038 Garbage Collection
1039 ~~~~~~~~~~~~~~~~~~
1040
1041 The ``prune`` command removes only the backup index files, not the data
1042 from the data store. This task is left to the garbage collection
1043 command. It is recommended to carry out garbage collection on a regular basis.
1044
1045 The garbage collection works in two phases. In the first phase, all
1046 data blocks that are still in use are marked. In the second phase,
1047 unused data blocks are removed.
1048
1049 .. note:: This command needs to read all existing backup index files
1050 and touches the complete chunk-store. This can take a long time
1051 depending on the number of chunks and the speed of the underlying
1052 disks.
1053
1054 .. note:: The garbage collection will only remove chunks that haven't been used
1055 for at least one day (exactly 24h 5m). This grace period is necessary because
1056 chunks in use are marked by touching the chunk which updates the ``atime``
1057 (access time) property. Filesystems are mounted with the ``relatime`` option
1058 by default. This results in a better performance by only updating the
1059 ``atime`` property if the last access has been at least 24 hours ago. The
1060 downside is, that touching a chunk within these 24 hours will not always
1061 update its ``atime`` property.
1062
1063 Chunks in the grace period will be logged at the end of the garbage
1064 collection task as *Pending removals*.
1065
1066 .. code-block:: console
1067
1068 # proxmox-backup-client garbage-collect
1069 starting garbage collection on store store2
1070 Start GC phase1 (mark used chunks)
1071 Start GC phase2 (sweep unused chunks)
1072 percentage done: 1, chunk count: 219
1073 percentage done: 2, chunk count: 453
1074 ...
1075 percentage done: 99, chunk count: 21188
1076 Removed bytes: 411368505
1077 Removed chunks: 203
1078 Original data bytes: 327160886391
1079 Disk bytes: 52767414743 (16 %)
1080 Disk chunks: 21221
1081 Average chunk size: 2486565
1082 TASK OK
1083
1084
1085 .. todo:: howto run garbage-collection at regular intervalls (cron)
1086
1087
1088 .. _pve-integration:
1089
1090 `Proxmox VE`_ integration
1091 -------------------------
1092
1093 You need to define a new storage with type 'pbs' on your `Proxmox VE`_
1094 node. The following example uses ``store2`` as storage name, and
1095 assumes the server address is ``localhost``, and you want to connect
1096 as ``user1@pbs``.
1097
1098 .. code-block:: console
1099
1100 # pvesm add pbs store2 --server localhost --datastore store2
1101 # pvesm set store2 --username user1@pbs --password <secret>
1102
1103 If your backup server uses a self signed certificate, you need to add
1104 the certificate fingerprint to the configuration. You can get the
1105 fingerprint by running the following command on the backup server:
1106
1107 .. code-block:: console
1108
1109 # proxmox-backup-manager cert info |grep Fingerprint
1110 Fingerprint (sha256): 64:d3:ff:3a:50:38:53:5a:9b:f7:50:...:ab:fe
1111
1112 Please add that fingerprint to your configuration to establish a trust
1113 relationship:
1114
1115 .. code-block:: console
1116
1117 # pvesm set store2 --fingerprint 64:d3:ff:3a:50:38:53:5a:9b:f7:50:...:ab:fe
1118
1119 After that you should be able to see storage status with:
1120
1121 .. code-block:: console
1122
1123 # pvesm status --storage store2
1124 Name Type Status Total Used Available %
1125 store2 pbs active 3905109820 1336687816 2568422004 34.23%
1126
1127
1128
1129 .. include:: command-line-tools.rst
1130
1131 .. include:: services.rst