Backup Non-Proxmox VE System Data to Proxmox Backup Server


Proxmox provides the “proxmox-backup-client” RPM package for CentOS 7 and CentOS 8. The download link is https://github.com/sg4r/proxmox-backup-client/releases/download/v1.0.11/proxmox-backup-1.0.11-2.x86_64.el7.rpm. By installing this PBS client on CentOS 7.8, you can back up directories or files from the system to the designated remote PBS directory.

Installing the Proxmox-backup-client Software

SSH into the source system CentOS, and follow the steps below to install the Proxmox-backup-client via the command line.

Step 1: Install the “sg3_utils” Software

The CentOS client software Proxmox-backup-client depends on the dynamic link library file “/usr/lib64/libsgutils2.so.2.0.0”, so the system must install the “sg3_utils” package. The specific command is as follows:

yum install sg3_utils

If this package is not installed, the backup operation will fail when executing the proxmox-backup-client command due to an error.

Step 2: Download the Proxmox-backup-client Software to the Local Directory

Command:

wget https://github.com/sg4r/proxmox-backup-client/releases/download/v1.0.11/proxmox-backup-1.0.11-2.x86_64.el7.rpm

Step 3: Install the Proxmox-backup-server Software

Command:

yum localinstall proxmox-backup-1.0.11-2.x86_64.el7.rpm

Step 4: Verify Installation

Run the command “proxmox-backup-client version” in any path from the command line. If the version number is displayed without any error messages, the installation is successful.

Configure Remote Proxmox Backup Server Backup Path and Authorization

Log into the Proxmox Backup Server web management interface, add a separate account, storage directory, and assign permissions.

An account “centreon135” and directory “/mnt/datastore/pbs_data/centreon135” are created. The remote client will connect to PBS using the account “centreon135@pbs” and back up data to the subdirectory “centreon135”, without mixing with other backup directories.

Backup Data from CentOS to PBS

Backup is a long-term activity. To verify reliability, manually back up the source data first. Once verified, use the crond tool “crontab” to schedule automatic backup tasks.

Manually Backup the /var/lib/mysql Data Directory to PBS

This is done in two steps. First, log into PBS and save the PBS fingerprint, login password, etc., locally on CentOS. Then, synchronize the data.

Step 1: Log into PBS Client

The username, password, and other information are set in the PBS web management interface. The login command is as follows:

proxmox-backup-client login –repository centreon135@pbs@172.16.228.250:8007:centreon135

On the first login, enter the password for the account “centreon135” and confirm the PBS fingerprint twice. Logging in is optional; if you skip it and run the backup command directly, you’ll be prompted to enter the password and confirm the fingerprint interactively.

Step 2: Back Up the Database Data Directory “/var/lib/mysql” to the PBS Subdirectory “centreon135”

Command:

proxmox-backup-client backup mysql.pxar:/var/lib/mysql –repository centreon135@pbs@172.16.228.250:8007:centreon135

No password is required for this operation, and progress is displayed on the screen.

Backing up this 14 GB database directory took only about 5 minutes, much faster than Rsync or Scp.

Step 3: Verify the Backup

Log into the Proxmox Backup Server web interface, check the “Content” of the storage subdirectory to ensure the backup was successful.

Additionally, from the CentOS command line, you can list the stored data on PBS with the following command:

proxmox-backup-client snapshot list –repository centreon135@pbs@172.16.228.250:8007:centreon135

The output will be displayed in a table format.

Automatically Backup the /var/lib/mysql Data Directory to PBS

Since entering a password is required, it’s difficult to perform automatic backup in a single crontab command. Therefore, you need to write a shell script first, then edit it into the crontab to achieve the goal.

Step 1: Write the Shell Script “/usr/bin/mysql_pbs.sh”

The complete content is as follows:

#!/bin/bash

source /etc/profile

export PBS_PASSWORD=”dweu72U%de”

proxmox-backup-client backup mysql.pxar:/var/lib/mysql –repository centreon135@pbs@172.16.228.250:8007:centreon135

Grant execution permission to this shell script with the command “chmod +x /usr/bin/mysql_pbs.sh”, then execute the script to verify its correctness.

Step 2: Use the “crontab -e” Command to Edit the Scheduled Task

Insert the line “05 02 * * * /usr/bin/mysql_pbs.sh”, save it, and wait until 2:05 AM to confirm whether the scheduled task was executed by checking the log at “/var/log/cron”.

From the log output, it’s clear that the automatic backup job was called normally. Switch to the PBS web management interface, view the “Content” of the relevant subdirectory in the “Data Store”, and confirm that the backup occurred as expected based on the timestamp of the backup file.

Restore Data from Proxmox Backup Server on CentOS

Log into the CentOS system and run the following command to list relevant backup information based on the output:

proxmox-backup-client snapshot list –repository centreon135@pbs@172.16.228.250:8007:centreon135

The command format for restoring data with Proxmox-backup-client is:

proxmox-backup-client restore –repository <strings> <snapshot> <archive-name> <target> [OPTIONS]

The values for “snapshot” and “archive-name” are obtained from the previous backup listing.

The “target” parameter specifies the local CentOS directory where the backup data will be restored.

I just successfully backed up the “/var/lib/mysql” database directory on CentOS to the PBS subdirectory centreon135. To verify the correctness of the backup, I’ll restore it to the local CentOS /tmp directory and compare it with the source directory to roughly assess the validity of the data.

The command line is as follows:

proxmox-backup-client restore –repository centreon135@pbs@172.16.228.250:8007:centreon135 host/mon135/2021-09-22T16:39:32Z mysql.pxar /tmp/mysql

If no errors are reported during the execution, the restore is successful. If you want to check the restore progress, log into the Proxmox Backup Server web interface and click the “Tasks” button on the page to monitor the restore status.


Leave a Reply

Your email address will not be published. Required fields are marked *