I want to do database back. I have created two files one is '.sh' and another one is '.py' file. both have execution permission.
-rwxrwxr-x 1 acespritech-bhaviraj acespritech-bhaviraj 152 Aug 8 14:26 google_drive_v8_backup.sh
-rwxrwxr-x 1 acespritech-bhaviraj acespritech-bhaviraj 334 Aug 8 14:26 google_drive_v8_db_backup.py
I have the following code into '.sh' file:
#!/bin/bash
#database backup code Dump DBs
echo "123456"|sudo -S /bin/bash -c "sudo python google_drive_v8_db_backup.py"
#database backup code ends
and into '.py' file I have following code:
import os
from datetime import datetime, date, timedelta
db_file_name = 'google_drive_v8'+'_'+datetime.strftime(datetime.today(), '%d_%m_%y_%H_%M_%S'+'.sql')
os.system("echo 123456|sudo su acespritech-bhaviraj /bin/bash -c 'pg_dump -E UTF-8 -p 5432 -F p -b -f '"+db_file_name+"' google_drive_v8' acespritech-bhaviraj")
I have run this two files manually I got database backup done, but when I add this '.sh' file into crontab like this below:
10 * * * * /bin/bash /home/acespritech-bhaviraj/backup/google_drive_v8_backup.sh
it is not running.
can you please help we what should I do?