在Xen Server 6.1上,为了备份我的虚拟机,我使用了基于以下工具的脚本:
xe vm-listbuild立要备份的虚拟机列表 xe vm-snapshot拍摄虚拟机的快照 xe template-param-set is-a-template=false ha-always-run=false将快照转换为虚拟机 xe vm-export vm=uuid_of_this_new_vm filename=|ssh ..... "cat > /path/backup.xva" xe vm-uninstall 我想使用sshfs来挂载我的Xen主机上的远程备份服务器。 但是,sshfs在Xen发行版或默认存储库(XenServer 6.1.0更新)中不可用。
我有几种可能性在我的Xen主机上安装sshfs:
或者我find一种方法来pipe道远程SSH命令到xe vm-import像我这样做出口。 我testing了很多东西,但没有任何工作
你认为最好的解决scheme是什么?
虽然这是一个古老的问题,但我自己也是这样想的。
首先..什么都行不通(全部在XenServer 6.5上testing过):
xe-import filename=/dev/stdin 根本不起作用。 不pipe你做什么都没关系:
# simple local import on xenhost xe vm-import filename=/dev/stdin < myexport.xva # try it the other way, with cat, still won't work: cat myexport.xva | xe vm-import filename=/dev/stdin # and no, dd instead of cat in the above does not make it better # nor can you pull the file from elsewhere via ssh: ssh user@backupserver "cat myexport.xva" | xe vm-import filename=/dev/stdin # nor the other way, pushing from elsewhere to your xenserver ssh root@xenhost "xe vm-import filename=/dev/stdin" < myexport.xva # named pipes don't work either, even locally: mkfifo mypipe cat myexport.xva > ./mypipe & xe vm-import filename=./mypipe
所以,我发现,没有办法从一个stream中导入,它必须是一个真正的文件系统。 显然这用于工作,但现在不。 我的猜测是,XenServer想要寻求。
(如果有人能够发现我的错误,certificate我错了,我会非常感激的)。
所以,是的,我的结论是你必须使用远程文件系统,而且我们知道NFS是为此而工作的,因为我们已经使用了它,但是为了简单起见,决定使用sshfs。 以下是我如何在XenServer 6.5上安装sshfs:
# fuse-fs and fuse-libs are in existing repos, so.. yum --enablerepo=base --disablerepo=citrix install fuse-fs # for some reason yum wanted to install i386 fuse-libs which fails # because of a dependency on i386 glibc.. nevermind all that, tell it # directly that we want x86_64 and it will work: yum --enablerepo=base --disablerepo=citrix install fuse-libs.x86_64 # fuse-sshfs is in the epel repo, which we need to add yum --disablerepo=citrix --enablerepo=extras install epel-release # now install fuse-sshfs yum --disablerepo=citrix --enablerepo=extras install fuse-sshfs # The above leaves epel-release enabled, which should be no problem but # nevertheless I disabled it since I don't need it anymore: # Use vim to edit /etc/yum.repos.d/epel.repo # Where it says `enabled=1` change to `enabled=0` vim /etc/yum.repos.d/epel.repo
现在好了,从另一台机器上的导出中恢复:
# make mount point mkdir backups # mount location of your backups onto mount point sshfs [email protected]:/path/to/backups backups # import as usual xe vm-import filename=backups/myexport.xva # unmount the remote filesystem, if you don't need it anymore umount backups # IT WORKS
哦,我应该加..我试着在我们的备份服务器上安装xenxerver工具..它也不工作。 当然,你可以执行命令,这一切看起来不错。 但是filename=/dev/stdin仍然不起作用,NOR DOES filename=/path/to/myexport.xva 。 它只是挂起或开始导入,然后以奇怪的方式失败。
所以这是import..但是出口呢? 使用远程安装的xenserver工具:
xe vm-export uuid = -vm -uuid filename = -s xenhost.my.domain -u root -pwf password_file
这会输出到标准输出。 但是,这些出口是否会一直成功地import还有点不清楚。 我经历了一些失败和一些成功。 所以决定不使用远程工具..但是通过ssh来代替:
ssh [email protected] "vm-export uuid=the-vm-uuid filename=" > myexport.xva
有用!
其结果是,使用我们的备份系统(Bareos),可以通过ssh直接备份到备份软件中,而不必先导出到临时文件。 但要进行还原,必须先将xva恢复到临时存储,然后使用sshfs挂载到xenhost,然后使用vm-import。 我很难过,我们不能stream两种方式..希望这将在xe固定一段时间。
希望这有助于一些人..它花了大量的试验和错误来testing所有的可能性:)
如果您想要将xva-backups导入XenServer,则只需将xe guest实用程序安装到备份服务器上即可。 它们包含在xentools iso(linux文件夹)中。 那么你可以使用“xe -s serverip -u root -pw password vm-import …”导入你的备份(甚至导出它们)。
顺便说一句:连接通过SSL保护。
这适用于我:
任务:将VM从旧的XS移动到新的XS从:XS 6.2 70446c到:XS 7.0 125380c
在XS 6.2主机上,我在控制台中使用这个命令:
xe vm-export uuid=<VM_UUID> filename= | ssh root@<XS7_IP_ADDRESS> 'xe vm-import filename=/dev/stdin sr-uuid=<XS7_LOCAL_STORAGE_UUID>'
所有的作品很棒!