mbrother2 / backuptogoogle Goto Github PK
View Code? Open in Web Editor NEWBackup to Google Drive use gdrive
License: MIT License
Backup to Google Drive use gdrive
License: MIT License
Checking connectivity... done.
[ 17/11/2019 11:28:30 ] Build your own gdrive!
Please go to URL to create your own Google credential:
https://github.com/mbrother2/backuptogoogle/wiki/Create-own-Google-credential-step-by-step
Your Google API client_id: 341513425591-XXXXXXXXXXXXXXXXXX.apps.googleusercontent.com341513425591-XXXXXXXXXXXXXXXXXX.apps.googleusercontent.com
Your Google API client_secret: oLQr3eF8QKZH1FXXXXXXXXX
[ 17/11/2019 11:28:58 ] Building gdrive...
[ 17/11/2019 11:29:12 ] Build gdrive successful. Gdrive bin locate here /root/bin/gdrive
[ 17/11/2019 11:29:12 ] Setting up gdrive credential...
Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=341513425591-XXXXXXXXXXXXXXXXX.apps.googleusercontent.com341513425591-XXXXXXXXXXXXXXXXX.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=state
Enter verification code:
^C
root@localhost:## gdrive list
root@localhost:
Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=367116221053-XXXXXXXXXXXXXXXX.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=state
Enter verification code:
i use control C to cancel and
run gdrive list to get new link for password request
after that all working fine
Dear developers,
Can this script synchronous backup multiple directories? Thanks.
Failed to upload file: Post https://www.googleapis.com/upload/drive/v3/files?alt=json&fields=id%2Cname%2Csize%2Cmd5Checksum&uploadType=resumable&upload_id=AEnB2UopoJ0Trgypi8hYy6ikNOx9-gAc1i0pdwdHw8THiv6ifWVJvSSUQVYORhEpyZDVQC9_0Q38R7m_qYTxSxaJzN2ExBS6Bg: oauth2: cannot fetch token: 401 Unauthorized
Response: {
"error": "unauthorized_client",
"error_description": "Unauthorized"
}
It shows me this when worked a while. How could I deal with it?
bash butgg.bash --setup
[root@charlie ~]# bash butgg.bash --setup
[ 14/05/2020 20:01:35 ] ---
[ 14/05/2020 20:01:35 ] Creating necessary directory...
[ 14/05/2020 20:01:35 ] Directory /root/.gdrive existed. Skip
[ 14/05/2020 20:01:35 ] Check write to /root/.gdrive successful
[ 14/05/2020 20:01:35 ] Directory /root/bin existed. Skip
[ 14/05/2020 20:01:35 ] Check write to /root/bin successful
[ 14/05/2020 20:01:35 ] Checking OS...
[ 14/05/2020 20:01:35 ] OS supported
[ 14/05/2020 20:01:35 ] Checking necessary package...
/usr/bin/curl
[ 14/05/2020 20:01:35 ] Package curl is installed
/usr/bin/realpath
[ 14/05/2020 20:01:35 ] Package realpath is installed
/usr/bin/git
[ 14/05/2020 20:01:35 ] Package git is installed
[ 14/05/2020 20:01:35 ] Cheking network...
[ 14/05/2020 20:01:35 ] Connect Github successful
[ 14/05/2020 20:01:35 ] Connect Google successful
[ 14/05/2020 20:01:35 ] Downloading script cron file from github...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16481 100 16481 0 0 98330 0 --:--:-- --:--:-- --:--:-- 98688
[ 14/05/2020 20:01:36 ] [CHECKS][FAIL] Can not verify md5 for file cron_backup.bash. Exit!
sh butgg.sh --setup
[ 25/11/2019 09:04:00 ] Directory /root/bin existed. Skip
[ 25/11/2019 09:04:00 ] Check write to /root/bin successful
[ 25/11/2019 09:04:00 ] Cheking network...
[ 25/11/2019 09:04:00 ] Connect Github successful
[ 25/11/2019 09:04:00 ] Connect Google successful
[ 25/11/2019 09:04:00 ] Checking OS...
[ 25/11/2019 09:04:00 ] Sorry! We do not support your OS. Exit
Could you kindly support Debian Linux? Right now, the above message is shown when running butgg.
Greets
-act
cron_backup.sh -v
[ 16/02/2020 13:01:11 ] ---
[ 16/02/2020 13:01:11 ] Checking OS...
[ 16/02/2020 13:01:11 ] OS supported
[ 16/02/2020 13:01:12 ] Start upload to Google Drive...
[ 16/02/2020 13:01:12 ] Checking Google folder ID...
[ 16/02/2020 13:11:51 ] [CHECKS][FAIL] Can not find Google folder ID 1M4OdlBWWrm3HarjdloMjAw0eXWtwOuKP . Exit
[ 16/02/2020 13:11:51 ] Sending error email...
[ 16/02/2020 13:11:54 ] Send error email successful
[ 16/02/2020 12:56:30 ] ---
[ 16/02/2020 12:56:30 ] Creating necessary directory...
[ 16/02/2020 12:56:30 ] Directory /home/canor/.gdrive existed. Skip
[ 16/02/2020 12:56:30 ] Check write to /home/canor/.gdrive successful
[ 16/02/2020 12:56:30 ] Directory /home/canor/bin existed. Skip
[ 16/02/2020 12:56:30 ] Check write to /home/canor/bin successful
[ 16/02/2020 12:56:30 ] Checking OS...
[ 16/02/2020 12:56:30 ] OS supported
[ 16/02/2020 12:56:30 ] Checking necessary package...
/usr/bin/curl
[ 16/02/2020 12:56:30 ] Package curl is installed
/usr/bin/git
[ 16/02/2020 12:56:30 ] Package git is installed
[ 16/02/2020 12:56:30 ] Cheking network...
[ 16/02/2020 12:56:31 ] Connect Github successful
[ 16/02/2020 12:56:31 ] Connect Google successful
[ 16/02/2020 12:56:31 ] Downloading script cron file from github...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16335 100 16335 0 0 37465 0 --:--:-- --:--:-- --:--:-- 37379
[ 16/02/2020 12:56:32 ] Check md5sum for file cron_backup.bash successful
[ 16/02/2020 12:56:32 ] Downloading setup file from github...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16626 100 16626 0 0 36621 0 --:--:-- --:--:-- --:--:-- 36540
[ 16/02/2020 12:56:33 ] Check md5sum for file butgg.bash successful
[ 16/02/2020 12:56:33 ] Downloading go from Google...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 122M 100 122M 0 0 10.2M 0 0:00:11 0:00:11 --:--:-- 10.3M
[ 16/02/2020 12:56:44 ] Extracting go lang...
[ 16/02/2020 12:56:47 ] Cloning gdrive project from Github...
Cloning into 'gdrive'...
remote: Enumerating objects: 1458, done.
remote: Total 1458 (delta 0), reused 0 (delta 0), pack-reused 1458
Receiving objects: 100% (1458/1458), 465.59 KiB | 636.00 KiB/s, done.
Resolving deltas: 100% (873/873), done.
[ 16/02/2020 12:56:49 ] Build your own gdrive!
Read more: https://github.com/mbrother2/backuptogoogle/wiki/Create-own-Google-credential-step-by-step
Your Google API client_id:
Your Google API client_secret:
[ 16/02/2020 12:59:02 ] Building gdrive...
[ 16/02/2020 12:59:03 ] Build gdrive successful. Gdrive bin locate here /home/canor/bin/gdrive
[ 16/02/2020 12:59:03 ] Setting up gdrive credential...
User: 엄성찬(학부/문과대학 중어중문학), [email protected]
Used: 3.3 TB
Free: -3263807690678.0 B
Total:
Max upload size: 5.2 TB
[ 16/02/2020 12:59:04 ] Setup gdrive credential successful
[ 16/02/2020 12:59:04 ] Setting up config file...
Which directory on your server do you want to upload to Google Drive?(default /home/canor/backup):
How many days do you want to keep backup on Google Drive?(default 7):
Read more https://github.com/mbrother2/backuptogoogle/wiki/What-is-the-option-SYNC_FILE%3F
Do you want only sync file(default no)(y/n):
Read more https://github.com/mbrother2/backuptogoogle/wiki/Get-Google-folder-ID
Your Google folder ID(default None): 1M4OdlBWWrm3HarjdloMjAw0eXWtwOuKP
Do you want compress directory before upload?(default no)(y/n):
Read more https://github.com/mbrother2/backuptogoogle/wiki/Turn-on-2-Step-Verification-&-create-app's-password-for-Google-email
Do you want to send email if upload error(default no)(y/n): y
Your Google email user name: [email protected]
Your Google email password:
Which email will be receive notify?: [email protected]
[ 16/02/2020 13:00:11 ] Setup config file successful
[ 16/02/2020 13:00:11 ] Setting up cron backup...
[ 16/02/2020 13:00:11 ] Cron backup existed. Skip
[ 16/02/2020 13:00:11 ] +-----
[ 16/02/2020 13:00:11 ] | SUCESSFUL! Your information:
[ 16/02/2020 13:00:11 ] | Backup dir : /home/canor/backup
[ 16/02/2020 13:00:11 ] | Config file : /home/canor/.gdrive/butgg.conf
[ 16/02/2020 13:00:11 ] | Log file : /home/canor/.gdrive/butgg.log
[ 16/02/2020 13:00:11 ] | Keep backup : 7 days
[ 16/02/2020 13:00:11 ] | Google folder ID: 1M4OdlBWWrm3HarjdloMjAw0eXWtwOuKP
[ 16/02/2020 13:00:11 ] | Your email : [email protected]
[ 16/02/2020 13:00:11 ] | Email password :
[ 16/02/2020 13:00:11 ] | Email notify : [email protected]
[ 16/02/2020 13:00:11 ] | butgg.bash file : /home/canor/bin/butgg.bash
[ 16/02/2020 13:00:11 ] | Cron backup file: /home/canor/bin/cron_backup.bash
[ 16/02/2020 13:00:11 ] | Gdrive bin file : /home/canor/bin/gdrive
[ 16/02/2020 13:00:11 ] | Cron backup : 0 0 * * * bash /home/canor/bin/cron_backup.bash >/dev/null 2>&1
[ 16/02/2020 13:00:11 ] | Google token : /home/canor/.gdrive/token_v2.json
[ 16/02/2020 13:00:11 ] +-----
IMPORTANT: Please run command to use butgg: source /home/canor/.profile
If you get trouble when use butgg.bash please report here:
https://github.com/mbrother2/backuptogoogle/issues
backup script says Google folder with that ID is unable to find but it actually exists. And it used to work before. Any suggestion?
Could you add file/folder exclusion.
Hi i created one file in /root/.gdrive/exclude.list
and my backup path is : /opt/project
but i want to exclude /opt/project/cache folder
i try put to exclude.list
cache
/opt/project/cache
but doesnt help how can exclude spesific folders ?
./butgg.bash --setup only-build
[ 06/03/2023 01:05:39 ] ---
[ 06/03/2023 01:05:39 ] Creating necessary directory...
[ 06/03/2023 01:05:39 ] Create directory /root/.gdrive successful
[ 06/03/2023 01:05:39 ] Check write to /root/.gdrive successful
[ 06/03/2023 01:05:39 ] Create directory /root/bin successful
[ 06/03/2023 01:05:39 ] Check write to /root/bin successful
[ 06/03/2023 01:05:39 ] Checking OS...
[ 06/03/2023 01:05:39 ] OS supported
[ 06/03/2023 01:05:39 ] Checking necessary package...
[ 06/03/2023 01:05:39 ] Package curl is installed
[ 06/03/2023 01:05:39 ] Package realpath is installed
[ 06/03/2023 01:05:39 ] Command git not found. Trying to install git...
[ 06/03/2023 01:06:18 ] Package git is installed
[ 06/03/2023 01:06:18 ] Cheking network...
[ 06/03/2023 01:06:18 ] Connect Github successful
[ 06/03/2023 01:06:18 ] Connect Google successful
[ 06/03/2023 01:06:18 ] Downloading go from Google...
[ 06/03/2023 01:06:58 ] Extracting go lang...
[ 06/03/2023 01:07:06 ] Cloning gdrive project from Github...
[ 06/03/2023 01:07:09 ] Build your own gdrive!
[ 06/03/2023 01:07:35 ] Building gdrive...
[ 06/03/2023 01:13:11 ] �[31m[ERROR]�[0m Can not build gdrive. Exit
Error:
[ 06/03/2023 01:07:35 ] Building gdrive...
# golang.org/x/oauth2/google
/root/go/src/golang.org/x/oauth2/google/error.go:22:6: undefined: errors.As
# golang.org/x/oauth2/google
/root/go/src/golang.org/x/oauth2/google/error.go:22:6: undefined: errors.As
[ 06/03/2023 01:13:11 ] [ERROR] Can not build gdrive. Exit
I am using the Windows version of the gdrive utility, a Windows version of this script will be quite helpful (ref: the issue logged in gdrive for getting failures with 400 error).
gdrive about?
Failed to get about: Get https://www.googleapis.com/drive/v3/about?alt=json&fields=maxImportSizes%2CmaxUploadSize%2CstorageQuota%2Cuser: oauth2: cannot fetch token: 400 Bad Request Response: { "error": "invalid_grant", "error_description": "Token has been expired or revoked."
[ 13/12/2019 16:35:32 ] [CHECKS][FAIL] Can not verify md5 for file butgg.bash. Exit!
Base on idea of https://github.com/rborges89 at issue #16
[ 25/11/2019 13:00:12 ] [CHECKS][FAIL] Can not connect to Github file, please check your network. Exit
sh butgg.sh --setup
[ 15/11/2019 10:07:11 ] ---
[ 15/11/2019 10:07:12 ] Cheking network...
[ 15/11/2019 10:07:12 ] Connect Github successful
[ 15/11/2019 10:07:12 ] Connect Google successful
[ 15/11/2019 10:07:12 ] Checking OS...
[ 15/11/2019 10:07:12 ] OS supported
[ 15/11/2019 10:07:12 ] Downloading script cron file from github...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6486 100 6486 0 0 16659 0 --:--:-- --:--:-- --:--:-- 16630
butgg.sh: 39: [: Ubuntu: unexpected operator
butgg.sh: 39: [: Ubuntu: unexpected operator
butgg.sh: 1: butgg.sh: md5: not found
butgg.sh: 45: [: fd4ed0c766ca96af93cd15fc1eda4bc6: unexpected operator
[ 15/11/2019 10:07:12 ] -e \e[31m[CHECKS][FAIL]\e[0m Can not verify md5sum for file cron_backup.sh. Exit!
gdrive upload
build gdrive
[ 09/12/2019 07:56:12 ] Building gdrive...
# cd .; git clone https://go.googlesource.com/oauth2 /home/thanh3/go/src/golang.org/x/oauth2
Cloning into '/home/thanh3/go/src/golang.org/x/oauth2'...
fatal: unable to access 'https://go.googlesource.com/oauth2/': The requested URL returned error: 502
package golang.org/x/oauth2/google: exit status 128
../../go/src/github.com/prasmussen/gdrive/auth/oauth.go:6:2: cannot find package "golang.org/x/oauth2/google" in any of:
/home/thanh3/go/src/github.com/prasmussen/gdrive/vendor/golang.org/x/oauth2/google (vendor tree)
/home/thanh3/bin/go/src/golang.org/x/oauth2/google (from $GOROOT)
/home/thanh3/go/src/golang.org/x/oauth2/google (from $GOPATH)
[ 09/12/2019 07:56:44 ] [ERROR] Can not build gdrive. Exit
Upload file
[ 09/12/2019 15:27:28 ] [UPLOAD][FAIL] Can not upload backup file Uploading /backup/admin.root.admin.tar.gz Failed to upload file: googleapi: got HTTP response code 502 with body: <!DOCTYPE html> <html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> <title>Error 502 (Server Error)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style> <a href=//www.google.com/><span id=logo aria-label=Google></span></a> <p><b>502.</b> <ins>That’s an error.</ins> <p>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds. <ins>That’s all we know.</ins>. Exit
getting this:
root@ashbury1:/home/wuser/backuptogoogle# ./cron_backup.bash -v
[ 25/03/2020 14:02:43 ] ---
[ 25/03/2020 14:02:43 ] Checking OS...
[ 25/03/2020 14:02:43 ] OS supported
[ 25/03/2020 14:02:44 ] Start upload to Google Drive...
[ 25/03/2020 14:02:44 ] Checking Google folder ID...
[ 25/03/2020 14:02:44 ] Check Google folder ID successful
[ 25/03/2020 14:02:44 ] Directory 25_03_2020 existed. Skipping...
[ 25/03/2020 14:02:45 ] [INFO] You do not compress directory before upload
./cron_backup.bash: line 269: realpath: command not found
[ 25/03/2020 14:02:45 ] [CHECKS][FAIL] Can not detect file type for /build_gdrive_windows.bash. Exit
Originally posted by @cduduc in #13 (comment)
cron_backup.bash
I built & installed your app and am keen to use it. But I'm a bit new.
It seemed to install fine and I wanted to run it.
I went into the bin folder and tried to run cron, but it says "command not found".
How does the script know what to backup? must it be in /home/root/backup folder?
root@PBS08:/bin# ll/bin# sh cron_backup.bash
total 6536
drwxr-xr-x 2 root root 4096 Feb 4 05:52 ./
drwxr-xr-x 36 jan jan 4096 Feb 4 05:36 ../
-rwxr-xr-x 1 root root 16626 Feb 4 05:35 butgg.bash*
-rwxr-xr-x 1 root root 16335 Feb 4 05:35 cron_backup.bash*
-rwxr-xr-x 1 root root 6644736 Feb 4 05:37 gdrive*
root@PBS08:
cron_backup.bash: 170: cron_backup.bash: Syntax error: "(" unexpected
root@PBS08:/bin# cron_backup.bash/bin#
cron_backup.bash: command not found
root@PBS08:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.