duplicity --exclude option doesn't exclude the mentioned dir

621 views Asked by At
#!/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

This code supposed to backup every directtory and subdirectory under /var/www/ except for "logs" and "backups" dirs.

While it works perfectly with the rsync command below:

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

..it doesn't work with duplicity command below. It just backs up everything and doesn't exclude.

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

What am I missing here?

1

There are 1 answers

0
Mher Harutyunyan On

OK I excluded the unnecessary directories in subdirs=($(find * -maxdepth 0 ! -path /path/to/exclude -type d)) point. So the directories are being excluded during the step before duplicity process.

Thank you.