-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvm_backup.sh
100 lines (77 loc) · 1.63 KB
/
vm_backup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
#
# Citrix XenServer 5.5 VM Backup Script
# This script provides online backup for Citrix Xenserver 5.5 virtual machines
#
# @version 3.01
# @created 24/11/2009
# @lastupdated 01/12/2009
#
# @author Andy Burton
# @url http://www.andy-burton.co.uk/blog/
# @email andy@andy-burton.co.uk
#
# Get current directory
dir=`dirname $0`
# Load functions and config
. $dir"/vm_backup.lib"
. $dir"/vm_backup.cfg"
touch $log_path
# Switch backup_vms to set the VM uuids we are backing up in vm_backup_list
case $backup_vms in
"all")
if [ $vm_log_enabled ]; then
log_message "Backup All VMs"
fi
set_all_vms
;;
"running")
if [ $vm_log_enabled ]; then
log_message "Backup running VMs"
fi
set_running_vms
;;
"argv")
if [ $vm_log_enabled ]; then
log_message "Backup argv VMs"
fi
set_argv_vms "$1"
;;
"list")
if [ $vm_log_enabled ]; then
log_message "Backup list VMs"
fi
;;
*)
if [ $vm_log_enabled ]; then
log_message "Backup no VMs"
fi
reset_backup_list
;;
esac
# Check backup_dir exists if not create it
if [ ! -d $backup_dir ];
then
`mkdir -p $backup_dir`
fi
# Check if backing to CIFS share
# if not run backups
# else mount share and if successful run backups
if [ -z $cifs_share ]; then
backup_vm_list
else
`mount -t cifs "$cifs_share" $backup_dir -o username=$cifs_username,password="$cifs_password"`
if [ $? -eq 0 ]; then
backup_vm_list
else
console_alert "backups mount error" "Unable to mount share, please check cfg"
exit
fi
fi
if [ -n "$keep_backups_for" ]; then
remove_old_backups $keep_backups_for
fi
# End
if [ $vm_log_enabled ]; then
log_disable
fi