У меня вот так сделано:
# ------- Upload backups -------
echo "$(date +%H:%M:%S) Uploading backup files to Selectel Storage..." | _log
cd "$BACKUP_DIR"
for _file in "${_for_upload[@]}"; do
_u_opts=""
if [ -n "$STORAGE_EXPIRE" ]; then
_u_opts="-d ${STORAGE_EXPIRE}d"
fi
FILENAME=$(basename "$_file")
nice -n 19 ionice -c 3 swift upload -A https://auth.selcdn.ru -U "$SS_USER" -K "$SS_PWD" -S 1073741824 "$SS_CONTAINER" "$FILENAME" | _log
if [ $? -ne 0 ]; then
_error="1"
else
if [ x"$DELETE_BACKUPS_AFTER_UPLOAD" = x"yes" ]; then
rm -f "$_file"
echo "$(date +%H:%M:%S) File $_file was removed" | _log
fi
fi
done