Coder Social home page Coder Social logo

backuptogoogle's Introduction

backuptogoogle (Linux: butgg.bash - BSD: butgg.sh)

Tired of gdrive? Gdrive project dead? I wrote some scripts to use rclone for backuping from your server to Google Drive. Please try here:

What can this script do?

  • Complie gdrive (https://github.com/gdrive-org/gdrive) on your server with your Google credential
  • Create cron auto backup
  • Exclude file/directory when run cron backup
  • Sync backup directory from local to Google Drive
  • Compress backup directory before upload
  • Send error email if upload to Google Drive fail
  • Auto remove old backup on Google Drive
  • Run upload from your backup directory to Google Drive whenever you want
  • Detail log

Structure

$HOME (/root or /home/$USER)
   ├── bin
   │    ├── butgg.bash (or butgg.sh on BSD system)
   │    ├── cron_backup.bash (or cron_backup.sh on BSD system)
   │    └── gdrive
   └── .gdrive
        ├── butgg.conf
        ├── butgg.log
        ├── exclude.list (exist if you create)
        ├── detail.log (debug log if run fail)
        └── token_v2.json

OS support(x86_64):

  • Linux: CentOS, Debian, Ubuntu, openSUSE
  • BSD: FreeBSD
  • Commercial: CloudLinux, SUSE Linux Enterprise
  • Windows: Build gdrive only

Environment

  • Server, VPS, shared hosting

[BETA] Support docker & docker-compose

For more informations: https://hub.docker.com/r/mbrother2/backuptogoogle


How to use

On Linux system:

curl -o butgg.bash https://raw.githubusercontent.com/mbrother2/backuptogoogle/master/butgg.bash
bash butgg.bash --setup

On BSD system:

curl -o butgg.sh https://raw.githubusercontent.com/mbrother2/backuptogoogle/master/butgg.sh
sh butgg.sh --setup

On Windows system:

  1. Install git for windows https://git-scm.com/download/win
  2. Build gdrive on Git bash terminal:
curl -o build_gdrive_windows.bash https://raw.githubusercontent.com/mbrother2/backuptogoogle/master/build_gdrive_windows.bash
bash build_gdrive_windows.bash

Wiki

Change log

https://github.com/mbrother2/backuptogoogle/blob/master/CHANGLOG.md

Options

Run command bash butgg.bash --help(or sh butgg.sh --help on BSD system) to show all options( After install you only need run butgg.bash --help(or butgg.sh --help on BSD system))

butgg.bash - Backup to Google Drive solution

Usage: butgg.bash [options] [command]

Options:
  --help       show this help message and exit
  --setup      setup or reset all scripts & config file
    config     only setup config
    credential only setup credential
    only-build only build gdrive bin
    no-build   setup butgg without build gdrive
    no-update  setup butgg without update script
  --update     update to latest version
  --uninstall  remove all butgg scripts and .gdrive directory

Command

1. Help

butgg.bash --help (or butgg.sh --help on BSD system) Show help message and exit

Example
[thanh1@centos7 .gdrive]$ butgg.bash --help
butgg.bash - Backup to Google Drive solution

Usage: butgg.bash [options] [command]

Options:
  --help       show this help message and exit
  --setup      setup or reset all scripts & config file
    config     only setup config
    credential only setup credential
    only-build only build gdrive bin
    no-build   setup butgg without build gdrive
    no-update  setup butgg without update script
  --update     update to latest version
  --uninstall  remove all butgg scripts and .gdrive directory
2. Setup

butgg.bash --setup (or butgg.sh --setup on BSD system) Set up or reset all scripts & config file

Example
[thanh1@centos7 ~]$ butgg.bash --setup
[ 14/11/2019 10:54:25 ] Cheking network...
[ 14/11/2019 10:54:25 ] Connect Github successful
[ 14/11/2019 10:54:26 ] Connect Google successful
[ 14/11/2019 10:54:26 ] Checking OS...
[ 14/11/2019 10:54:26 ] OS supported
[ 14/11/2019 10:54:26 ] Downloading script cron file from github...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5808  100  5808    0     0   7944      0 --:--:-- --:--:-- --:--:--  7956
[ 14/11/2019 10:54:27 ] Check md5sum for file cron_backup.bash successful
[ 14/11/2019 10:54:27 ] Downloading setup file from github...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 11151  100 11151    0     0  26427      0 --:--:-- --:--:-- --:--:-- 26424
[ 14/11/2019 10:54:28 ] Check md5sum for file butgg.bash successful
/usr/bin/git
[ 14/11/2019 10:54:28 ] 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.1M      0  0:00:12  0:00:12 --:--:-- 11.0M
[ 14/11/2019 10:54:40 ] Extracting go lang...
[ 14/11/2019 10:54:45 ] 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.06 KiB | 228.00 KiB/s, done.
Resolving deltas: 100% (873/873), done.
[ 14/11/2019 10:54:49 ] 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: 782896115405-qs2evi3rqlnkjm2vond8onilq9xxxxxx.apps.googleusercontent.com
 Your Google API client_secret: g7p_kcdNEq_ULsfxrTxxxxxx
[ 14/11/2019 10:55:02 ] Building gdrive...
[ 14/11/2019 10:55:03 ] Build gdrive successful
[ 14/11/2019 10:55:04 ] 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=782896115405-qs2evi3rqlnkjm2vond8onilq9xxxxxx.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: 4/tQEqtaOpkPsX1keXGuZWQsPMB5AF0mZ7a_FiiSheYnYuSBejxxxxxx
User: mbr other, [email protected]
Used: 
Free: 16.1 GB
Total: 16.1 GB
Max upload size: 5.2 TB
[ 14/11/2019 10:55:29 ] Setup gdrive credential successful
[ 14/11/2019 10:55:29 ] Setting up config file...
 Which directory do you want to upload to Google Drive?(default /home/thanh1/backup): /home/thanh1/backup2/backup
 How many days you want to keep backup on Google Drive?(default 7): 30
[ 14/11/2019 10:55:47 ] [WARNING] Directory /home/thanh1/backup2/backup does not exist! Ensure you will be create it after.
[ 14/11/2019 10:55:50 ] Setup config file successful
[ 14/11/2019 10:55:50 ] Setting up cron backup...
[ 14/11/2019 10:55:50 ] Cron backup existed. Skip

[ 14/11/2019 10:55:50 ] +-----
[ 14/11/2019 10:55:50 ] | SUCESSFUL! Your information:
[ 14/11/2019 10:55:50 ] | Backup dir      : /home/thanh1/backup2/backup
[ 14/11/2019 10:55:50 ] | Config file     : /home/thanh1/.gdrive/butgg.conf
[ 14/11/2019 10:55:50 ] | Log file        : /home/thanh1/.gdrive/butgg.log
[ 14/11/2019 10:55:50 ] | Keep backup     : 30 days
[ 14/11/2019 10:55:50 ] | butgg.sh file   : /home/thanh1/bin/butgg.bash
[ 14/11/2019 10:55:50 ] | Cron backup file: /home/thanh1/bin/cron_backup.bash
[ 14/11/2019 10:55:50 ] | Gdrive bin file : /home/thanh1/bin/gdrive
[ 14/11/2019 10:55:50 ] | Cron backup     : 0 0 * * * bash /home/thanh1/bin/cron_backup.bash >/dev/null 2>&1
[ 14/11/2019 10:55:50 ] | Google token    : /home/thanh1/.gdrive/token_v2.json
[ 14/11/2019 10:55:50 ] +-----

 If you get trouble when use butgg.bash please report here:
 https://github.com/mbrother2/backuptogoogle/issues

butgg.bash --setup config (or butgg.sh --setup config on BSD system) Only edit butgg.conf

Example
[thanh1@centos7 .gdrive]$ butgg.bash --setup config
[ 15/11/2019 08:41:54 ] ---
[ 15/11/2019 08:41:54 ] Setting up config file...
 Which directory do you want to upload to Google Drive?(default /home/thanh1/backup): /home/thanh1/backup2/backup
 How many days you want to keep backup on Google Drive?(default 7): 30
[ 15/11/2019 08:42:06 ] Setup config file successful

[ 15/11/2019 08:42:06 ] +-----
[ 15/11/2019 08:42:06 ] | SUCESSFUL! Your information:
[ 15/11/2019 08:42:06 ] | Backup dir      : /home/thanh1/backup2/backup
[ 15/11/2019 08:42:06 ] | Keep backup     : 30 days
[ 15/11/2019 08:42:06 ] | Config file     : /home/thanh1/.gdrive/butgg.conf
[ 15/11/2019 08:42:06 ] +-----

butgg.bash --setup credential (or butgg.sh --setup credential on BSD system) Only reset Google Drive token

Example
[thanh1@centos7 .gdrive]$ butgg.bash --setup credential
[ 15/11/2019 08:46:41 ] ---
[ 15/11/2019 08:46:41 ] 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=782896115405-qs2evi3rqlnkjm2vond8onilq9xxxxxx.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: 4/tQGSi4-XXBv3QMy8wAacJz-BARzzZM0wVZG0xtATTP3vG393axxxxxx
User: mbr other, [email protected]
Used: 
Free: 16.1 GB
Total: 16.1 GB
Max upload size: 5.2 TB
[ 15/11/2019 08:47:01 ] Setup gdrive credential successful

butgg.bash --setup only-build (or butgg.sh --setup only-build on BSD system) Only build gdrive bin

Example
[thanh1@centos7 .gdrive]$ butgg.bash --setup only-build
[ 15/11/2019 08:42:54 ] ---
[ 15/11/2019 08:42:54 ] Cheking network...
[ 15/11/2019 08:42:54 ] Connect Github successful
[ 15/11/2019 08:42:54 ] Connect Google successful
[ 15/11/2019 08:42:54 ] Checking OS...
[ 15/11/2019 08:42:54 ] OS supported
/usr/bin/git
[ 15/11/2019 08:42:54 ] 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  1209k      0  0:01:43  0:01:43 --:--:--  951k
[ 15/11/2019 08:44:37 ] Extracting go lang...
[ 15/11/2019 08:44:44 ] 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.06 KiB | 22.00 KiB/s, done.
Resolving deltas: 100% (873/873), done.
[ 15/11/2019 08:45:20 ] 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: 782896115405-qs2evi3rqlnkjm2vond8onilq9xxxxxx.apps.googleusercontent.com
 Your Google API client_secret: g7p_kcdNEq_ULsfxrTxxxxxx
[ 15/11/2019 08:45:34 ] Building gdrive...
[ 15/11/2019 08:45:36 ] Build gdrive successful. Gdrive bin locate here /home/thanh1/bin/gdrive

butgg.sh --setup no-build (or butgg.sh --setup no-build on BSD system) Setup butgg without build gdrive

Example
[thanh1@centos7 .gdrive]$ butgg.bash --setup no-build
[ 15/11/2019 08:53:15 ] ---
[ 15/11/2019 08:53:15 ] Cheking network...
[ 15/11/2019 08:53:15 ] Connect Github successful
[ 15/11/2019 08:53:15 ] Connect Google successful
[ 15/11/2019 08:53:15 ] Checking OS...
[ 15/11/2019 08:53:15 ] OS supported
[ 15/11/2019 08:53:15 ] 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  15030      0 --:--:-- --:--:-- --:--:-- 15048
[ 15/11/2019 08:53:16 ] Check md5sum for file cron_backup.bash successful
[ 15/11/2019 08:53:16 ] Downloading setup file from github...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13199  100 13199    0     0  34979      0 --:--:-- --:--:-- --:--:-- 35010
[ 15/11/2019 08:53:17 ] Check md5sum for file butgg.bash successful
[ 15/11/2019 08:53:17 ] Setting up gdrive credential...
User: mbr other, [email protected]
Used: 
Free: 16.1 GB
Total: 16.1 GB
Max upload size: 5.2 TB
[ 15/11/2019 08:53:17 ] Setup gdrive credential successful
[ 15/11/2019 08:53:17 ] Setting up config file...
 Which directory do you want to upload to Google Drive?(default /home/thanh1/backup): 
 How many days you want to keep backup on Google Drive?(default 7): 
[ 15/11/2019 08:53:25 ] Setup config file successful
[ 15/11/2019 08:53:25 ] Setting up cron backup...
[ 15/11/2019 08:53:25 ] Cron backup existed. Skip

[ 15/11/2019 08:53:25 ] +-----
[ 15/11/2019 08:53:25 ] | SUCESSFUL! Your information:
[ 15/11/2019 08:53:25 ] | Backup dir      : /home/thanh1/backup
[ 15/11/2019 08:53:25 ] | Config file     : /home/thanh1/.gdrive/butgg.conf
[ 15/11/2019 08:53:25 ] | Log file        : /home/thanh1/.gdrive/butgg.log
[ 15/11/2019 08:53:25 ] | Keep backup     : 7 days
[ 15/11/2019 08:53:25 ] | butgg.sh file   : /home/thanh1/bin/butgg.bash
[ 15/11/2019 08:53:25 ] | Cron backup file: /home/thanh1/bin/cron_backup.bash
[ 15/11/2019 08:53:25 ] | Gdrive bin file : /home/thanh1/bin/gdrive
[ 15/11/2019 08:53:25 ] | Cron backup     : 0 0 * * * bash /home/thanh1/bin/cron_backup.bash >/dev/null 2>&1
[ 15/11/2019 08:53:25 ] | Google token    : /home/thanh1/.gdrive/token_v2.json
[ 15/11/2019 08:53:25 ] +-----

 If you get trouble when use butgg.bash please report here:
 https://github.com/mbrother2/backuptogoogle/issues

butgg.sh --setup no-update (or butgg.sh --setup no-update on BSD system) Setup butgg without update script

Example
[thanh1@centos7 .gdrive]$ butgg.bash --setup no-update
[ 15/11/2019 08:54:20 ] ---
[ 15/11/2019 08:54:20 ] Cheking network...
[ 15/11/2019 08:54:20 ] Connect Github successful
[ 15/11/2019 08:54:20 ] Connect Google successful
[ 15/11/2019 08:54:20 ] Checking OS...
[ 15/11/2019 08:54:20 ] OS supported
/usr/bin/git
[ 15/11/2019 08:54:20 ] 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.9M
[ 15/11/2019 08:54:32 ] Extracting go lang...
[ 15/11/2019 08:54:37 ] 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.06 KiB | 343.00 KiB/s, done.
Resolving deltas: 100% (873/873), done.
[ 15/11/2019 08:54:41 ] 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: 782896115405-qs2evi3rqlnkjm2vond8onilq9xxxxxx.apps.googleusercontent.com
 Your Google API client_secret: g7p_kcdNEq_ULsfxrTxxxxxx
[ 15/11/2019 08:54:54 ] Building gdrive...
[ 15/11/2019 08:54:56 ] Build gdrive successful. Gdrive bin locate here /home/thanh1/bin/gdrive 
[ 15/11/2019 08:54:56 ] Setting up gdrive credential...
User: mbr other, [email protected]
Used: 
Free: 16.1 GB
Total: 16.1 GB
Max upload size: 5.2 TB
[ 15/11/2019 08:54:57 ] Setup gdrive credential successful
[ 15/11/2019 08:54:57 ] Setting up config file...
 Which directory do you want to upload to Google Drive?(default /home/thanh1/backup): 
 How many days you want to keep backup on Google Drive?(default 7): 
[ 15/11/2019 08:55:00 ] Setup config file successful
[ 15/11/2019 08:55:00 ] Setting up cron backup...
[ 15/11/2019 08:55:00 ] Cron backup existed. Skip

[ 15/11/2019 08:55:00 ] +-----
[ 15/11/2019 08:55:00 ] | SUCESSFUL! Your information:
[ 15/11/2019 08:55:00 ] | Backup dir      : /home/thanh1/backup
[ 15/11/2019 08:55:00 ] | Config file     : /home/thanh1/.gdrive/butgg.conf
[ 15/11/2019 08:55:00 ] | Log file        : /home/thanh1/.gdrive/butgg.log
[ 15/11/2019 08:55:00 ] | Keep backup     : 7 days
[ 15/11/2019 08:55:00 ] | butgg.sh file   : /home/thanh1/bin/butgg.bash
[ 15/11/2019 08:55:00 ] | Cron backup file: /home/thanh1/bin/cron_backup.bash
[ 15/11/2019 08:55:00 ] | Gdrive bin file : /home/thanh1/bin/gdrive
[ 15/11/2019 08:55:00 ] | Cron backup     : 0 0 * * * bash /home/thanh1/bin/cron_backup.bash >/dev/null 2>&1
[ 15/11/2019 08:55:00 ] | Google token    : /home/thanh1/.gdrive/token_v2.json
[ 15/11/2019 08:55:00 ] +-----

 If you get trouble when use butgg.bash please report here:
 https://github.com/mbrother2/backuptogoogle/issues
3. Update

butgg.sh --update (or butgg.sh --update on BSD system) Update to latest version

Example
[thanh1@centos7 .gdrive]$ butgg.bash --update
[ 15/11/2019 08:56:43 ] ---
[ 15/11/2019 08:56:43 ] Cheking network...
[ 15/11/2019 08:56:43 ] Connect Github successful
[ 15/11/2019 08:56:43 ] Connect Google successful
[ 15/11/2019 08:56:43 ] Checking OS...
[ 15/11/2019 08:56:43 ] OS supported
[ 15/11/2019 08:56:43 ] 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  14965      0 --:--:-- --:--:-- --:--:-- 14979
[ 15/11/2019 08:56:44 ] Check md5sum for file cron_backup.bash successful
[ 15/11/2019 08:56:44 ] Downloading setup file from github...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13199  100 13199    0     0  35969      0 --:--:-- --:--:-- --:--:-- 35964
[ 15/11/2019 08:56:45 ] Check md5sum for file butgg.bash successful
4. Uninstall

butgg.sh --uninstall (or butgg.sh --uninstall on BSD system) Remove all butgg scripts and .gdrive directory

Example
[thanh1@centos7 .gdrive]$ butgg.bash --uninstall
[ 15/11/2019 08:57:14 ] ---
[ 15/11/2019 08:57:14 ] Removing all butgg.bash scripts...
[ 15/11/2019 08:57:14 ] Remove all butgg.bash scripts successful
 Do you want remove /home/thanh1/.gdrive directory?(y/n) n
[ 15/11/2019 08:57:18 ] Skip remove /home/thanh1/.gdrive directory
5. Run upload to Google Drive immediately

cron_backup.bash (or cron_backup.sh on BSD system) Run upload to Google Drive immediately without show log cron_backup.bash -v (or cron_backup.sh -v on BSD system) Run upload to Google Drive immediately with show log detail

Example
[thanh1@centos7 ~]$ cron_backup.bash -v
[ 14/11/2019 10:58:54 ] ---
[ 14/11/2019 10:58:55 ] Start upload to Google Drive...
[ 14/11/2019 10:58:56 ] Directory 14_11_2019 existed. Skipping...
[ 14/11/2019 10:58:57 ] Uploading file /home/thanh1/backup2/backup/a.txt to directory 14_11_2019...
[ 14/11/2019 10:58:59 ] [UPLOAD] Uploaded file /home/thanh1/backup2/backup/a.txt to directory 14_11_2019
[ 14/11/2019 10:58:59 ] Uploading file /home/thanh1/backup2/backup/b.txt to directory 14_11_2019...
[ 14/11/2019 10:59:02 ] [UPLOAD] Uploaded file /home/thanh1/backup2/backup/b.txt to directory 14_11_2019
[ 14/11/2019 10:59:02 ] Uploading directory /home/thanh1/backup2/backup/thanh1 to directory 14_11_2019...
[ 14/11/2019 10:59:03 ] [UPLOAD] Uploaded directory /home/thanh1/backup2/backup/thanh1 to directory 14_11_2019
[ 14/11/2019 10:59:03 ] Uploading directory /home/thanh1/backup2/backup/thanh2 to directory 14_11_2019...
[ 14/11/2019 10:59:04 ] [UPLOAD] Uploaded directory /home/thanh1/backup2/backup/thanh2 to directory 14_11_2019
[ 14/11/2019 10:59:04 ] Finish! All files and directories in /home/thanh1/backup2/backup are uploaded to Google Drive in directory 14_11_2019
[ 14/11/2019 10:59:05 ] Directory 15_10_2019 does not exist. Nothing need remove!

Thank you for support!

If you like my script, please Buy me a coffee Buy me a coffee :)

