blob: e51aaf142687277a3f9e65e0f8ec0dffff8ac7d7 (
plain)
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
|
# use first not-remote backup directory as bup's local repository
# defaults to ".bup"
function bup_local() {
for BACKUP_DIR in ${BACKUP_DIRS[*]}
do
if [[ $BACKUP_DIR != *:* ]]; then
echo "$BACKUP_DIR"
return
fi
done
echo ".bup"
}
function bup_init() {
bup -d "$(bup_local)" index "$WORLD_NAME"
status=$?
if [ $status -ne 0 ]; then
echo "bup: no local repo found, creating..."
bup -d "$(bup_local)" init -r "$(bup_local)"
echo "bup: created local repo at $(bup_local)"
fi
}
function bup_create_backup() {
echo "bup: backup started"
bup -d "$(bup_local)" index "$WORLD_NAME"
# 0 if saved to at least one non-local repository
RETCODE=1
for BACKUP_DIR in ${BACKUP_DIRS[*]}
do
echo "bup: backing up to \"$BACKUP_DIR\""
# try to save to remote
bup -d "$(bup_local)" save -r "$BACKUP_DIR" -n "$BACKUP_NAME" "$WORLD_NAME"
# if failed - reinit remote and try again
if [ ! $? -eq 0 ]; then
echo "bup: failed backing up to \"$BACKUP_DIR\", reinitializing remote..."
bup -d "$(bup_local)" init -r "$BACKUP_DIR"
if [ ! $? -eq 0 ]; then
echo "bup: created remote at \"$BACKUP_DIR\""
bup -d "$(bup_local)" save -r "$BACKUP_DIR" -n "$BACKUP_NAME" "$WORLD_NAME"
else
echo "bup: failed to make remote at \"$BACKUP_DIR\", moving on"
fi
else
if [ "$BACKUP_DIR" = "$(bup_local)" ]; then
RETCODE=0
fi
fi
done
echo "bup: backup finished"
return $RETCODE
}
function bup_ls() {
for BACKUP_DIR in ${BACKUP_DIRS[*]}
do
echo "bup: backups in \"$BACKUP_DIR\":"
bup -d "$(bup_local)" ls -r "$BACKUP_DIR" --human-readable -l "$BACKUP_NAME"
done
}
|