Using a script that uses Duplicity + S3 excluding large files
- by Jason
I'm trying to write an backup script that will exclude files over a certain size.
If i run the script duplicity gives an error. However if I copy and paste the same command generated by the script everything works...
Here is the script
#!/bin/bash
# Export some ENV variables so you don't have to type anything
export AWS_ACCESS_KEY_ID="accesskey"
export AWS_SECRET_ACCESS_KEY="secretaccesskey"
export PASSPHRASE="password"
SOURCE=/home/
DEST=s3+http://s3bucket
GPG_KEY="gpgkey"
# exclude files over 100MB
exclude ()
{
find /home/jason -size +100M \
| while read FILE; do
echo -n " --exclude "
echo -n \'**${FILE##/*/}\' | sed 's/\ /\\ /g' #Replace whitespace with "\ "
done
}
echo "Using Command"
echo "duplicity --encrypt-key=$GPG_KEY --sign-key=$GPG_KEY `exclude` $SOURCE $DEST"
duplicity --encrypt-key=$GPG_KEY --sign-key=$GPG_KEY `exclude` $SOURCE $DEST
# Reset the ENV variables.
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export PASSPHRASE=
When the script is run I get the error;
Command line error: Expected 2 args, got 6
Where am i going wrong??