While in the first part of this series dedicated to the Proxmox backup server we saw how to install the distribution, and in the second we explored the web administration interface, in this third tutorial, we learn how to create and restore a backup of a physical host using the Proxmox backup client.
In this tutorial we learn how to install the Proxmox backup client, and how to perform a backup of a physical host.
In this tutorial you will learn:
- How to install the Proxmox backup client on Debian and Debian-based distributions
- How to perform a backup of a physical host using the Proxmox backup client
- How to list, mount and restores snapshots
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Debian or a Debian-based distribution |
Software | A running instance of Proxmox backup server |
Other | None |
Conventions | # – requires given linux-commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux-commands to be executed as a regular non-privileged user |
Backup client installation
In order to install the Proxmox backup client on Debian stable (bookworm, at the moment of writing), or one of the many Debian-based distributions, we need to add the dedicated repository to the distribution software sources. We start by downloading the GPG key used to sign and validate packages:
$ curl -O https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg
Once the download is complete, we verify the key sha512 checksum:
$ sha512sum proxmox-release-bookworm.gpg
The command returns the following value, which is exactly what we expect:
7da6fe34168adc6e479327ba517796d4702fa2f8b4f0a9833f5ea6e6b48f6507a6da403a274fe201595edc86a84463d50383d07f64bdde2e3658108db7d6dc87
Once we verified the key is valid, we can move it to the /etc/apt/trusted.gpg.d/
directory:
$ sudo mv proxmox-release-bookworm.gpg /etc/apt/trusted.gpg.d
We can now add the Proxmox repository to the distribution software sources. We can do this by issuing the following command:
$ echo "deb http://download.proxmox.com/debian/pbs-client bookworm main" | sudo tee /etc/apt/sources.list.d/pbs-client.list
At this point we need to sync the repository and, finally, install the “proxmox-backup-client” package:
$ sudo apt update && sudo apt install proxmox-backup-client
Creating a backup
Before performing our first backup, let’s recap our current setup. In the first part of this series, we installed the Proxmox backup server, which can be reached at 192.168.122.72. As part of the second tutorial, instead, we created a datastore called “datastore0”. To create a backup, we use the Proxmox backup client “backup” command, which requires the following syntax:
proxmox-backup-client backup {<backupspec>} [OPTIONS]
Where <backupspec> is the list of sources to backup in the form:
<label.ext>:<path>
Let’s suppose we want to create a backup of the /etc
directory on the client system and send it to the Proxmox backup server we already installed. Here is the command we would run:
$ sudo proxmox-backup-client backup etc.pxar:/etc --repository 192.168.122.72:datastore0
As you can see, we used the “etc” label together with the “.pxar” extension (Proxmox File Archive Format). To specify the server IP, we can either use the --repository
option, or assign it as the value of the PBS_REPOSITORY
environment variable. If no user is specified, “root” is assumed. To proceed, we need to authenticate, and provide its password on the server:
Password for "root@pam":
If it is the first time we perform a backup we must confirm we want to connect to the remote machine. Once the backup is complete, we will get a report:
Starting backup: host/doc-standardpcq35ich92009/2024-01-11T11:01:49Z Client name: doc-standardpcq35ich92009 Starting backup protocol: Thu Jan 11 12:01:55 2024 storing login ticket failed: $XDG_RUNTIME_DIR must be set No previous manifest available. Upload directory '/etc' to '192.168.122.72:datastore0' as etc.pxar.didx etc.pxar: had to backup 78.847 MiB of 78.847 MiB (compressed 6.68 MiB) in 0.66s etc.pxar: average backup speed: 119.457 MiB/s Uploaded backup catalog (45.525 KiB) Duration: 0.79s End Time: Thu Jan 11 12:01:56 2024
If we take a look at the server web interface, we can see an entry is now present under the “datastore0” section:
By clicking on each backup entry, we can see the components of the backup, and by clicking on the “directory” icon in the “Actions” column, we can see the files included in the backup and optionally download them:
Excluding files and directories
In certain situations, we may want to exclude specific files and directories from the backup. To accomplish this task, we need to create a .pxarexclude
file in the root directory of our backup and/or in one of its subdirectories. Let’s see an example. Suppose we want to backup the /etc directory but, for some reason, we want to exclude the /etc/fstab
file, and the content of the /etc/X11
directory. We would create the /etc/.pxarexclude
file, with the following content:
/fstab /X11/*
A .pxarexclude file must contain one entry per line; the directory in which it is located is considered to be the “root” for each pattern. Lines starting with “#” are considered as comments and ignored; the “!” character, at the beginning of a line, turns the pattern to an explicit inclusion. In each entry, a glob character (“*”) matches any other character, while a double glob (“**”) matches the current directory and its subdirectories. To know more about the syntax and expressions which can be used in the file, you can take a look at the dedicated section of the official documentation.
Encrypting backups
The backup we created in the previous example is not encrypted. In order to encrypt our backups, we first need to generate an encryption key:
$ proxmox-backup-client key create
By default, a key is generated as ~/.config/proxmox-backup/encryption-key.json
; this path is automatically searched whenever we use the --keyfile
option. To use any other path, we can specify it as argument to the command. To generate the key as “mykey” in the current working directory, for example, we would run:
$ proxmox-backup-client key create mykey
In order for the key to be generated successfully, we need to provide and confirm an encryption password. To generate an encrypted backup using the key we just generated, we would run:
$ proxmox-backup-client backup etc.pxar:/etc --keyfile mykey --repository 192.168.122.72:datastore0
Listing, restoring and mounting a snapshot
To retrieve the list of the snapshots we created, we can use the “snapshot” command, and the “list” action:
$ sudo proxmox-backup-client snapshot list --repository 192.168.122.72:datastore0
In this case, the command returns the following output:
┌─────────────────────────────────────────────────────┬────────────┬───────────────────────────────────┐ │ snapshot │ size │ files │ ╞═════════════════════════════════════════════════════╪════════════╪═══════════════════════════════════╡ │ host/doc-standardpcq35ich92009/2024-01-11T11:01:49Z │ 78.888 MiB │ catalog.pcat1 etc.pxar index.json │ └─────────────────────────────────────────────────────┴────────────┴───────────────────────────────────┘
We can see the snapshot ID, its size, and its files. In order to retrieve the list of the files included in the backup, we can run:
$ sudo proxmox-backup-client catalog dump --repository 192.168.122.72:datastore0 host/doc-standardpcq35ich92009/2024-01-11T11:01:49Z
To restore a backup we use the “restore” command and provide the name of the archive we want to restore, and the target directory. To restore the etc.pxar archive included in the snapshot, under the /etc directory, for example, we would run:
$ sudo proxmox-backup-client restore --repository 192.168.122.72:datastore0 host/doc-standardpcq35ich92009/2024-01-11T11:01:49Z etc.pxar /etc
Using the “mount” command, we can also mount the archive using FUSE (Filesystem in Userspace). To mount the etc.pxar archive on the /mnt directory, we would run:
$ sudo proxmox-backup-client mount --repository 192.168.122.72:datastore0 host/doc-standardpcq35ich92009/2024-01-11T11:01:49Z etc.pxar /mnt
If the command is successful, the content of the “etc.pxar” archive will be accessible under the given mountpoint.
Conclusions
In this third tutorial of the series dedicated to the proxmox-backup server we learned how to install the backup client on Debian and Debian-based distributions. We saw how to perform a backup, how to generate an encryption key, how to list the snapshots available on the server, and, finally, how to mount and restore a backup archive. To know more about the Proxmox backup client usage, please take a look at the official online documentation or consult the client the manual page.