I'm trying to create a cronjob that creates db backups every night.
My crontab has the job:
* * * * * /home/user/scripts/backup.sh
(have it set to go off every min for testing)
In backup.sh, I have:
docker exec -it dbContainer pg_dump -U username -d dbName > /home/user/backups/testingBackup.sql
The file is always empty:
-rw-rw-r-- 1 user user 0 Jul 14 08:39 testingBackup.sql
However, if I run the file on my own and type the command /home/user/scripts/backup.sh
,
it is not empty:
-rw-rw-r-- 1 user user 30813 Jul 14 08:45 testingBackup.sql
I feel like it makes sense something is off on the permissions, but everything is done from the "user". I haven't done anything from root such as sudo crontab... sudo /home/user/backups/testingBackup.sql, etc.
I am confused as to why in one scenario, the resulting file is empty, and in the other, it is not.
Thanks for any help