Академический Документы
Профессиональный Документы
Культура Документы
Jerome Reid
Agenda
Introduction Backup and recovery tools XenServer CLI basics
Sample Scripts
Agenda
Introduction Introduction Backup and and recovery recovery tools tools Backup XenServer CLI basics
Sample Scripts
Why backup?
Failure can result in wider impact as a result of workload consolidation A properly designed backup plan will minimize downtime Comprehensive backup up plan needed for Disaster recovery
Pool db
Master maintains pool db The UUIDs of all objects are tracked in the pool db Slaves take pool db backup Master
Slaves
Passive snapshot
Vm metadata
Contained within the pool db Contains VM information: name, description, uuid VM configuration: amount of virtual memory, virtual CPUs
Pool db backup
xe pool-dump-database , xe pool-restore-database
Vm metadata
xe vm-export --metadata, xe vm-import --metadata
backup-metadata
When a metadata backup is first taken, a special backup VDI is created on a SR. This VDI stores the following backups:
A full pool-database backup. Individual VM metadata backups, partitioned by the SRs in which the VM has disks. SR-level metadata which can be used to recreate the SR description when the storage is reattached.
The metadata backup and restore works at the command-line script level Also supported in the menu-driven text console.
backup-metadata
Metadata backup/restore can also be performed and scehduled via the XS console:
backup-metadata
Metadata backup/restore can be run and scripted via the CLI: xebackup-metadata,xe-restore-metadata
xe-backup-metadata provides an interface to create the backup VDIs xe-backup-metadata -h xe-backup-metadata -c -u <sr uuid> xe-backup-metadata -d -u <sr uuid>
3 4
Automated backup of VM metadata to SR Replication of SR includes Virtual Disks and VM metadata Attach replicated SR Restore of VM metadata will recreate VMs
Shared Storage
Shared Storage
Production Site
DR Site
pool-dump-database
Downloads a copy of the entire pool db and dumps it into a file on the client Only available via the CLI xe pool-dump-database
file-name=
xe pool-restore-database
File-name=
Can be scripted and saved to a network share. See Citrix article CTX116632
pool-dump-database
pool-restore-database xe-toolstack-restart Single Host
Pool db
Pool db backup
pool-dump-database
Master pool-restore-database xe-toolstack-restart
Pool db
Pool db backup
Slaves
vm-export metadata
xe vm-export
filename=<filename> vm=<vm name-label> metadata=true
xe vm-import
filename=<filename> metadata=true
Can be scripted
Can be saved to network share. Please see Citrix article CTX117258
host-backup
xe host-backup
file-name= host= <host_selector_value> Archives the active partition to a specified file
xe host-restore
file-name= host= <host_selector_value>. extracts the archive created by xe host-backup over the host's currently inactive disk partition
host-backup
The backup partition can then be made active by booting off the installation CD and choosing the Restore option.
Agenda
Introduction Introduction Backup and recovery tools XenServer CLI basics
Sample Scripts
CLI Basics
The XenServer CLI provides additional functionality over the XenCenter Interface New features are often developed in the CLI before being available in the GUI CLI enables scripts for automating system administration tasks
Object model
The object model and classes are key to understanding the CLI
Host and VM interact with the storage,virtual disk and network objects using connecttor objects
VM Config VM Network Config Disk Config
VIF
Network
VBD
VDI SR PBD
Object model
VM
VIF
Network
CLI Basics
Basic Syntax
xe <command-name> <argument=value> <argument=value>
Object commands
xe <class>-<TAB> Where class can be: bond,console,host,network, patch, pbd, pif, pool,sr, task, template, vbd, vdi, vif, vlan, vm
CLI Basics
Filtering
vm-list HVM-boot-policy="BIOS order" power-state=halted
Parameterization
xe vm-list params=name-label
Minimal Output
xe vm-list HVM-boot-policy="BIOS order" power-state=halted params=name-label --minimal
Agenda
Introduction Introduction Backup and recovery tools XenServer CLI basics
Sample Scripts
List all loaded CD and set to empty Pool-dump database script
#we loop through the cdlist and for each instance we get the name label using the uuid, print it out # and we eject the the CDusing the vm uuid for vm in $cdlist do echo $vm vmname=`xe vm-list uuid=$vm params=name-label --minimal` echo "eject CD from $vmname" xe vm-cd-eject uuid="$vm" done
# THIS SECTION VERIFIES IF THE LocalDirectoryName HAS NOT BEEN MOUNTED. IF NOT IT WILL MOUNT THE SHARE. MountName="" MountName=`mount -l | grep LocalDirectoryName` if [ "$MountName" = "" ]; then mount -t nfs <NFSSERVERNAME>:/<NFSShareNAME> /<LocalDirectoryName> echo "MOUNT POINT SUCCESSFULL /n" Fi # THIS SECTION WILL VERIIFY IF THE MOUNT POINT EXISTS BEFORE PERFORMING THE BACKUP OPERATION. MountTest="" MountTest=`mount -l | grep LocalDirectoryName ` if [ "$MountTest" != "" ]; then xe pool-dump-database file-name=/ LocalDirectoryName/`date '+XenPoolBackup_%m-%d-%y_ %H-%M-%S'` fi
#in this section we loop through VIFLIST # we use param clear to clear the other cconfig parameter and we set the ethtool-tx=off for all the listed vifs for VIF in $VIFLIST do echo $VIF xe vif-param-clear uuid=$VIF param-name=other-config xe vif-param-set uuid=$VIF other-config:ethtool-tx="off" done
#!/bin/bash i=0 vlantag=1 devname=eth0 while [ $i -lt 3 ] do netname=vlan$vlantag netuuid=`xe network-create name-label=$netname` echo Network UUID $netuuid pifuuid=`xe pif-list device=$devname VLAN=-1 --minimal` echo PIF UUID $pifuuid vlanuuid=`xe vlan-create network-uuid=$netuuid pif-uuid=$pifuuid vlan=$vlantag` echo Vlan UUID $vlanuuid i=$[$i+1] vlantag=$[$vlantag +1] netuuid=' ' pifuuid=' ' vlanuuid=' ' done
VLAN creation