A simple tool to backup data & db from a web server to Google Drive.

Overview

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.

🎉

OAuth scopes in Google Cloud Console

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.
  • Activate Google Drive API.
    • Go to "OAuth authorization screen" and edit application.
    • Enable field .../auth/drive in order to create/remove some files. OAuth scopes in Google Cloud Console
  • Add a test user with the email you wish to use. Add a test user in Google Cloud Console
  • 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.json file 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!

Add a cronjob to start backing up in OVH

Developer resources 📝

You might also like...
A CLI tool to check whether a specific composer package uses imported symbols that aren't part of its direct composer dependencies

A CLI tool to analyze composer dependencies and verify that no unknown symbols are used in the sources of a package. This will prevent you from using "soft" dependencies that are not defined within your composer.json require section.

Takeout is a CLI tool for spinning up tiny Docker containers, one for each of your development environment dependencies.
Takeout is a CLI tool for spinning up tiny Docker containers, one for each of your development environment dependencies.

Takeout Takeout is a CLI tool for spinning up tiny Docker containers, one for each of your development environment dependencies. It's meant to be pair

A tool to generate boilerplate code, interact with and debug Drupal.

Table of Contents generated with DocToc Drupal Console Required PHP version Drupal Console documentation Download Drupal Console Run Drupal Console Co

A commandline based tool to sync watch state between different media servers

Warning This is an early release version, expect bugs and edge cases that we haven't encountered. Please keep that in mind before running this tool. w

A Cli tool to save you time, and gives you the power to scaffold all of your models,controllers,commands
A Cli tool to save you time, and gives you the power to scaffold all of your models,controllers,commands

A Cli tool to save you time, and gives you the power to scaffold all of your models,controllers,commands... at once Installation You can install the p

Command-line control panel for Nginx Server to manage WordPress sites running on Nginx, PHP, MySQL, and Let's Encrypt
Command-line control panel for Nginx Server to manage WordPress sites running on Nginx, PHP, MySQL, and Let's Encrypt

EasyEngine v4 EasyEngine makes it greatly easy to manage nginx, a fast web-server software that consumes little memory when handling increasing volume

☄️  PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server
☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server

☄️ PHP CLI mode development framework, supports Swoole, WorkerMan, FPM, CLI-Server / PHP 命令行模式开发框架,支持 Swoole、WorkerMan、FPM、CLI-Server

Host Onion services in dark web using Heroku CLI
Host Onion services in dark web using Heroku CLI

Tor Onion Service On Heroku Host Tor v3 Hidden Service in dark web using heroku Try my another repository built with php https://github.com/sumithemma

Web Shell Detector – is a php script that helps you find and identify php/cgi(perl)/asp/aspx shells.
Web Shell Detector – is a php script that helps you find and identify php/cgi(perl)/asp/aspx shells.

Web Shell Detector – is a php script that helps you find and identify php/cgi(perl)/asp/aspx shells. Web Shell Detector has a “web shells” signature database that helps to identify “web shell” up to 99%. By using the latest javascript and css technologies, web shell detector has a light weight and friendly interface.

Owner
Alex
Just a developer in various languages.
Alex
A simple command-line tool whose aim is to facilitate the continous delivery of PHP apps

Deployer Simple command-line tool that aims to facilitate the continous delivery of PHP apps, particularly Laravel apps. Imagine you want to update yo

Fernando Bevilacqua 4 Sep 8, 2021
Simple command-line tool to access HiWeb account information

Simple command-line tool to access HiWeb account information.

Milad Nekofar 2 Dec 26, 2022
PHP CLI tool which allows publishing zipped MODX extra to modstore.pro marketplace

MODX Extra Publisher PHP CLI tool which allows publishing zipped MODX extra to modstore.pro marketplace. Installation global? local? To install packag

Ivan Klimchuk 3 Aug 6, 2021
👨🏻‍🚀 A command-line tool that gives you the Alpine Day 2021 schedule in your timezone. 🚀

Alpine Day Schedule a command-line tool that gives you the Alpine Day 2021 schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, instal

Nuno Maduro 11 Jun 10, 2021
PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal.

PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal. ??

Nuno Maduro 32 Dec 26, 2022
Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check.

Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check. Installation / Usage Requires PHP 8.0+ First, install Patr

Nuno Maduro 237 Nov 14, 2022
A PHP command line tool used to install shlink

Shlink installer A PHP command line tool used to install shlink. Installation Install this tool using composer.

null 8 Nov 3, 2022
Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone.

Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, install: c

Nuno Maduro 101 Sep 16, 2022
A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies.

Front End Compiler A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies. The minif

Happy Medium 2 Nov 12, 2021
💥 Collision is a beautiful error reporting tool for command-line applications

Collision was created by, and is maintained by Nuno Maduro, and is a package designed to give you beautiful error reporting when interacting with your

Nuno Maduro 4.2k Jan 5, 2023