This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
virtualization:xenserver:xenserver_backup [2014/08/21 11:14] gcooper |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== XenServer Backup ====== | ||
- | **Main Reference Article**: http:// | ||
- | |||
- | **Backup**: http:// | ||
- | |||
- | **Restore**: | ||
- | |||
- | :!: You can back up all the VM's, XenServer hosts, and metadata from a single XenServer host in a XenServer pool. | ||
- | |||
- | :!: Consider this a disaster recovery backup. | ||
- | |||
- | :!: Here we use an NFS mount for backup storage. | ||
- | |||
- | :!: XVA backups are compressed on the fly. | ||
- | |||
- | :!: This is a no-downtime script set; it backs up the VM " | ||
- | |||
- | ===== The Basic Idea ===== | ||
- | |||
- | - The local Dom0 on the XenServer runs cron | ||
- | - The '' | ||
- | - The '' | ||
- | - The '' | ||
- | - The '' | ||
- | - enters the correct directory | ||
- | - sources the '' | ||
- | - determines what is to be backed up from the '' | ||
- | - calls for a backup (via live snapshot/ | ||
- | - outputs to a log | ||
- | |||
- | ===== Prepare the NFS Mount and Test a Manual Backup ===== | ||
- | |||
- | :!: Choose one of your XenServers to be the backup server. | ||
- | |||
- | :!: Here we assume you have a XenServer pool named '' | ||
- | |||
- | Mount the NFS share: | ||
- | |||
- | < | ||
- | mkdir /mnt/backup | ||
- | |||
- | vi /etc/fstab | ||
- | </ | ||
- | |||
- | Append: | ||
- | |||
- | < | ||
- | # | ||
- | # Mount the backup share | ||
- | 10.10.1.9:/ | ||
- | </ | ||
- | |||
- | Mount the share, check it's mounted and test a manual backup: | ||
- | |||
- | < | ||
- | mount -a | ||
- | mount | ||
- | xe vm-export vm="< | ||
- | </ | ||
- | |||
- | ===== Get Mail Working ===== | ||
- | |||
- | see also **[[networking: | ||
- | |||
- | Modify '' | ||
- | |||
- | < | ||
- | vi / | ||
- | |||
- | root=adminuser@yourdomain.com | ||
- | mailhub=mail.yourdomain.com: | ||
- | RewriteDomain=yourdomain.com | ||
- | FromLineOverride=YES | ||
- | UseTLS=YES | ||
- | AuthUser=smtpuser | ||
- | AuthPass=smtppass | ||
- | </ | ||
- | |||
- | ===== Install the Scripts on the Backup Server ===== | ||
- | |||
- | < | ||
- | mkdir -p /opt/backup && cd /opt/backup | ||
- | wget https:// | ||
- | unzip XenServerBackup.zip | ||
- | rm -rf __MACOSX/ | ||
- | chmod +x *.sh | ||
- | chmod +x dbtool | ||
- | cp -a ./dbtool / | ||
- | </ | ||
- | |||
- | ===== Configure the Scripts on the Backup Server ===== | ||
- | |||
- | :!: You might want to use IP addresses to control which network interfaces are used for the backups. | ||
- | |||
- | Change the names and filenames to the names you have for your XenServers according to the article: | ||
- | |||
- | < | ||
- | vi audit.sh | ||
- | |||
- | vi cleanup.sh | ||
- | |||
- | vi meta-backup.sh | ||
- | |||
- | vi mailheader.txt | ||
- | |||
- | vi vm_backup.cfg | ||
- | </ | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ====== Old Page Contents Below ====== | ||
- | |||
- | Old but good list of XenServer backup options: | ||
- | http:// | ||
- | |||
- | ===== Local Backup Disk or CIFS Share ===== | ||
- | |||
- | http:// | ||
- | |||
- | * The '' | ||
- | * '' | ||
- | |||
- | ==== Install on the XenServer Host ==== | ||
- | |||
- | < | ||
- | mkdir / | ||
- | mkdir /VM_Backup | ||
- | |||
- | # Use a command like this if you want to send backups to a CIFS share | ||
- | #mount -t cifs "// | ||
- | |||
- | cd /VM_Backup | ||
- | wget http:// | ||
- | tar -xzf xenserver_backup.tar.gz | ||
- | chmod 777 v* | ||
- | </ | ||
- | |||
- | === startvmbackup.sh === | ||
- | |||
- | < | ||
- | vi / | ||
- | </ | ||
- | |||
- | < | ||
- | #!/bin/bash | ||
- | set -x | ||
- | |||
- | # Dismount then remount backup share to be sure it's mounted | ||
- | umount -f /VM_Backup | ||
- | |||
- | #mount -t cifs "// | ||
- | |||
- | / | ||
- | |||
- | / | ||
- | |||
- | / | ||
- | |||
- | sleep 120 | ||
- | |||
- | / | ||
- | </ | ||
- | |||
- | < | ||
- | chmod 777 / | ||
- | </ | ||
- | |||
- | === CLEARDOWN.sh === | ||
- | |||
- | < | ||
- | vi / | ||
- | </ | ||
- | |||
- | < | ||
- | #!/bin/bash | ||
- | |||
- | coalesce-leaf -u $uuid | ||
- | coalesce-leaf -u $uuid | ||
- | coalesce-leaf -u $uuid | ||
- | |||
- | xe host-call-plugin host-uuid=$VM_XENUUID plugin=coalesce-leaf fn=leaf-coalesce args: | ||
- | xe host-call-plugin host-uuid=$VM_XENUUID plugin=coalesce-leaf fn=leaf-coalesce args: | ||
- | xe host-call-plugin host-uuid=$VM_XENUUID plugin=coalesce-leaf fn=leaf-coalesce args: | ||
- | </ | ||
- | |||
- | < | ||
- | chmod 777 / | ||
- | </ | ||
- | |||
- | ==== Configure The Scripts ==== | ||
- | |||
- | Edit the '' | ||
- | |||
- | < | ||
- | vi / | ||
- | </ | ||
- | |||
- | Insert these two lines in the '' | ||
- | |||
- | < | ||
- | # | ||
- | # Settings | ||
- | # | ||
- | |||
- | VM_XENHOST=$(xe vm-list | grep ' | ||
- | |||
- | VM_XENUUID=$(xe vm-list params uuid=$(xe vm-list | grep -B1 $VM_XENHOST | grep uuid | awk -F ': ' '{ print $2 }') | grep resident-on | awk -F ': ' '{ print $2 }') | ||
- | </ | ||
- | |||
- | Set log path: | ||
- | |||
- | < | ||
- | log_path="/ | ||
- | </ | ||
- | |||
- | Set the backup destination: | ||
- | |||
- | < | ||
- | backup_dir="/ | ||
- | </ | ||
- | |||
- | Ensure only running VMs are backed up: | ||
- | |||
- | < | ||
- | backup_vms=" | ||
- | </ | ||
- | |||
- | Edit the '' | ||
- | |||
- | < | ||
- | vi / | ||
- | </ | ||
- | |||
- | Search for this line and add below it in the same if/then stanza: | ||
- | |||
- | < | ||
- | log_message "VM $uuid backup failed" | ||
- | </ | ||
- | |||
- | < | ||
- | xe host-call-plugin host-uuid=$VM_XENUUID plugin=coalesce-leaf fn=leaf-coalesce args: | ||
- | sleep 10 | ||
- | xe host-call-plugin host-uuid=$VM_XENUUID plugin=coalesce-leaf fn=leaf-coalesce args: | ||
- | sleep 10 | ||
- | xe host-call-plugin host-uuid=$VM_XENUUID plugin=coalesce-leaf fn=leaf-coalesce args: | ||
- | </ | ||
- | |||
- | Search for this line and add below it in the same if/then stanza: | ||
- | |||
- | < | ||
- | log_message "VM $uuid backup succeeded" | ||
- | </ | ||
- | |||
- | < | ||
- | xe host-call-plugin host-uuid=$VM_XENUUID plugin=coalesce-leaf fn=leaf-coalesce args: | ||
- | sleep 10 | ||
- | xe host-call-plugin host-uuid=$VM_XENUUID plugin=coalesce-leaf fn=leaf-coalesce args: | ||
- | sleep 10 | ||
- | xe host-call-plugin host-uuid=$VM_XENUUID plugin=coalesce-leaf fn=leaf-coalesce args: | ||
- | </ |