Welcome to Centmin Mod Community
Become a Member

Backup database and files to Google Drive Securely

Discussion in 'Centmin Mod User Tutorials & Guides' started by Dnyan, Jun 2, 2020.

  1. Dnyan

    Dnyan Member

    106
    24
    18
    Sep 16, 2017
    Ratings:
    +36
    Local Time:
    6:00 PM
    1.17.8
    10.3.22
    Now you can upload your backup files to google drive very easily with your own app and credential.

    First check go language is installed on your OS or not by writing command
    Code:
    go version
    If its output the version of installed go version then OK, else do install the golang addon on your system.

    Code:
    cd /usr/local/src/centminmod/addons
    wget --no-check-certificate https://github.com/centminmod/centminmod/raw/master/addons/golang.sh
    Give script appropriate permissions via command:
    Code:
    chmod 0700 /usr/local/src/centminmod/addons/golang.sh
    Run golang.sh script via commands:
    Code:
    cd /usr/local/src/centminmod/addons/
      ./golang.sh install
    After complition of install, do check its version by:
    Code:
    go version
    it will output the installed version details of go lang.

    Create your own credentials:
    • Go to Google API Console
    • Create a new project
    • Enable Google Drive API
    • Configure Consent Screen
    • Create credentials by choosing OAuth client ID
    for tutorial on how to create your own credential, click on link own Google credentials.

    as this tutorial is older one, instead of selecting other, do select desktop.

    Once the credentials are created, do install drive with following command:
    Code:
    go get github.com/prasmussen/gdrive
    now it will get installed in packages directory.

    change directory to pkg:
    Code:
    cd $GOPATH/src/github.com/prasmussen/gdrive
    Edit the credentials in handlers_drive.go file with your own by opening it with nano editor:
    Code:
    nano handlers_drive.go
    at line 17 & 18, set your credential value, it will look somewhat shown below:
    Code:
    const ClientId = "****************.apps.googleusercontent.com"
    const ClientSecret = "*******************"
    Now run the following command to build your app:
    Code:
    go build
    On completion of building your app, you will see a new file created at this package root directory namely gdrive. you can also run command to check it
    Code:
    ls -lah
    in a list, you will able to see now the gdrive file.


    move this file to bin folder by following command
    Code:
    mv gdrive /usr/sbin/gdrive

    Give appropriate permissions via command:
    Code:
    chmod 700 /usr/sbin/gdrive
    Now run command:
    Code:
    gdrive list
    in reply you will get a link for authenticating access of server to your google drive.
    Copy and paste it in browser and give it access, after giving access, you will get a verification code, copy it and paste it into your cli.

    once the authentication process is completed and your google drive files are listed in cli, you can now transfer files from your server to google drive in a click.

    command for uploading file to your drive:
    Code:
    gdrive upload /path/to/your/backup/file.zip
    You can also upload file to a specific folder by following command:
    Code:
    gdrive upload --parent ********* /path/to/your/backup/file.zip
    ******** is a code for folder shown in your browser for particular opened folder https: //drive.google .com /drive/folders/**********

    You can also schedule a cron for regular automatic backups.
     
  2. eva2000

    eva2000 Administrator Staff Member

    47,551
    10,789
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,774
    Local Time:
    10:30 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    Thanks for sharing. I moved your thread to Centmin Mod User Tutorial forum. Seems like the best place :)