php-google-drive-backup
                                
                                
                                
                                    php-google-drive-backup copied to clipboard
                            
                            
                            
                        A simple tool to backup data & db from a web server to Google Drive.
PHP Google Drive backup
A (very) simple CLI tool that I used to backup my www directory and my database from OVH to Google Drive, in a cronjob.
🎉

Disclaimer
⚠️You should never trust a script found on GitHub to backup your data!
🔥 I made this script in a few hours. It not perfect, but it works very well.
Getting started 🔧
You need to configure your Google Cloud Console account first.
- Create a new project and an OAuth from quickstart.
- Download the 
credentials.json. - Upload it in the root directory of this project.
 
 - Download the 
 - Activate Google Drive API.
- Go to "OAuth authorization screen" and edit application.
 - Enable field 
.../auth/drivein order to create/remove some files.
 
 - Add a test user with the email you wish to use.

 - ❌ Do not activate the "production review" since:
- You do not need it.
 - It will make you unable to continue the process.
 
 - Run the project using CLI (locally if you have to).
 - Then, generate the proper 
token.jsonfile by logging with the given URL from CLI.- Authenticate yourself with your Google Account...
 
 - All good! ✅
 
Environments variables 🚀
The following environment variables must be declared.
If you do not know how it works, just create a file named .env in the root directory with your own configuration.
(The .env.dist file contains a skeleton.)
Example:
DB_HOST=127.0.0.1
DB_USER=username
DB_PASSWORD=password
DB_NAME=database_name
DB_PORT=3306
DIRECTORY_TO_BACKUP=www
DELETE_UPLOADED_BACKUPS=false
ONLY_CLI=false
Feel free to fill it with your config!
Launching cronjob from OVH to Google Drive
Here is my cronjob configuration.
- I decided to run the job the first and the fifteenth of each month: 
0 0 1,15 * * - Logs are sent by email
 - All good! ✅
 

Developer resources 📝
- Google Quickstart with Google Drive API in PHP.
 - Documentation & examples googleapis/google-api-php-client (used by this project).
- API documentation (for old school developers 💪).