Xen backup to external HDD or SMB share
- Create SNAPSHOT
- Convert to TEMPLATE
- Export to .xva file (to external USB HDD or SMB share)
- Delete SNAPSHOT
- Delete backups older than 10 days
- SSH to host
- Type "xe vm-list" to show UUIDs of virtual machines for backup
- Put UUIDs to /home/xen-backup/xen-uuids.txt
- Type "Enter" after last UUID
Example xen-uuids.txt
2a120389-80fe-2ade-380e-65733c4a563d
c096ed53-4f29-722c-2790-1b7a2a71ff4d
- Plug external USB HDD
- "fdisk -l" to show all disks.
- Find your disk (e.g. "sdc")
- Mount disk - "mount /dev/sdc1 /mnt/hdd"
- Change values in xen-backup-hdd.sh
UUIDFILE=./xen-uuids.txt BACKUPPATH=/mnt/hdd
- Run ".\xen-backup-hdd.sh"
- Unmout disk - "umount /mnt/hdd"
- Change values in xen-backup-smb.sh
UUIDFILE=./xen-uuids.txt SERVER=//192.168.1.99 UNC=share/xen_backup MOUNTPOINT=/mnt/mount_point mount.cifs ${SERVER}/${UNC} ${MOUNTPOINT} -o username=USERNAME,password=SECRETPASSWORD
- Run ".\xen-backup-smb.sh"
Backup to USB HDD at 23:00 everyday, and to SMB share at 01:00.
/var/spool/cron/root
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
0 23 * * * cd /home/xen-backup && /bin/bash xen-backup-hdd.sh
0 1 * * * cd /home/xen-backup && /bin/bash xen-backup-smb.sh
xe vm-import filename=/mnt/hdd/<name_of_VM.xva> force=true preserve=true
Set "preserve" to "false" if you need to duplicate VM.
Be careful with symbols in the name of .xva file.