我正在将一些具有重复性的路径备份到另一个分区,现在我想排除一个子目录。但是我得到了这个错误:
[*] duplicity --full-if-older-than 1M --no-encryption -v4 --volsize 100 --exclude "/home/usera/gemeinfrei/epubs/**" "/home/usera" "file:///var/backups/backup/home/usera"
Import of duplicity.backends.giobackend Failed: No module named gio
Fatal Error: The file specification
"/home/usera/gemeinfrei/epubs/**
cannot match any files in the base directory
/home/usera
Useful file specifications begin with the base directory or some
pattern (such as '**') which matches the base directory.
这很奇怪,因为文件规范确实以基目录开头。我还想备份其他用户目录。我为他们每个人运行一个重复过程。或者我应该只使用一个使用多个 --include 选项并作为基目录/的重复性进程?
这是实际的备份脚本:
#!/bin/bash
#0 Error, 2 Warning, 4 Notice (default), 8 Info, 9 Debug (noisiest)
VERBOSE=4
BACKUP_PATH=/var/backups/backup
DUP="duplicity --full-if-older-than 1M --no-encryption -v$VERBOSE --volsize 100"
DUP_DEL="duplicity remove-older-than 2M --force -v$VERBOSE"
DUP_EXCLUDE="--exclude "/home/usera/gemeinfrei/epubs/**""
DIRECTORIES="/etc /home/usera /home/userb /home/userc /home/userd /home/usere /home/userf /home/userg /home/userh /var/vmail"
function doBackup() {
for DIRECTORY in $DIRECTORIES; do
if [ -d "$DIRECTORY" ]; then
mkdir -p "${BACKUP_PATH}${DIRECTORY}"
if [ -d "${BACKUP_PATH}${DIRECTORY}" ]; then
echo "[*] $DUP $DUP_EXCLUDE "$DIRECTORY" "file://${BACKUP_PATH}${DIRECTORY}""
$DUP $DUP_EXCLUDE "$DIRECTORY" "file://${BACKUP_PATH}${DIRECTORY}"
else
echo "[!] Backuppfad konnte nicht angelegt werden: ${BACKUP_PATH}${DIRECTORY}"
fi
fi
done
}
function doClean() {
for DIRECTORY in $DIRECTORIES; do
echo "[*] $DUP_DEL "file://${BACKUP_PATH}${DIRECTORY}""
$DUP_DEL "file://${BACKUP_PATH}${DIRECTORY}"
done
}
echo -n "[*] "
date
df -h
while [ -n "$1" ]; do
case $1 in
"backup")
doBackup
;;
"clean")
doClean
;;
*)
echo "[*] Unbekannter Parameter: '$1'" >&2
;;
esac
shift
done
df -h
echo -n "[*] "
date
exit 0
如何转义命令行上的星号,以免它们被扩展?