How to use the command 'vzdump' (with examples)

How to use the command 'vzdump' (with examples)

The vzdump command is a backup utility for virtual machines and containers. It allows users to create backups of their guest virtual machines and provides various options to customize the backup process.

Use case 1: Dump a guest virtual machine into the default dump directory

Code:

vzdump vm_id

Motivation:

  • Users may want to create a backup of a specific guest virtual machine.
  • Dumping the virtual machine into the default dump directory ensures that the backup is stored in a standard location.

Explanation:

  • vzdump: The command itself.
  • vm_id: The ID of the guest virtual machine to be backed up.

Example output:

INFO: Starting Backup of VM 101 (qemu)
INFO: Backup started at 2021-08-10 15:00:00
INFO: Backup finished at 2021-08-10 15:05:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-101-2021_08_10-15_00_00.vma.gz
INFO: Backup completed successfuly!

Use case 2: Back up multiple guest virtual machines

Code:

vzdump 101 102 103

Motivation:

  • Users may want to create backups of multiple guest virtual machines at once.
  • Providing the IDs of the virtual machines allows for a batch backup process.

Explanation:

  • vzdump: The command itself.
  • 101 102 103: The IDs of the guest virtual machines to be backed up.

Example output:

INFO: Starting Backup of VM 101 (qemu)
INFO: Backup started at 2021-08-10 15:00:00
INFO: Backup finished at 2021-08-10 15:05:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-101-2021_08_10-15_00_00.vma.gz
INFO: Backup completed successfuly!

INFO: Starting Backup of VM 102 (qemu)
INFO: Backup started at 2021-08-10 15:05:00
INFO: Backup finished at 2021-08-10 15:10:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-102-2021_08_10-15_05_00.vma.gz
INFO: Backup completed successfuly!

INFO: Starting Backup of VM 103 (qemu)
INFO: Backup started at 2021-08-10 15:10:00
INFO: Backup finished at 2021-08-10 15:15:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-103-2021_08_10-15_10_00.vma.gz
INFO: Backup completed successfuly!

Use case 3: Dump a guest virtual machine using a specific mode

Code:

vzdump vm_id --mode suspend|snapshot

Motivation:

  • Users may want to choose a specific mode for their backup process.
  • The suspend mode suspends the virtual machine during the backup, while the snapshot mode takes a snapshot before backing up.

Explanation:

  • vzdump: The command itself.
  • vm_id: The ID of the guest virtual machine to be backed up.
  • --mode suspend|snapshot: The mode to be used for the backup. Choose either “suspend” or “snapshot”.

Example output (using suspend mode):

INFO: Starting Backup of VM 101 (qemu)
INFO: Suspending VM 101 (qemu)
INFO: Backup started at 2021-08-10 15:00:00
INFO: Backup finished at 2021-08-10 15:05:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-101-2021_08_10-15_00_00.vma.gz
INFO: Backup completed successfuly!

Example output (using snapshot mode):

INFO: Starting Backup of VM 101 (qemu)
INFO: Creating snapshot of VM 101 (qemu)
INFO: Backup started at 2021-08-10 15:00:00
INFO: Backup finished at 2021-08-10 15:05:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-101-2021_08_10-15_00_00.vma.gz
INFO: Backup completed successfuly!

Use case 4: Back up all guest systems and send a notification email

Code:

vzdump --all --mode suspend --mailto root --mailto admin

Motivation:

  • Users may want to back up all guest virtual machines in their environment.
  • Sending a notification email to multiple recipients ensures that important personnel are alerted about the backup process.

Explanation:

  • vzdump: The command itself.
  • --all: Selects all guest virtual machines for backup.
  • --mode suspend: Uses the suspend mode for backup.
  • --mailto root --mailto admin: Specifies the email addresses of the recipients for the notification email.

Example output:

INFO: Starting Backup of VM 101 (qemu)
INFO: Suspending VM 101 (qemu)
INFO: Backup started at 2021-08-10 15:00:00
INFO: Backup finished at 2021-08-10 15:05:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-101-2021_08_10-15_00_00.vma.gz
INFO: Backup completed successfuly!

INFO: Starting Backup of VM 102 (qemu)
INFO: Suspending VM 102 (qemu)
INFO: Backup started at 2021-08-10 15:05:00
INFO: Backup finished at 2021-08-10 15:10:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-102-2021_08_10-15_05_00.vma.gz
INFO: Backup completed successfuly!

INFO: Starting Backup of VM 103 (qemu)
INFO: Suspending VM 103 (qemu)
INFO: Backup started at 2021-08-10 15:10:00
INFO: Backup finished at 2021-08-10 15:15:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-103-2021_08_10-15_10_00.vma.gz
INFO: Backup completed successfuly!

INFO: Sending notification email to root and admin
INFO: Email sent successfully!

Use case 5: Use snapshot mode and a non-default dump directory

Code:

vzdump vm_id --dumpdir path/to/directory --mode snapshot

Motivation:

  • Users may want to specify a different dump directory for their backups.
  • Using the snapshot mode allows them to create backups without interrupting the virtual machine.

Explanation:

  • vzdump: The command itself.
  • vm_id: The ID of the guest virtual machine to be backed up.
  • --dumpdir path/to/directory: Specifies the path to the directory where the backup will be stored.
  • --mode snapshot: Uses the snapshot mode for backup.

Example output:

INFO: Starting Backup of VM 101 (qemu)
INFO: Creating snapshot of VM 101 (qemu)
INFO: Backup started at 2021-08-10 15:00:00
INFO: Backup finished at 2021-08-10 15:05:00
INFO: Backup file: path/to/directory/vzdump-qemu-101-2021_08_10-15_00_00.vma.gz
INFO: Backup completed successfuly!

Use case 6: Back up all guest virtual machines excluding specific IDs

Code:

vzdump --mode suspend --exclude 101, 102

Motivation:

  • Users may want to back up all guest virtual machines except for specific ones.
  • Excluding certain IDs allows for a selective backup process.

Explanation:

  • vzdump: The command itself.
  • --mode suspend: Uses the suspend mode for backup.
  • --exclude 101, 102: Excludes the guest virtual machines with IDs 101 and 102 from the backup process.

Example output:

INFO: Starting Backup of VM 103 (qemu)
INFO: Suspending VM 103 (qemu)
INFO: Backup started at 2021-08-10 15:00:00
INFO: Backup finished at 2021-08-10 15:05:00
INFO: Backup file: /var/lib/vz/dump/vzdump-qemu-103-2021_08_10-15_00_00.vma.gz
INFO: Backup completed successfuly!

Conclusion:

The vzdump command is a powerful backup utility for virtual machines and containers. It provides users with the flexibility to create backups of specific virtual machines, multiple virtual machines, or all virtual machines in their environment. Additionally, users can choose different backup modes, specify custom dump directories, and exclude specific virtual machines from the backup process. Using vzdump helps ensure the safety and availability of virtualized environments by creating regular backups.

Related Posts

How to use the command inotifywait (with examples)

How to use the command inotifywait (with examples)

The inotifywait command is a Linux utility that waits for changes to one or more files or directories.

Read More
How to use the command "gotty" (with examples)

How to use the command "gotty" (with examples)

The “gotty” command allows you to share your terminal as a web application.

Read More
Proxmox Virtual Environment: qm rollback (with examples)

Proxmox Virtual Environment: qm rollback (with examples)

Use Case 1: Rollback the state of a specific VM to a specified snapshot.

Read More