]> git.proxmox.com Git - proxmox-backup.git/blob - docs/administration-guide.rst
docs: Add documentation for mounting pxar archives via FUSE.
[proxmox-backup.git] / docs / administration-guide.rst
1 Administration Guide
2 ====================
3
4 The administration guide.
5
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, one can split data into fixed or variable
16 sized chunks.
17
18 Fixed sized chunking needs almost no CPU performance, 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 Therefore, the 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 whole directory tree. Content is stored using
33 the :ref:`pxar-format`, split into variable sized chunks. The format
34 is specially 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) binaries like
48 configuration data. 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 basically an index for file archive. It contains
58 the list of files, and is used to speedup search operations.
59
60
61 The Manifest: ``index.json``
62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
64 The manifest contains the list of all backup files, including
65 file 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 contains the virtual machine configuration and an image archive
77 for each disk.
78
79 ``ct``
80 This type is used for :term:`container`\ s. Contains the container
81 configuration and a single file archive for the container content.
82
83 ``host``
84 This type is used for physical host, or if you want to run backups
85 manually from inside virtual machines or containers. Such backups
86 may contain file and image archives (no restrictions here).
87
88
89 Backup ID
90 ~~~~~~~~~
91
92 An 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 We call the tuple ``<type>/<ID>`` a backup group. Such group
106 may contains one or more backup snapshots.
107
108
109 Backup Snapshot
110 ~~~~~~~~~~~~~~~
111
112 We call the triplet ``<type>/<ID>/<time>`` 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 is formatted as RFC3399_ using Coordinated
122 Universal Time (UTC_, identified by the trailing *Z*).
123
124
125 :term:`DataStore`
126 ~~~~~~~~~~~~~~~~~
127
128 A datastore is a place to store backups. The current implementation
129 uses a directory inside a standard unix file system (``ext4``, ``xfs``
130 or ``zfs``) to store backup data.
131
132 Datastores are identified by a simple *ID*. You can configure that
133 when setting up the backup server.
134
135
136 Backup Server Management
137 ------------------------
138
139 The command line tool to configure and manage the server is called
140 :command:`proxmox-backup-manager`.
141
142
143 Datastore Configuration
144 ~~~~~~~~~~~~~~~~~~~~~~~
145
146 A :term:`datastore` is a place to store backups. You can configure
147 several datastores, but you need at least one of them. The datastore is identified by a simple `name` and point to a directory.
148
149 The following command creates a new datastore called ``store1`` on :file:`/backup/disk1/store1`
150
151 .. code-block:: console
152
153 # proxmox-backup-manager datastore create store1 /backup/disk1/store1
154
155 To list existing datastores use:
156
157 .. code-block:: console
158
159 # proxmox-backup-manager datastore list
160 store1 /backup/disk1/store1
161
162 Finally, it is also possible to remove the datastore configuration:
163
164 .. code-block:: console
165
166 # proxmox-backup-manager datastore remove store1
167
168 .. note:: Above command removes the datastore configuration. It does
169 not delete any data from the underlying directory.
170
171
172 File Layout
173 ^^^^^^^^^^^
174
175 .. todo:: Add datastore file layout example
176
177
178 Backup Client usage
179 -------------------
180
181 The command line client is called :command:`proxmox-backup-client`.
182
183
184 Respository Locations
185 ~~~~~~~~~~~~~~~~~~~~~
186
187 The client uses a special repository notation to specify a datastore
188 on the backup server.
189
190 [[username@]server:]datastore
191
192 If you do not specify a ``username`` the default is ``root@pam``. The
193 default for server is to use the local host (``localhost``).
194
195 You can pass the repository by setting the ``--repository`` command
196 line options, or by setting the ``PBS_REPOSITORY`` environment
197 variable.
198
199
200 Environment Variables
201 ~~~~~~~~~~~~~~~~~~~~~~
202
203 ``PBS_REPOSITORY``
204 The default backup repository.
205
206 ``PBS_PASSWORD``
207 When set, this value is used for the password required for the
208 backup server.
209
210 ``PBS_ENCRYPTION_PASSWORD``
211 When set, this value is used to access the secret encryption key (if
212 protected by password).
213
214
215 Creating Backups
216 ~~~~~~~~~~~~~~~~
217
218 This section explains how to create backup on physical host, or from
219 inside virtual machines or containers. Such backups may contain file
220 and image archives (no restrictions here).
221
222 .. note:: If you want to backup virtual machines or containers see :ref:`pve-integration`.
223
224 The prerequisite is that you have already set up (or can access) a
225 backup server. It is assumed that you know the repository name and
226 credentials. In the following examples we simply use ``backup-server:store1``.
227
228 .. code-block:: console
229
230 # proxmox-backup-client backup root.pxar:/ --repository backup-server:store1
231 Starting backup: host/elsa/2019-12-03T09:35:01Z
232 Client name: elsa
233 skip mount point: "/boot/efi"
234 skip mount point: "/dev"
235 skip mount point: "/run"
236 skip mount point: "/sys"
237 Uploaded 12129 chunks in 87 seconds (564 MB/s).
238 End Time: 2019-12-03T10:36:29+01:00
239
240 This will prompt you for a password and then uploads a file archive named
241 ``root.pxar`` containing all the files in the ``/`` directory.
242
243 .. Caution:: Please note that proxmox-backup-client does not
244 automatically include mount points. Instead, you will see a short
245 ``skip mount point`` notice for each of them. The idea is that you
246 create a separate file archive for each mounted disk. You can also
247 explicitly include them using the ``--include-dev`` option
248 (i.e. ``--include-dev /boot/efi``). You can use this option
249 multiple times, once for each mount point you want to include.
250
251 The ``--repository`` option is sometimes quite long and is used by all
252 commands. You can avoid having to enter this value by setting the
253 environment variable ``PBS_REPOSITORY``.
254
255 .. code-block:: console
256
257 # export PBS_REPOSTORY=backup-server:store1
258
259 You can then execute all commands without specifying the ``--repository``
260 option.
261
262 One signle backup is allowed to contain more than one archive. For example, assume you want to backup two disks mounted at ``/mmt/disk1`` and ``/mnt/disk2``:
263
264 .. code-block:: console
265
266 # proxmox-backup-client backup disk1.pxar:/mnt/disk1 disk2.pxar:/mnt/disk2
267
268 This create a backup of both disks.
269
270 The backup command takes a list of backup specifications, which
271 include archive name on the server, the type of the archive, and the
272 archive source at the client. The format is quite simple to understand:
273
274 <archive-name>.<type>:<source-path>
275
276 Common types are ``.pxar`` for file archives, and ``.img`` for block
277 device images. Thus it is quite easy to create a backup for a block
278 device:
279
280 .. code-block:: console
281
282 # proxmox-backup-client backup mydata.img:/dev/mylvm/mydata
283
284
285 Encryption
286 ^^^^^^^^^^
287
288 Proxmox backup support client side encryption using AES-256 in GCM_
289 mode. You first need to create an encryption key in order to use that:
290
291 .. code-block:: console
292
293 # proxmox-backup-client key create my-backup.key
294 Encryption Key Password: **************
295
296 The key is password protected by default. If you do not need this
297 extra protection, you can also create it without a password:
298
299 .. code-block:: console
300
301 # proxmox-backup-client key create /path/to/my-backup.key --kdf none
302
303
304 .. code-block:: console
305
306 # proxmox-backup-client backup etc.pxar:/etc --keyfile /path/to/my-backup.key
307 Password: *********
308 Encryption Key Password: **************
309 ...
310
311
312 You can avoid having to enter the passwords by setting the environment
313 variables ``PBS_PASSWORD`` and ``PBS_ENCRYPTION_PASSWORD``.
314
315 .. todo:: Explain master-key
316
317
318 Restoring Data
319 ~~~~~~~~~~~~~~
320
321 The regular creation of backups is a necessary step to avoid data
322 loss. More important, however, is the restoration. Be sure to perform
323 periodic recovery tests to ensure that you can access your data in
324 case of problems.
325
326 First, you need to find the snapshot you want to restore. The snapshot
327 command gives you a list of all snapshots on the server:
328
329 .. code-block:: console
330
331 # proxmox-backup-client snapshots
332 ...
333 host/elsa/2019-12-03T09:30:15Z | 51788646825 | root.pxar catalog.pcat1 index.json
334 host/elsa/2019-12-03T09:35:01Z | 51790622048 | root.pxar catalog.pcat1 index.json
335 ...
336
337 You can also inspect the catalog to find specific files.
338
339 .. code-block:: console
340
341 # proxmox-backup-client catalog dump host/elsa/2019-12-03T09:35:01Z
342 ...
343 d "./root.pxar.didx/etc/cifs-utils"
344 l "./root.pxar.didx/etc/cifs-utils/idmap-plugin"
345 d "./root.pxar.didx/etc/console-setup"
346 ...
347
348 The restore command lets you restore a single archive from the
349 backup.
350
351 .. code-block:: console
352
353 # proxmox-backup-client restore host/elsa/2019-12-03T09:35:01Z root.pxar /target/path/
354
355 You can instead simply download the contents of any archive using '-'
356 instead of ``/target/path``. This dumps the content to standard
357 output:
358
359 .. code-block:: console
360
361 # proxmox-backup-client restore host/elsa/2019-12-03T09:35:01Z index.json -
362
363
364 Interactive Restores
365 ^^^^^^^^^^^^^^^^^^^^
366
367 If you only want to restore a few individual files, it is often easier
368 to use the interactive recovery shell.
369
370 .. code-block:: console
371
372 # proxmox-backup-client catalog shell host/elsa/2019-12-03T09:35:01Z root.pxar
373 Starting interactive shell
374 pxar:/ > ls
375 bin boot dev etc home lib lib32
376 ...
377
378 The interactive recovery shell is a minimalistic command line interface that
379 utilizes the metadata stored in the catalog for you to quickly list, navigate and
380 search files contained within a file archive.
381 You can select individual files as well as select files matched by a glob pattern
382 for restore.
383
384 The use of the catalog for navigation reduces the overhead otherwise caused by
385 network traffic and decryption, as instead of downloading and decrypting
386 individual encrypted chunks from the chunk store to access the metadata, we only
387 need to download and decrypt the catalog.
388 The actual chunks are only accessed if the metadata in the catalog is not enough
389 or for the actual restore.
390
391 Similar to common UNIX shells ``cd`` and ``ls`` are the commands used to change
392 working directory and list directory contents of the archive.
393 ``pwd`` shows the full path of the current working directory with respect to the
394 archive root.
395
396 Being able to quickly search the contents of the archive is a often needed feature.
397 That's where the catalog is most valuable.
398 For example:
399
400 .. code-block:: console
401
402 pxar:/ > find etc/ **/*.txt --select
403 "/etc/X11/rgb.txt"
404 pxar:/ > list-selected
405 etc/**/*.txt
406 pxar:/ > restore-selected /target/path
407 ...
408
409 This will find and print all files ending in ``.txt`` located in ``etc/`` or a
410 subdirectory and add the corresponding pattern to the list for subsequent restores.
411 ``list-selected`` shows these patterns and ``restore-selected`` finally restores
412 all files in the archive matching the patterns to ``/target/path`` on the local
413 host. This will scan the whole archive.
414
415 With ``restore /target/path`` you can restore the sub-archive given by the current
416 working directory to the local target path ``/target/path`` on your host.
417 By additionally passing a glob pattern with ``--pattern <glob>``, the restore is
418 further limited to files matching the pattern.
419 For example:
420
421 .. code-block:: console
422
423 pxar:/ > cd /etc/
424 pxar:/etc/ > restore /target/ --pattern **/*.conf
425 ...
426
427 The above will scan trough all the directories below ``/etc`` and restore all
428 files ending in ``.conf``.
429
430 .. todo:: Explain interactive restore in more detail
431
432 Mounting of Archives via FUSE
433 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
434
435 The :term:`FUSE` implementation for the pxar archive allows you to mount a
436 file archive as a read-only filesystem to a mountpoint on your host.
437
438 .. code-block:: console
439
440 # proxmox-backup-client mount host/backup-client/2020-01-29T11:29:22Z root.pxar /mnt
441 # ls /mnt
442 bin dev home lib32 libx32 media opt root sbin sys usr
443 boot etc lib lib64 lost+found mnt proc run srv tmp var
444
445 This allows you to access the full content of the archive in a seamless manner.
446
447 .. note:: As the FUSE connection needs to fetch and decrypt chunks from the
448 backup servers datastore, this can cause some additional network and CPU
449 load on your host, depending on the operations you perform on the mounted
450 filesystem.
451
452 To unmount the filesystem simply use the ``umount`` command on the mountpoint:
453
454 .. code-block:: console
455
456 # umount /mnt
457
458 Login and Logout
459 ~~~~~~~~~~~~~~~~
460
461 The client tool prompts you to enter the logon password as soon as you
462 want to access the backup server. The server checks your credentials
463 and responds with a ticket that is valid for two hours. The client
464 tool automatically stores that ticket and use it for further requests
465 to this server.
466
467 You can also manually trigger this login/logout using the login and
468 logout commands:
469
470 .. code-block:: console
471
472 # proxmox-backup-client login
473 Password: **********
474
475 To remove the ticket, simply issue a logout:
476
477 .. code-block:: console
478
479 # proxmox-backup-client logout
480
481
482 Pruning and Removing Backups
483 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
484
485 You can manually delete a backup snapshot using the ``forget``
486 command:
487
488 .. code-block:: console
489
490 # proxmox-backup-client forget <snapshot>
491
492
493 .. caution:: This command removes all the archives in this backup
494 snapshot so that they are inaccessible and unrecoverable.
495
496
497 Such manual removal is sometimes required, but normally the prune
498 command is used to systematically delete older backups. Prune lets
499 you specify which backup snapshots you want to keep. There are the
500 following retention options:
501
502 ``--keep-last <N>``
503 Keep the last ``<N>`` backup snapshots.
504
505 ``--keep-hourly <N>``
506 Keep backups for the last ``<N>`` different hours. If there is more than one
507 backup for a single hour, only the latest one is kept.
508
509 ``--keep-daily <N>``
510 Keep backups for the last ``<N>`` different days. If there is more than one
511 backup for a single day, only the latest one is kept.
512
513 ``--keep-weekly <N>``
514 Keep backups for the last ``<N>`` different weeks. If there is more than one
515 backup for a single week, only the latest one is kept.
516
517 .. note:: The weeks start on Monday and end on Sunday. The software
518 uses the `ISO week date`_ system and correctly handles weeks at
519 the end of the year.
520
521 ``--keep-monthly <N>``
522 Keep backups for the last ``<N>`` different months. If there is more than one
523 backup for a single month, only the latest one is kept.
524
525 ``--keep-yearly <N>``
526 Keep backups for the last ``<N>`` different years. If there is more than one
527 backup for a single year, only the latest one is kept.
528
529
530 Those retention options are processed in the order given above. Each
531 option covers a specific period of time. We say that backups within
532 this period are covered by this option. The next option does not take
533 care of already covered backups and only considers older backups.
534
535 The prune command also looks for unfinished and incomplete backups and
536 removes them unless they are newer than the last successful backup. In
537 this case, the last failed backup is retained.
538
539 .. code-block:: console
540
541 # proxmox-backup-client prune <group> --keep-daily 7 --keep-weekly 4 --keep-monthly 3
542
543
544 You can use the ``--dry-run`` option to test your settings. This just
545 shows the list of existing snapshots and what action prune would take
546 on that.
547
548 .. code-block:: console
549
550 # proxmox-backup-client prune host/elsa --dry-run --keep-daily 1 --keep-weekly 3
551 retention options: --keep-daily 1 --keep-weekly 3
552 Testing prune on store "store2" group "host/elsa"
553 host/elsa/2019-12-04T13:20:37Z keep
554 host/elsa/2019-12-03T09:35:01Z remove
555 host/elsa/2019-11-22T11:54:47Z keep
556 host/elsa/2019-11-21T12:36:25Z remove
557 host/elsa/2019-11-10T10:42:20Z keep
558
559
560 .. note:: Neither the ``prune`` command nor the ``forget`` command free space
561 in the chunk-store. The chunk-store still contains the data blocks
562 unless you are performing :ref:`garbage-collection`.
563
564
565 .. _garbage-collection:
566
567 Garbage Collection
568 ~~~~~~~~~~~~~~~~~~
569
570 The ``prune`` command removes only the backup index files, not the data
571 from the data store. This task is left to the garbage collection
572 command. It is therefore recommended to carry out garbage collection
573 regularly.
574
575 The garbage collection works in two phases. In the first phase, all
576 data blocks that are still in use are marked. In the second phase,
577 unused data blocks are removed.
578
579 .. note:: This command needs to read all existing backup index files
580 and touches the complete chunk store. This can take a long time
581 depending on the number of chunk and the speed of the underlying
582 disks.
583
584
585 .. code-block:: console
586
587 # proxmox-backup-client garbage-collect
588 starting garbage collection on store store2
589 Start GC phase1 (mark used chunks)
590 Start GC phase2 (sweep unused chunks)
591 percentage done: 1, chunk count: 219
592 percentage done: 2, chunk count: 453
593 ...
594 percentage done: 99, chunk count: 21188
595 Removed bytes: 411368505
596 Removed chunks: 203
597 Original data bytes: 327160886391
598 Disk bytes: 52767414743 (16 %)
599 Disk chunks: 21221
600 Average chunk size: 2486565
601 TASK OK
602
603
604 .. todo:: howto run garbage-collection at regular intervalls (cron)
605
606
607 .. _pve-integration:
608
609 `Proxmox VE`_ integration
610 -------------------------
611
612
613 .. include:: command-line-tools.rst
614
615 .. include:: services.rst
616
617 .. include host system admin at the end
618
619 .. include:: sysadmin.rst