2

This is the command I use to tar my backup files, write to stdout and then upload everything to Amazon S3 with an email notification.

tar -czvf - --exclude-caches /var/www | s3cmd --reduced-redundancy --multipart-chunk-size-mb=30 put - s3://MY-BUCKET/`date +\%G-\%m-\%d`.tar.gz | mail -s "Weekly Backup"

Everything works fine except the mail command. I think I have some syntax error.. as I get:

mail: Cannot parse address `File '-' stored as 's3://MY-BUCKET/2014-08-31.tar.gz' (0 bytes in 2190.3 seconds' (while expanding `File '-' stored as 's3://MY-BUCKET/2014-08-31.tar.gz' (0 bytes in 2190.3 seconds'): Malformed email address
mail: Cannot parse address `-1.00 B/s) [1 of 1]' (while expanding `-1.00 B/s) [1 of 1]'): Malformed email address
root:~# tar -czvf - --exclude-caches /var/www | s3cmd --reduced-redundancy --multipart-chunk-size-mb=30 put - s3://MY-BUCKET/`date +\%G-\%m-\%d`.tar.gz
 | mail -s "Weekly Backup"
MultiformeIngegno
  • 1,627
  • 9
  • 24
  • 31

1 Answers1

3

To send a mail via mail (and using stdin as body), use the following syntax:

echo "test body" | mail -s 'test subject' reciever@example.com

For more information take a look at the Manpage man mail.

sebix
  • 4,175
  • 2
  • 25
  • 45