-
Notifications
You must be signed in to change notification settings - Fork 28
/
esnapshot
executable file
·77 lines (65 loc) · 1.37 KB
/
esnapshot
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
#!/usr/bin/env bash
#
# esnapshot - Erigones snapshot tool
#
set -u
set -o pipefail
ERIGONES_HOME=${ERIGONES_HOME:-"/opt/erigones"}
#SELF="${ERIGONES_HOME}/bin/esnapshot"
PROG="$(basename "$0")"
# shellcheck disable=SC1090
. "${ERIGONES_HOME}"/bin/eslib/functions.sh
declare -ri OK=0
declare -ri ERR_INPUT=1
###############################################################
# helper functions
###############################################################
function usage() {
cat <<EOF
${PROG} create <snapshot> [metadata] [fs_freeze_qa_agent_socket]
${PROG} destroy <snapshot>
${PROG} rollback <snapshot>
EOF
}
###############################################################
# ZFS snapshot
###############################################################
main() {
local action="${1:-}"
shift
case "${action}" in
list)
if [[ "${1}" == *"/"* ]]; then
_zfs_list_snapshots "${1}" "name,creation,written,es:snapname"
else
_zfs_list_snapshots_zpool "${1}" "name,creation,written,es:snapname"
fi
exit $?
;;
create)
_zfs_snap_vm "${1}" "${2:-}" "${3:-}"
exit $?
;;
destroy)
_zfs_destroy_snap_vm "${1}"
exit $?
;;
rollback)
_zfs_rollback "${1}"
exit $?
;;
restore)
echo "Use esbackup snap-restore" >&2
exit ${ERR_INPUT}
;;
-h|--help)
usage
exit ${OK}
;;
*)
usage
exit ${ERR_INPUT}
;;
esac
}
main "$@"