Want to subscribe to topics you're interested in?
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:
    1:16 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

    53,142
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    5:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Thanks for sharing. I moved your thread to Centmin Mod User Tutorial forum. Seems like the best place :)
     
  3. TRINH AI QUOC

    TRINH AI QUOC New Member

    13
    1
    3
    Dec 28, 2020
    Ratings:
    +1
    Local Time:
    2:46 PM
    1.17.3
    10
    hi @eva2000 @Dnyan
    Is it working now.
    i can't install go

    -bash: go: command not found
     
  4. eva2000

    eva2000 Administrator Staff Member

    53,142
    12,108
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,643
    Local Time:
    5:46 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    You should be able to with latest 124.00stable or 130.00beta01 run these 3 commands
    Code (Text):
    cmupdate
    cd /usr/local/src/centminmod/addons/
    ./golang.sh install
    

    Then exist SSH session and re-login via SSH