File: oci-swift-backup-ring

package info (click to toggle)
openstack-cluster-installer 43.0.22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,544 kB
  • sloc: php: 19,169; sh: 18,137; ruby: 75; makefile: 31; xml: 8
file content (57 lines) | stat: -rwxr-xr-x 877 bytes parent folder | download | duplicates (4)
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
#!/bin/sh

set -e
# set -x

TODAY=$(date +%Y.%m.%d_%H%M)

usage()
{
	cat <<EOF
Description:
	Backup Swift rings

Usage:
	$0 <cluster-name>

Options:
	-h: show this help menu
EOF

	exit 1
}

while getopts "h" o; do
	case "${o}" in
		h)
			usage
			;;
		?)
			echo "Invalid option" && exit 1
			;;
	esac
done
shift $((OPTIND-1))

if [ -z "${1}" ]; then
	usage
fi

LOCAL_RING_PATH="/var/lib/oci/clusters/${1}/swift-ring"
BACKUP_PATH="/var/backups/oci/clusters/${1}/swift/rings"

# make sure we have ring
if ! [ -d ${LOCAL_RING_PATH} ]; then
	echo "ERROR: Swift ring directory does not exist"
	exit 1
fi

# prepare backup destination folder
if ! [ -d ${BACKUP_PATH} ]; then
	mkdir -p ${BACKUP_PATH}
fi

# backup all available ring types
for ring in $(ls ${LOCAL_RING_PATH}/ | grep -E '^(account|container|object).*?\.builder'); do
	cp ${ring}* ${BACKUP_PATH}/${TODAY}.${ring}
done