How to encrypt drush backups with gnupg I am trying to set up a cron job that automatically backups up a Drupal site using drush but then encrypts that file. I would like to accomplish this using a single command but am not sure how to go about it.

Here is the command that does the backup and logs any messages (this works):

drush @mysite archive-dump --destination="/home/drush-backups/archive-dump/mysite.$(date +\%F_\%H-\%M-\%S).tar.gz" &amp;&gt;&gt; /var/log/mysites/$(hostname -s)/drush-cron.log


However when I try this: 

drush @mysite archive-dump --destination="/home/drush-backups/archive-dump/mysite.$(date +\%F_\%H-\%M-\%S).tar.gz" | gpg -e -r mypublickey &amp;&gt;&gt; /var/log/mysites/$(hostname -s)/drush-cron.log


It does not work. Any ideas where I am going wrong? What is the correct command?

Thanks.
You're piping the output of the Drush command to gpg, but it's expecting a file path.

By default the output will not be something that gpg can use, but archive-dump has a handy --pipe option which will print just the path to the output file; gpg can use that:

drush @mysite archive-dump --pipe --destination="/home/drush-backups/archive-dump/mysite.$(date +\%F_\%H-\%M-\%S).tar.gz" | gpg -e -r mypublickey &amp;&gt;&gt; /var/log/mysites/$(hostname -s)/drush-cron.log