backuptogoogle | Backup to Google Drive use gdrive | REST library
kandi X-RAY | backuptogoogle Summary
kandi X-RAY | backuptogoogle Summary
Backup to Google Drive use gdrive
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of backuptogoogle
backuptogoogle Key Features
backuptogoogle Examples and Code Snippets
Community Discussions
Trending Discussions on backuptogoogle
QUESTION
I am trying to take backup of my website`s files and database and upload it to google drive from my website via Google drive Api.
Followed instructions as per these links - backup files to google drive using php https://www.matthewhipkin.co.uk/codelib/automatically-backing-up-your-web-server-files-to-googledrive-with-php/ and did the following -
downloaded the backupgoogledrive folder from https://github.com/hippy2094/backuptogoogledrive and uploaded that in my public_html/backup folder and renamed backuptogoogle.php as backup/index.php
I created the client ID, client secret and an authCode and put those in the setting.inc along with my MySQL username, password and database name. $homedir was put as
/home/myuser/
and $sitedir was set topublic_html/
Then, I ran in SSH - php /home/user/backup/index.php
This ran fine generating a json file and backup for files and database also was found in google drive.
Then, I set up cron job as follows - 5 0 * * 6 /usr/local/bin/php /home/myusername/public_html/backup/index.php
This should run the script at 00:05 on a saturday but it did NOT run or backup to google drive.
After that, I changed the cron to run every 15 minutes. I noticed that the files and database backups are going to home/myuser folder instead of google drive and the error_log in that folder is giving this error every 15 minutes -
Fatal error: Uncaught exception 'Google_AuthException' with message 'Error fetching OAuth2 access token, message: 'invalid_grant'' in /home/myuser/public_html/backup/google-api-php-client/src/auth/Google_OAuth2.php:115
Stack trace:
#0 /home/myuser/public_html/backup/google-api-php-client/src/Google_Client.php(127): Google_OAuth2->authenticate(Array, '4/SCxgUoxjnbe_0...')
#1 /home/myuser/public_html/backup/index.php(38): Google_Client->authenticate('4/SCxgUoxjnbe_0...')
#2 {main} thrown in /home/myuser/public_html/backup/google-api-php-client/src/auth/Google_OAuth2.php on line 115`
Please note while registering at Google API at https://console.developers.google.com/apis I selected Other
option in the Credentials Page and not Web Application
because my aim is only to take backup for my site. Also, when I selected the Web Application
option and generated the client ID and secret and tried to generate the authCode via url generated in SSH, it would give an error with the SSH generated url. So, the solutions for invalid grant
which are mentioned in other posts do not work for me as I do not get option for setting call back url.
Please tell what I am doing wrong. Why I am able to run the script successfully manually and not via cron ? When I am running the script manually running in SSH. Only problem happens when cron runs.
Thanks in advance.
...ANSWER
Answered 2018-Jan-27 at 03:03Found the solutions as follows -
Put in the file index.php this code -
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install backuptogoogle
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page