First of all
- Install https://wiki.nethserver.org/doku.php?id=crontab crontab module!
- Have a Google Account (Any will do it)
- Have terminal (root) access to your NethServer, i tested it on NethServer 7.9.2009, it may work fine in others too or other administrator credentials!
- Have nano installed
yum install nanoor your fav terminal text editor.
sudo tar -C /usr/local -xf go1.13.5.linux-amd64.tar.gz
Set Go Path
sudo nano ~/.bash_profile
export GOPATH=$HOME/golang export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
Create Google Credentials
Create a new Project:
Give any name you want.
Click here and enable GDrive API:
Configure Conset Screen:
Check “External” and click “Create”
You should leave the rest blank. Click in “Save and Continue”. DO NOT ADD LOGO it will give you some trouble later on…
Add one Developer contact information.
No need to add Scopes or Test Users, just click “save and continue” and “back to dasboard”.
After that click on “Credentials” and “+Create Credentials”.:
Select “Desktop App” or “Others” and click “Create”:
Save this data:
go get github.com/prasmussen/gdrive
After that type:
Go to line 17& 18 and add your google Credentials (use your credentials):
const ClientId = "367116221053-7n0v**.apps.googleusercontent.com" const ClientSecret = "1qsNodXN*****jUjmvhoO"
Control+O to save changes
Hit Enter and then Control+X
Lets Build our project
Move Gdrive to sbin:
sudo mv gdrive /usr/sbin/gdrive
sudo chmod 700 /usr/sbin/gdrive
Publish your APP click “OAuth conset Screen” then “PUBLISH APP”:
One URL should appear, follow it and authorize it. With the correct Google Account
Something like this should show in Browser, click in “advanced”:
The click in the “unsafe” option.
Click in “Allow”
And Again, click “allow”
And paste it to your terminal.
Should look something like this:
Now to start “Sync” Folders you need to create folders using Gdrive:
Do as many folders you need to sync and keep organized. I did 3 folders!
gdrive mkdir foldername
It will look something like this:
Keep those gdrive Directory names, only with those you will be able to sync a folder within your linux.
If for any reason you lost them just type:
Something like this should:
In my case i want to sync 3 “file shares” therefore i created a file named backup.sh inside /usr/local/bin/
Inside that file.
#!/bin/sh cd / gdrive --config root/.gdrive sync upload /var/lib/nethserver/ibay/operacional/ 1xLTs8N7L8BBWAUKdoQCO0zt2mbYd2sUN gdrive --config root/.gdrive sync upload /var/lib/nethserver/ibay/patrimonio/ 1omMEYSMmqxqm1waXVqEREZT-7zxfjEl1 gdrive --config root/.gdrive sync upload /var/lib/nethserver/ibay/vendas/ 1k1t3ZZY_qqJLryPdIesZoNObnUqwoHCU
that --config root/.gdrive indicates where the token auth is.
The wierd letters and numbers after the ibay folder is where gdrive should sync, in my case i just need to upload, but here you can see your options.
give your backup.sh execute permissions.
chmod +x /usr/local/bin/backup.sh
Test it out.
Now just add it to your crotab schedule like this: