-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbamboo.diy-backup.rsync.sh
45 lines (37 loc) · 1.22 KB
/
bamboo.diy-backup.rsync.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
#!/bin/bash
check_command "rsync"
function bamboo_perform_rsync {
for exclude in ${BAMBOO_BACKUP_EXCLUDE:-}; do
RSYNC_EXCLUDE="${RSYNC_EXCLUDE:-} --exclude=${exclude}"
done
RSYNC_QUIET=-q
if [ "${BAMBOO_VERBOSE_BACKUP}" == "TRUE" ]; then
RSYNC_QUIET=
fi
mkdir -p ${BAMBOO_BACKUP_HOME}
rsync -avh ${RSYNC_QUIET} --numeric-ids --sparse \
--delete --delete-excluded \
--exclude=temp --exclude=exports \
--exclude=build-dir --exclude=build_logs --exclude=artifacts \
${RSYNC_EXCLUDE:-} \
${BAMBOO_HOME} ${BAMBOO_BACKUP_HOME}
if [ $? != 0 ]; then
bail "Unable to rsync from ${BAMBOO_HOME} to ${BAMBOO_BACKUP_HOME}"
fi
}
function bamboo_prepare_home {
bamboo_perform_rsync
info "Prepared backup of ${BAMBOO_HOME} to ${BAMBOO_BACKUP_HOME}"
}
function bamboo_backup_home {
bamboo_perform_rsync
info "Performed backup of ${BAMBOO_HOME} to ${BAMBOO_BACKUP_HOME}"
}
function bamboo_restore_home {
RSYNC_QUIET=-q
if [ "${BAMBOO_VERBOSE_BACKUP}" == "TRUE" ]; then
RSYNC_QUIET=
fi
rsync -av ${RSYNC_QUIET} ${BAMBOO_RESTORE_HOME}/ ${BAMBOO_HOME}/
info "Performed restore of ${BAMBOO_RESTORE_HOME} to ${BAMBOO_HOME}"
}