Home VM Tips Proxmox Scripts | Benefits & Practice

Proxmox Scripts | Benefits & Practice

2023-11-30 | Dan Zeng

Table of contents
  • Benefits of using Proxmox command line
  • How to perform tasks with Proxmox scripts?
  • Protect your Proxmox VM with Vinchin Backup & Recovery
  • Conclusion
Are you looking for a robust VM backup solution? Try Vinchin Backup & Recovery!↘ Download Free Trial

Proxmox Scripts refers to scripts that run on Proxmox Virtual Environment (Proxmox VE), an open source virtualization management platform that allows you to easily manage virtual machines  and containers. Through Proxmox scripts, you can perform automated tasks, configure and manage various settings in the virtualized environment.

Benefits of using Proxmox command line

Automate tasks: Save time and reduce errors by automating common tasks such as VM creation, backup, restore, and cluster management through Proxmox command.

Batch operation: Easily batch process multiple VMs or containers using Proxmox scripts to improve management efficiency, especially for large-scale environments.

Consistency and repeatability: Proxmox command ensures consistency of configuration and operation, avoiding human error. It is also possible to repeat the same steps at different times and in different environments.

Improve efficiency: Quickly perform tasks via Proxmox command line, eliminating time spent manually configuring them on the web interface. Improve the efficiency of your entire virtualized environment.

Customization and scalability: Writing custom Proxmox command line to meet specific needs provides greater flexibility and adaptability to make virtualized environments more customizable.

How to perform tasks with Proxmox scripts?

The following is a detailed discussion on how to perform varied tasks with the help of Proxmox scripts. It covers the creation, startup, backup and recovery of virtual machines, as well as the backup and recovery of snapshots, compression and encryption of VMs.

By mastering these scripting skills, you will be able to more fully utilize the functions of Proxmox VE and make the management and maintenance of virtualized environments easier. This is not only for beginners, but also for experienced administrators who want to utilize Proxmox VE more flexibly and efficiently.

To perform Proxmox command, following these steps:

1. Login to Proxmox VE page

2. Click host > choose Shell


To create a Proxmox virtual machine

qm create <vmid> --name <vm_name> --memory <memory_size> --net0 <model=e1000,bridge=vmbr0> --cores <number_of_cores> --sockets <number_of_sockets> --cpu <cpu_type>
qm create 1233456 --name 12345 --memory 1024 --net0 model=e1000,bridge=vmbr0 --cores 2 --sockets 1 --cpu host


<vmid>: ID of the VM, which must be unique.

<vm_name>: Name of the VM.

<memory_size>: The size of the memory allocated to the VM, e.g. 1024 means 1GB.

<model=e1000,bridge=vmbr0>: Network configuration, which can be modified as needed.

<number_of_cores>: Number of CPU cores used by the VM

<number_of_sockets>: Number of CPU slots in the VM

<cpu_type>: The CPU type of the VM, e.g. host indicates that the CPU type of the host is used.

 create a Proxmox virtual machine

To start a Proxmox virtual machine

qm start [vmid]
qm start 123345

 start a Proxmox virtual machine

To create a Proxmox Snapshot

qm snapshot [vmid] [snapshot_name] [OPTIONS]
qm snapshot 1233456 snapshot_22222 --vmstate true

create a Proxmox Snapshot

create a Proxmox Snapshot

To restore the Proxmox Snapshot

qm rollback[vmid] [snapshot_name]
qm rollback 1233456 snapshot_22222

estore the Proxmox Snapshot

To backup the Proxmox virtual machine

1. Enter the following Proxmox script to get the storage ID.:

pvesm status

backup the Proxmox virtual machine

2. Type the following Proxmox command line:

vzdump [vmid] --storage [storage_id]
vzdump 1233456 --storage backupdir

backup the Proxmox virtual machine

backup the Proxmox virtual machine

To recover the Proxmox virtual machine

qmrestore /path/to/backup-file.vma [new_vm_id]
qmrestore /var/lib/vz/dump/vzdump-qemu-1233456-2023_11_29-10_09_37.vma 8888989

recover the Proxmox virtual machine

recover the Proxmox virtual machine

To compress the Proxmox VM

vzdump [VMID] --dumpdir /var/lib/vz/dump --compress lzo
vzdump 1233456 --dumpdir /var/lib/vz/dump --compress lzo


--compress lzo: Indicates that the LZO compression algorithm is used. You can choose other supported compression algorithms, such as gzip or zstd, depending on your needs.

--dumpdir /var/lib/vz/dump: Specify the storage directory for the backup file. You can change the directory path as needed.

compress the Proxmox VM

To encrypt the Proxmox VM

pvesm set <storage-id> --encryption-key autogen
pvesm set sdsdsds --encryption-key autogen

Make sure you use a sufficiently new libpve-storage-perl package (>= 6.2-3)

By default, containers backed up to this storage are encrypted, and so are VMs. 

encrypt the Proxmox VM

Protect your Proxmox VM with Vinchin Backup & Recovery

While scripting is excellent for improving system management efficiency, relying solely on scripts can lead to increased complexity and errors, especially when it comes to backing up and protecting critical VMs.

Vinchin Backup & Recovery is a backup solution designed for virtual machines of VMware, Hyper-V, XenServer, XCP-ng, oVirt, RHV, etc. It provides comprehensive and powerful VM backup and recovery features like agentless backup, instant recovery, V2V migration designed to protect and manage critical data in the virtualization environment.

Vinchin Backup & Recovery’s operation is very simple, just a few simple steps. 

1. Just select VMs on the host

Vinchin Backup & Recovery

2. Then select backup destination 

Vinchin Backup & Recovery

3. Select strategies

Vinchin Backup & Recovery

4. Finally submit the job

Vinchin Backup & Recovery

Vinchin offers a free 60-day trial for users to experience the functionality in a real-world environment. For more information, please contact Vinchin directly or contact our local partners.


In summary, Proxmox scripts simplify virtualized environment management, increasing efficiency through automation and customization. This article explores creating, launching, backing up and restoring and etc. Proxmox commands deliver superior performance, while specialized backup solutions such as Vinchin Backup & Recovery provide robust VM protection and simplify critical data management. Explore these tools to efficiently optimize your virtualized environment.

Share on:

Categories: VM Tips