title: docker-compose: dumping postgres database in a cron job not working
body: <p>I wrote a script to dump a database from host machine:</p>
  
  <pre><code>#!/bin/bash
  cd /mydir/
  echo "Dumping database .."
  /usr/local/bin/docker-compose exec pg-service pg_dump -U pg -d "MYDB" -f /var/lib/postgresql/dbback_ 2&gt;&amp;1 | tee -a /backup/backup.log
  date=`date +%F_%Hh_%Mm`
  mv pg_data/dbback_ /backup/dbback_$date.sql
  cd /backup/
  echo "compressing backup .."
  tar -czvf dbback_$date.tar.gz  dbback_$date.sql
  rm dbback_$date.sql
  </code></pre>
  
  <p>/var/lib/postgresql/ is exposed in MYDIR/pg_data/  </p>
  
  <p>when running the script manually it does the task perfectly, but when I create a cron job for the script it create an empty tar.gz file (the docker-compose command fail)</p>
  
  <p><code>50     22      * * *   root    /backup/backup.sh</code></p>
  
  <p>any suggestions! </p>