backuptogoogle's People

Contributors

mbrother2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

backuptogoogle's Issues

Script for Windows version of the gdrive

Your OS version: Windows 10
Command: ``
Detail log:

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).

MD5SUM Does not Same

[ 13/12/2019 16:35:32 ] [CHECKS][FAIL] Can not verify md5 for file butgg.bash. Exit!

exclude folder path

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 ?

realpath: command not found

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)

Error when run sh butgg.sh --setup [: Ubuntu: unexpected operator

Your OS version: Ubuntu 16.04.6
Your issue: Error when run sh butgg.sh --setup
Detail log:
[ 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!

Cannot find Google folder ID

Your OS version: Ubuntu 18.04
Command: cron_backup.sh -v
Detail log:
[ 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?

image

New: First time use

Your OS version: ubuntu 16.04
Command: cron_backup.bash
Detail log:
  1. 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".

  2. How does the script know what to backup? must it be in /home/root/backup folder?

root@PBS08:/bin# ll
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:
/bin# sh cron_backup.bash
cron_backup.bash: 170: cron_backup.bash: Syntax error: "(" unexpected
root@PBS08:/bin# cron_backup.bash
cron_backup.bash: command not found
root@PBS08:
/bin#

Support for Debian Linux

Your OS version: Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64
Command: sh butgg.sh --setup
Detail log:
[ 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

Setup Error

[ 25/11/2019 13:00:12 ] [CHECKS][FAIL] Can not connect to Github file, please check your network. Exit

can't reset all script

Your OS version: CentOS Linux 7
Command: bash butgg.bash --setup
Detail log:
[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!

Error link request password for fist time

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:#
root@localhost:
# gdrive list
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

Token has been expired or revoked

Your OS version: SUSE Linux Enterprise 15?
Command: gdrive about?
Detail log:
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."

Google api down!!!

Your OS version: ALL OS version
Command: build gdrive or gdrive upload
Detail log:

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

Error creating gdrive

Your OS version: CentOS 7.9
Command: ./butgg.bash --setup only-build
Detail log:
[ 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

401 Unauthorized

Your OS version:debian9
Command: ``gdrive sync upload
Detail log:

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.