xenserver 备份和还原
1. 备份和还原xenserver host系统
//备份
# xe host-backup file-name=[name.xbk] -s [ip] -u [username] -pw [password]
# xe host-backup file-name=redhat.xbk -s 127.0.0.1 -u root -pw 123456
-s : 备份服务器地址或名称
//还原
# xe host-restore file-name=[name.xbk] -s [ip] -u [username] -pw [password]
# xe host-restore file-name=redhat.xbk
2. 备份和还原xenserver vm虚拟机
# xe vm-export vm=[vm_uuid] filename=[filename.xva]
首先保证vm状态(expected: halted, suspended)
//获取虚拟机列表
# xe vm-list
uuid ( RO) : 0d166725-92a8-f3a7-2817-48df158129c5
name-label ( RW): redhat
power-state ( RO): running
uuid ( RO) : e99ae4b3-e585-4b58-bc52-41e3d133c717
name-label ( RW): Control domain on host: xenserver-nxhzbzto
power-state ( RO): running
//导出
# xe vm-export vm=0d166725-92a8-f3a7-2817-48df158129c5 filename=export.xva
//只导出metadata
# xe vm-export vm=0d166725-92a8-f3a7-2817-48df158129c5 filename=export.xva --metadata
//导入
# xe vm-import filename=[filename.xva]
# xe vm-import filename=export.xva
8e5eae25-087b-e797-b6e9-35c6670ba860
3. 备份和还原pool中的metadata
//备份
# xe pool-dump-database file-name=[name]
//还原
# xe pool-restore-database file-name=[name] dry-run=true
4. 快照snapshot
//创建
# xe vm-snapshot vm=[vm_uuid] new-name-label=[name]
# xe vm-snapshot vm=0d166725-92a8-f3a7-2817-48df158129c5 new-name-label=redhat.snapshot
eb4d60ce-b1f5-ae62-0d40-df45b7b0b319
//查看
# xe snapshot-list
//恢复
# xe snapshot-revert snapshot-uuid=[snapshot_uuid]
# xe snapshot-revert snapshot-uuid=eb4d60ce-b1f5-ae62-0d40-df45b7b0b319
//删除
# xe snapshot-uninstall snapshot-uuid=[snapshot_uuid]
# xe snapshot-uninstall snapshot-uuid=eb4d60ce-b1f5-ae62-0d40-df45b7b0b319
The following items are about to be destroyed
VM : eb4d60ce-b1f5-ae62-0d40-df45b7b0b319 (redhat.snapshot)
VDI: 810e4090-e9c4-4028-86a4-1a988572ef5e (redhat 0)
Type 'yes' to continue
yes
//删除force
# xe snapshot-destroy snapshot-uuid=[snapshot_uuid]
# xe snapshot-destroy snapshot-uuid=eb4d60ce-b1f5-ae62-0d40-df45b7b0b319
//导出
# xe snapshot-export-to-template snapshot-uuid=[snapshot_uuid] filename=[name.xva]
# xe snapshot-export-to-template snapshot-uuid=eb4d60ce-b1f5-ae62-0d40-df45b7b0b319 filename=snapshot.xva
Export succeeded
//导入
# xe vm-import filename=[name.xva]
# xe vm-import filename=snapshot.xva
d57e868f-1d95-f60a-957e-d4f571bb2205
导入之后是模版,可以用来创建虚拟机
5. 模版template
//查看
# xe template-list
//删除
# xe template-uninstall template-uuid=d57e868f-1d95-f60a-957e-d4f571bb2205
The following items are about to be destroyed
VM : f32d55cb-37e6-6534-7099-651cd77f7b3d (redhat (1))
VDI: 45746899-9fbd-4e48-9b3d-70a1aadfa817 (redhat 0)
VDI: 9b6e4792-57d8-4cfa-b8a2-80435236dfae (Suspend image)
Type 'yes' to continue
yes
All objects destroyed
6. vm挂起状态
从挂起状态,强制关机
# xe snapshot-reset-powerstate uuid=[uuid] force=true
# xe snapshot-reset-powerstate uuid=f32d55cb-37e6-6534-7099-651cd77f7b3d force=true
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!