How Do I Create Backup Storage Targets for Proxmox VE VMs?
Introduction
Backing up virtual machines (VMs) is a crucial part of maintaining a reliable and secure IT infrastructure. Proxmox VE, a popular open-source virtualization platform, allows you to manage VMs efficiently. To ensure data safety and integrity, creating backup storage targets is essential. In this guide, we will explore how to set up Amazon S3 as a backup storage target for Proxmox VE VMs. This involves creating an S3 bucket, configuring IAM roles and policies, and integrating them with Proxmox VE.
Step-by-Step Process
1. Create an S3 Bucket
First, we need to set up an S3 bucket where the Proxmox VE backups will be stored. The bucket should have versioning enabled to manage different versions of the backups and lifecycle rules to automatically delete old backups after a specified period.
2. Configure an IAM Role
Next, create an IAM role that Proxmox VE can assume. This role will allow Proxmox to interact with the S3 bucket for backup operations. The role will have a trust relationship with the EC2 service, enabling it to be assumed by Proxmox VE instances.
3. Define IAM Policy
After setting up the role, define an IAM policy that specifies the permissions required to access and manage the backups in the S3 bucket. This includes permissions to put objects, list the bucket contents, and get the bucket location.
4. Attach the Policy to the Role
Once the policy is defined, attach it to the IAM role. This step ensures that the role has the necessary permissions to perform backup operations on the S3 bucket.
5. Export Details for Integration
Finally, export the bucket name and IAM role ARN. These details will be used to configure Proxmox VE to interact with the S3 bucket for storing VM backups.
Below is the complete TypeScript program script that implements the above steps:
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// Create an S3 bucket for Proxmox VE backups
const proxmoxBackup = new aws.s3.BucketV2("proxmox_backup", {
bucket: "proxmox-ve-backup-bucket",
acl: "private",
versionings: [{
enabled: true,
}],
lifecycleRules: [{
id: "retain-backups",
enabled: true,
expirations: [{
days: 30,
}],
noncurrentVersionExpirations: [{
days: 30,
}],
}],
});
// Create an IAM role for Proxmox VE to access the S3 bucket
const proxmoxBackupRole = new aws.iam.Role("proxmox_backup_role", {
name: "proxmox-backup-role",
assumeRolePolicy: JSON.stringify({
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Principal: {
Service: "ec2.amazonaws.com",
},
Action: "sts:AssumeRole",
}],
}),
});
// Define the policy for access to the S3 bucket
const proxmoxBackupPolicy = new aws.iam.Policy("proxmox_backup_policy", {
name: "ProxmoxBackupPolicy",
description: "Policy to allow Proxmox VE to write backups to the S3 bucket",
policy: pulumi.jsonStringify({
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Action: [
"s3:PutObject",
"s3:PutObjectAcl",
"s3:ListBucket",
"s3:GetBucketLocation",
],
Resource: [
proxmoxBackup.arn,
pulumi.interpolate`${proxmoxBackup.arn}/*`,
],
}],
}),
});
// Attach the policy to the role
const proxmoxBackupRolePolicyAttachment = new aws.iam.RolePolicyAttachment("proxmox_backup_role_policy_attachment", {
role: proxmoxBackupRole.name,
policyArn: proxmoxBackupPolicy.arn,
});
export const bucketName = proxmoxBackup.bucket;
export const iamRoleArn = proxmoxBackupRole.arn;
Key Points
- Amazon S3 is used as a reliable storage backend for Proxmox VE backups.
- An S3 bucket is configured with versioning and lifecycle management to handle backup retention.
- IAM roles and policies are crucial for granting Proxmox VE the necessary permissions to interact with the S3 bucket.
- Exporting the bucket name and IAM role ARN is essential for integrating with Proxmox VE.
Conclusion
By following this guide, you can efficiently create backup storage targets for Proxmox VE VMs using AWS S3. This setup not only ensures that your VM data is securely backed up but also leverages AWS’s scalable and durable storage infrastructure. With the configured IAM roles and policies, Proxmox VE can seamlessly manage backups, providing peace of mind and data protection.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.