2017-05-10 5 views
1
#!/bin/bash 

datetime="`date +%Y%m%d`"; 

export AWS_ACCESS_KEY_ID="MYKEY" 
export AWS_SECRET_ACCESS_KEY="MYSECRET" 
export BACKUP_DEST_FILES="s3://s3.eu-central-1.amazonaws.com/mybucket" 

cd /var/www/ 
dirs=($(find * -maxdepth 0 -type d)) 
for dir in "${dirs[@]}"; do 
cd $dir 
subdirs=($(find * -maxdepth 0 -type d)) 
for subdir in "${subdirs[@]}"; do 
duplicity full --exclude "**logs/**" --exclude "**backups/**" --no-encryption $subdir $BACKUP_DEST_FILES/$dir/$datetime/$subdir 
done 
cd ../ 
done 

이 코드를 배제하지 않는다.이중성 --exclude 옵션은 백업의 "로그"와 "백업"DIRS 제외 /의/var/www가에서 모든 directtory과 서브 디렉토리로되어 언급 된 디렉토리

는 아래의 rsync를 명령과 함께 완벽하게 작동하는 동안 :

rsync -ar --exclude='backup' --exclude='log' --exclude='logs' --exclude='backups' $subdir backups/$datetime/ 

아래의 이중성 명령으로 작동하지 않습니다 가깝지만. 단지 모든 것을 백업하고 제외하지 않습니다.

duplicity full --exclude "**logs/**" --exclude "**backups/**" --no-encryption $subdir $BACKUP_DEST_FILES/$dir/$datetime/$subdir 

여기에 무엇이 누락 되었습니까?

답변

0

확인 subdirs=($(find * -maxdepth 0 ! -path /path/to/exclude -type d)) 지점의 불필요한 디렉토리를 제외했습니다. 중복 프로세스 전에 단계에서 제외되기 때문에 디렉터리가 중복됩니다.

감사합니다.