我正在将一些带有双重性的路径备份到另一个分区,现在我想要排除子目录。但我得到了这个错误:
[*] 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
答案 0 :(得分:-1)
如何在命令行中转义星号,以免它们被扩展?