Manny Posted May 22, 2016 Share Posted May 22, 2016 (edited) Hi all, I've created a script which will take backups of my databases and compress them together in a tar.gz file. This runs perfectly fine on the command line, but I'm unable to get it working via crontab. Here is the script that backs up the databases (which has permissions of 755) #!/bin/sh # Create a temporary directory to store the MySQL databases mkdir /$( date '+%Y-%m-%d' ) # Enter the temporary directory created above cd /$( date '+%Y-%m-%d' ) # Create a dump of each database mysql -u user -ppass -e 'show databases' | while read dbname; do mysqldump -u user -ppass -h localhost "$dbname" > "$dbname".sql; done # Create a tar.gz archive, consisting of all database backups tar -zcf /$( date '+%Y-%m-%d' ).tar.gz /$( date '+%Y-%m-%d' ) # Transfer the tar.gz archive to Google Drive gdrive upload --parent XXXXX /$( date '+%Y-%m-%d' ).tar.gz Again, this runs perfectly on the command line. However, the following cron does not appear to do anything. 0 3 * * * /backup-db The 'gdrive' command comes from the following Git and is installed at /usr/local/bin/gdrive https://github.com/prasmussen/gdrive It is worth noting that the script is located at the highest level of the server (e.g. / ) Any advice on how to get this working would be very much appreciated. Edited May 22, 2016 by Manny Link to comment Share on other sites More sharing options...
Manny Posted May 22, 2016 Author Share Posted May 22, 2016 If you're now taking the time to read this threat, I'm happy to report my issue has been resolved. Head on over to the following URL for updated script and the resolution, which was to do with PATH. https://github.com/prasmussen/gdrive/issues/151 Link to comment Share on other sites More sharing options...
htmlcolor Posted August 12, 2017 Share Posted August 12, 2017 (edited) Thanks for the information your article brings. I see the novelty of your writing, I will share it for everyone to read together. I look forward to reading many articles from you. Edited August 12, 2017 by Ingolme Removed advertising link Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now