Class: Pvectl::Models::Backup
Overview
Represents a VM/container backup in Proxmox.
A backup is a full copy of a VM or container stored on a storage backend. Backups can be created via vzdump and restored to create new VMs/containers.
Instance Attribute Summary collapse
-
#ctime ⇒ Integer?
readonly
Unix timestamp when backup was created.
-
#format ⇒ String?
readonly
Backup format (“vma”, “tar”).
-
#node ⇒ String?
readonly
Node name where backup is stored.
-
#notes ⇒ String?
readonly
Optional notes/description.
-
#protected ⇒ Boolean
readonly
Whether backup is protected from deletion.
-
#resource_type ⇒ Symbol?
readonly
Resource type (:qemu or :lxc).
-
#size ⇒ Integer?
readonly
Backup size in bytes.
-
#storage ⇒ String?
readonly
Storage name (extracted from volid).
-
#vmid ⇒ Integer
readonly
VM/container ID.
-
#volid ⇒ String
readonly
Full volume identifier (e.g., “local:backup/vzdump-qemu-100-xxx.vma.zst”).
Instance Method Summary collapse
-
#container? ⇒ Boolean
Checks if the backup is for a container (LXC).
-
#created_at ⇒ Time?
Returns the backup creation time as a Time object.
-
#filename ⇒ String?
Extracts the filename from the volume identifier.
-
#human_size ⇒ String?
Returns human-readable size.
-
#initialize(attrs = {}) ⇒ Backup
constructor
Creates a new Backup instance.
-
#protected? ⇒ Boolean
Checks if the backup is protected from deletion.
-
#vm? ⇒ Boolean
Checks if the backup is for a VM (QEMU).
Constructor Details
#initialize(attrs = {}) ⇒ Backup
Creates a new Backup instance.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/pvectl/models/backup.rb', line 67 def initialize(attrs = {}) super @volid = attributes[:volid] @vmid = attributes[:vmid] @node = attributes[:node] @storage = attributes[:storage] || extract_storage @resource_type = attributes[:resource_type] || detect_resource_type @format = attributes[:format] @size = attributes[:size] @ctime = attributes[:ctime] @notes = attributes[:notes] @protected = attributes[:protected] || false end |
Instance Attribute Details
#ctime ⇒ Integer? (readonly)
Returns Unix timestamp when backup was created.
46 47 48 |
# File 'lib/pvectl/models/backup.rb', line 46 def ctime @ctime end |
#format ⇒ String? (readonly)
Returns backup format (“vma”, “tar”).
40 41 42 |
# File 'lib/pvectl/models/backup.rb', line 40 def format @format end |
#node ⇒ String? (readonly)
Returns node name where backup is stored.
31 32 33 |
# File 'lib/pvectl/models/backup.rb', line 31 def node @node end |
#notes ⇒ String? (readonly)
Returns optional notes/description.
49 50 51 |
# File 'lib/pvectl/models/backup.rb', line 49 def notes @notes end |
#protected ⇒ Boolean (readonly)
Returns whether backup is protected from deletion.
52 53 54 |
# File 'lib/pvectl/models/backup.rb', line 52 def protected @protected end |
#resource_type ⇒ Symbol? (readonly)
Returns resource type (:qemu or :lxc).
37 38 39 |
# File 'lib/pvectl/models/backup.rb', line 37 def resource_type @resource_type end |
#size ⇒ Integer? (readonly)
Returns backup size in bytes.
43 44 45 |
# File 'lib/pvectl/models/backup.rb', line 43 def size @size end |
#storage ⇒ String? (readonly)
Returns storage name (extracted from volid).
34 35 36 |
# File 'lib/pvectl/models/backup.rb', line 34 def storage @storage end |
#vmid ⇒ Integer (readonly)
Returns VM/container ID.
28 29 30 |
# File 'lib/pvectl/models/backup.rb', line 28 def vmid @vmid end |
#volid ⇒ String (readonly)
Returns full volume identifier (e.g., “local:backup/vzdump-qemu-100-xxx.vma.zst”).
25 26 27 |
# File 'lib/pvectl/models/backup.rb', line 25 def volid @volid end |
Instance Method Details
#container? ⇒ Boolean
Checks if the backup is for a container (LXC).
100 101 102 |
# File 'lib/pvectl/models/backup.rb', line 100 def container? resource_type == :lxc end |
#created_at ⇒ Time?
Returns the backup creation time as a Time object.
84 85 86 87 88 |
# File 'lib/pvectl/models/backup.rb', line 84 def created_at return nil if ctime.nil? Time.at(ctime) end |
#filename ⇒ String?
Extracts the filename from the volume identifier.
107 108 109 110 111 |
# File 'lib/pvectl/models/backup.rb', line 107 def filename return nil if volid.nil? volid.split("/").last end |
#human_size ⇒ String?
Returns human-readable size.
116 117 118 119 120 |
# File 'lib/pvectl/models/backup.rb', line 116 def human_size return nil if size.nil? format_bytes(size) end |
#protected? ⇒ Boolean
Checks if the backup is protected from deletion.
125 126 127 |
# File 'lib/pvectl/models/backup.rb', line 125 def protected? @protected == true end |
#vm? ⇒ Boolean
Checks if the backup is for a VM (QEMU).
93 94 95 |
# File 'lib/pvectl/models/backup.rb', line 93 def vm? resource_type == :qemu end |