forked from henrik-farre/duplicity_backup_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup-clean.sh
More file actions
executable file
·38 lines (31 loc) · 964 Bytes
/
Copy pathbackup-clean.sh
File metadata and controls
executable file
·38 lines (31 loc) · 964 Bytes
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
#!/bin/bash
set -o nounset
set -o errexit
set -o errtrace
set -o pipefail
# To debug, enable xtrace, and disable redirection of stderr to file (the exec 2>${ERROR_LOG} line)
# set -o xtrace
if [[ ${EUID} -ne 0 ]]; then
echo "Needs root access"
exit 1
fi
MSG=""
ERROR=0
ERROR_MSG=""
ERROR_LOG="/root/.duplicity/logs/duplicity-errors.${$}.log"
TYPE="Cleanup"
# Redirect all stderr to error logfile
exec 2>${ERROR_LOG}
# For PyDrive credentials
cd /root/.duplicity/
source /root/.duplicity/config
source /root/.duplicity/scripts/includes.sh
setup
for SRC_DIR in ${BACKDIRS}; do
CLEAN_SRC_DIR="${SRC_DIR//\//-}"
DEST_DIR="${REMOTE_DIR}/${CLEAN_SRC_DIR}"
LOG_FILE="/root/.duplicity/logs/duplicity-cleanup-${CLEAN_SRC_DIR}.log"
echo "========================= Cleaning ${HOSTNAME}/${SRC_DIR} $(date) =========================" >> "${LOG_FILE}"
duplicity cleanup --force ${COMMON_OPTS} ${DEST_DIR} >> "${LOG_FILE}"
MSG="${MSG}\n- ${SRC_DIR}"
done