-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.SNAPSHOT
38 lines (29 loc) · 1.04 KB
/
Makefile.SNAPSHOT
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
SHELL := $(shell which bash)
SELF := $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))
VIRSH := sudo virsh
export
.PHONY: all
all:
@true
list-%:
@$(VIRSH) list --all | awk '/$*/{print$$2}' | sort | while read DOMAIN; do \
$(VIRSH) snapshot-list --domain "$$DOMAIN"; \
done
backup-%:
@$(VIRSH) list --all | awk '/$*/{print$$2}' | sort | while read DOMAIN; do \
$(VIRSH) snapshot-create --domain "$$DOMAIN" --atomic; \
done
restore-%:
@$(VIRSH) list --all | awk '/$*/{print$$2}' | sort | while read DOMAIN; do \
$(VIRSH) snapshot-revert --domain "$$DOMAIN" --current --running; \
done
delete-%:
@$(VIRSH) list --all | awk '/$*/{print$$2}' | sort | while read DOMAIN; do \
$(VIRSH) snapshot-delete --domain "$$DOMAIN" --current; \
done
clean-%:
@$(VIRSH) list --all | awk '/$*/{print$$2}' | sort | while read DOMAIN; do \
$(VIRSH) snapshot-list --domain "$$DOMAIN" | grep -oP '^\s*\K\b\d+\b' | sort -r | while read NAME; do \
$(VIRSH) snapshot-delete --domain "$$DOMAIN" "$$NAME"; \
done; \
done