### Install qmpbackup Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Commands to set up the virtual environment and install the package. ```bash python3 -m venv venv source venv/bin/activate pip3 install -r requirements.txt python3 setup.py install (alternatively use: `python -m pip install .` on systems deprecating setuptools) ``` -------------------------------- ### Start QEMU in prelaunch mode Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Run QEMU in prelaunch mode to allow backups of offline virtual machines. ```bash qemu-system- -S ``` -------------------------------- ### Create External Snapshot Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Example commands for adding a block device and creating an external snapshot for a disk. ```json blockdev-add driver=qcow2 node-name=snap_1 file={"driver":"file","filename":"/mysnapshot.qcow2"} blockdev-snapshot node=disk1 overlay=snap_1 ``` -------------------------------- ### Inspect VM Start Command Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Stop the VM and display the current command line arguments to identify existing QMP socket configurations. ```bash qm stop 110 qm showcmd 110 /usr/bin/kvm -id 110 -name [..] -chardev 'socket,id=qmp,path=/var/run/qemu-server/110.qmp,server=on,wait=off' ``` -------------------------------- ### Configure QEMU QMP Socket Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Commands to start a virtual machine with a QMP interface via Unix socket or TCP. ```bash qemu-system- -qmp unix:/path/to/socket,server,nowait ``` ```bash qemu-system- -qmp tcp:localhost:4444,server,wait=off ``` -------------------------------- ### Display Backup Directory Structure Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Example of a backup directory containing a full backup and incremental backups. ```text /tmp/backup/ide0-hd0/ ├── FULL-1706260639-disk1.qcow2 ├── INC-1706260646-disk1.qcow2 └── INC-1706260647-disk1.qcow2 ``` -------------------------------- ### Remove dirty-bitmaps Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Clean up existing dirty-bitmaps, typically required before starting a new backup chain. ```bash qmpbackup --socket /path/to/socket cleanup --remove-bitmaps ``` -------------------------------- ### Create metadata qcow image Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Initialize a metadata qcow2 image for raw storage backends. ```bash # point the data-file to a temporary file, as create will overwrite whatever it finds here qemu-img create -f qcow2 /vm1/metadata.qcow2 -o data_file=/tmp/TEMPFILE,data_file_raw=true .. rm -f /tmp/TEMPFILE ``` -------------------------------- ### Verify Socket and Initiate Backup Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Confirm the existence of the new socket file and execute the backup command. ```bash ls -ah /var/run/qemu-server/110-backup.qmp /var/run/qemu-server/110-backup.qmp qmpbackup --socket /var/run/qemu-server/110-backup.qmp backup [..] ``` -------------------------------- ### Enable QEMU guest agent socket Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Required QEMU command-line arguments to expose the guest agent socket to the host. ```bash -chardev socket,path=/tmp/qga.sock,server,nowait,id=qga0 \ -device virtio-serial \ -device "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0" \ ``` -------------------------------- ### Configure Additional QMP Socket Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Add a secondary QMP socket to the VM configuration and restart the VM to apply changes. ```bash qm set 110 --args "-chardev 'socket,id=qmp-backup,path=/var/run/qemu-server/110-backup.qmp,server=on,wait=off' -mon 'chardev=qmp-backup,mode=control'" update VM 110: -args -chardev 'socket,id=qmp-backup,path=/var/run/qemu-server/110-backup.qmp,server=on,wait=off' -mon 'chardev=qmp-backup,mode=control' qm start 110 ``` -------------------------------- ### Perform backup with guest agent quiesce Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Use the --agent-socket and --quiesce flags to ensure filesystem consistency during a backup. ```bash qmpbackup --socket /path/to/socket --agent-socket /tmp/qga.sock backup --level full --target /tmp/ --quisce ``` -------------------------------- ### Perform Full Backup Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Commands to clean up existing bitmaps and initiate a full backup to a target directory. ```bash # remove already existent bitmaps from prior full backups: qmpbackup --socket /path/to/socket cleanup --remove-bitmaps # create a new full backup to an empty directory: qmpbackup --socket /path/to/socket backup --level full --target /tmp/backup/ # example using a tcp endpoint: qmpbackup --socket tcp:localhost:4444 backup --level full --target /tmp/backup/ ``` -------------------------------- ### Enable compression for backups Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Use the --compress flag during blockdev-backup to reduce storage usage at the cost of performance. ```bash qmpbackup --socket /path/to/socket backup [..] --compress ``` -------------------------------- ### Restore raw device backups Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Use standard cp commands to restore sparse raw device backup files. ```bash cp FULL-1782888070-disk3.raw restore.raw cp --sparse=always INC-1782888113-disk3.raw restore.raw ``` -------------------------------- ### List block devices Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Query available block devices suitable for backup operations. ```bash qmpbackup --socket /path/to/socket info --show blockdev ``` -------------------------------- ### Perform Regular Rebase Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Updates the backing image for each backup file in-place. Use the --until option to roll back to a specific incremental point. ```bash qmprestore rebase --dir /tmp/backup/ide0-hd0 ``` ```bash qmprestore rebase --dir /tmp/backup/ide0-hd0 --until INC-1480542701 ``` -------------------------------- ### Check raw device backup size Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Verify the size of sparse files created during raw device backups. ```bash du -h * 10M FULL-1782888070-disk3.raw 256K INC-1782888113-disk3.raw ``` -------------------------------- ### Create Backups with Custom UUID Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Commands to perform full and incremental backups while specifying a UUID to ensure bitmap reuse. ```bash qmpbackup --socket /path/to/socket backup -l full -t /tmp/backup --uuid testme qmpbackup --socket /path/to/socket backup -l inc -t /tmp/backup ``` -------------------------------- ### Execute Monthly Backups Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Command to perform an automatic level backup organized into monthly folders based on the current date. ```bash qmpbackup --socket /path/to/socket backup --level auto --monthly --target /tmp/backup ``` -------------------------------- ### Perform Incremental Backup Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Command to create an incremental backup based on the last full or incremental state. ```bash qmpbackup --socket /path/to/socket backup --level inc --target /tmp/backup/ ``` -------------------------------- ### Rebase with Internal Snapshots Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Rebases images and creates internal snapshots for each incremental backup applied, allowing state switching. ```bash qmprestore snapshotrebase --dir /tmp/backup/ide0-hd0/ [..] qemu-img snapshot -l /tmp/backup/ide0-hd0/FULL-1706260639-disk1.qcow2 Snapshot list: ID TAG VM SIZE DATE VM CLOCK ICOUNT 1 FULL-BACKUP 0 B 2024-10-21 12:50:45 00:00:00.000 0 2 2024-10-21-12:42:48 0 B 2024-10-22 09:23:39 00:00:00.000 0 3 2024-10-21-12:42:49 0 B 2024-10-22 09:23:39 00:00:00.000 0 ``` -------------------------------- ### List existing bitmaps Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Retrieve information about currently tracked dirty-bitmaps. ```bash qmpbackup --socket /path/to/socket info --show bitmaps ``` -------------------------------- ### Rebase with Commit Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Rebases and commits changes back to the images, resulting in a merged image file in the target folder. ```bash qmprestore commit --dir /tmp/backup/ide0-hd0 ``` -------------------------------- ### Merge into New Image Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Restores and rebases backup files into a new target file without modifying the original backup files. ```bash qmprestore merge --dir /tmp/backup/ide0-hd0/ --targetfile /tmp/restore/disk1.qcow2 ``` -------------------------------- ### Set backup speed limit Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Throttle backup operations by specifying a maximum throughput in bytes per second. ```bash qmpbackup --socket /path/to/socket backup [..] --speed-limit 2000000 ``` -------------------------------- ### Trigger automatic full backup with chain removal Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Performs an automatic full backup while removing the previous chain to save space, trading safety for storage capacity. ```bash qmpbackup --socket /path/to/socket backup --level auto --auto-full-ratio 1.5 --auto-full-remove-chain --target /tmp/backup ``` -------------------------------- ### Trigger automatic full backup based on size ratio Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Initiates an automatic backup level where a new full backup is created when the chain size exceeds the specified ratio of the full backup size. ```bash qmpbackup --socket /path/to/socket backup --level auto --auto-full-ratio 1.5 --target /tmp/backup ``` -------------------------------- ### Amend metadata qcow image Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Update the data-file path of an existing metadata qcow2 image to point to the actual storage device. ```bash qemu-img amend /vm1/metadata.qcow2 -o data_file=/dev/lvm/vm1,data_file_raw=true ``` -------------------------------- ### Cleanup Unused Bitmaps Source: https://github.com/abbbi/qmpbackup/blob/master/README.md Commands to remove bitmaps that are no longer required, optionally filtered by a specific UUID. ```bash qmpbackup --socket /path/to/socket cleanup --remove-bitmaps qmpbackup --socket /path/to/socket cleanup --remove-bitmaps --uuid ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.