Percona-Lab / mongodb_consistent_backup

A tool for performing consistent backups of MongoDB Clusters or Replica Sets
https://www.percona.com
Apache License 2.0
276 stars 81 forks source link

Add --archive.tar.binary parameter #286

Closed dschneller closed 5 years ago

dschneller commented 5 years ago

Allows specifying a custom location of the tar command to use. Also, the flags sent to ta" are sent individually (tar -cf becomes tar -c -f).

This allows easily customizing how the archiving is performed without having to add lots of new options. For example, you could encrypt backup data via a simple shell script and specify via --archive.tar.binary:

#!/bin/bash
gpg_pubkey_id=XXXXXXX
new_args=""

while [ "${#}" -gt 0 ]; do
  case "$1" in
    -f)
      shift;
      original_output_file="${1}"
      shift
      new_args="${new_args} --to-stdout"
      ;;
    *)
      new_args="${new_args} ${1}"
      shift
      ;;
  esac
done

tar ${new_args} | gpg --always-trust --encrypt --recipient ${gpg_pubkey_id} -z 0 --output ${original_output_file}

This has several advantages:

timvaillancourt commented 5 years ago

LGTM, thanks @dschneller