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