#!/bin/bash

if [[ "$1" == 'perform' ]]
then
  echo 'NON-DRY RUN'
  DRY=''
else
  echo 'DRY RUN'
  DRY='-n'
fi

% for path, options in paths.items():
# ${path}
gsutil ${'\\'}
  -m ${'\\'}
  -o 'GSUtil:parallel_process_count=${processes}' ${'\\'}
  -o 'GSUtil:parallel_thread_count=${threads}' ${'\\'}
  rsync ${'\\'}
    $DRY ${'\\'}
    -r ${'\\'}
    -d ${'\\'}
    -e ${'\\'}
% if options.get('exclude'):
    -x '${'|'.join(options['exclude'])}' ${'\\'}
% endif
    '${options['encrypted_path']}' ${'\\'}
    'gs://${bucket}/${node_id}${path}' ${'\\'}
    2>&1 | logger -st gsutil
% endfor
