Gdrive: Sync Google Drive files and automatically backup websites to Google Drive under Linux

Gdrive: Sync Google Drive files and automatically backup websites to Google Drive under Linux

Gdrive is a CLI tool for uploading and downloading Google Drive files under Linux. It is easy to install and use.

1. Install Gdrive : (SSH, based on centos 7)
1. Installation

 wget -O /usr/bin/gdrive "https://docs.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA&export=download" chmod +x /usr/bin/gdrive

2. Authorization

 gdrive about

Then a URL will appear and ask for a verification code.

Paste the address into the browser and log in to your account, and a string of codes will be returned.

Paste the code into SSH and your account information will be returned

The gdrive program will automatically save your token in the .gdrive directory under the user directory, so remember to delete this file if you don’t need it anymore.

2. Use <br />The common commands are as follows, please visit the gdrive official website for more information; gdrive
List files and folders in the root directory of Google Drive

 gdrive list

Download the file in the root directory of Google Drive to your local computer (xxxx is the file name)

 gdrive download xxxx

Download the folder in the root directory of Google Drive to your local computer (xxx is the folder name)

 gdrive download xxx

Upload the local file to the root directory of Google Drive (xxxx is the file name)

 gdrive upload xxxx

Create a folder in the root directory of Google Drive (xxx is the folder name)

 gdrive mkdir xxx

3. Create a script to automatically backup your website and upload files to Google Drive
1. Website automatic backup script (based on MySQL database)
Script download : googledrive.sh
Modify the following sections:
Line 3: Change my-database-name to your own database name Line 4: Change my-database-user to your own database username Line 5: Change my-database-password to the password corresponding to your own database username Line 7: Change zhujiwiki to your own website directory Line 8: Change /home/wwwroot to the directory where your own website is located (that is, the backup directory needs to be /home/wwwroot/zhujiwiki)
Line 9: /backups is changed to the backup file storage directory Line 35: [email protected] is changed to your own email address

2. Change permissions

 chmod +x googledrive.sh

3. Create a scheduled task

 vi /etc/crontab

Add to

 0 2 * * * /backups/googledrive.sh

The above backup script is stored in /backups/, and the backup is restarted at 2 o'clock every day.

 /etc/init.d/crond restart

4. Application <br />With the help of the following blog post, you can make more rational use of resources.
Use Tumblr crawler, combine with h5ai to create private video library, picture library Use VPS to create Tumblr analysis station
VPS installation of Nextcloud, sharing of Google Drive, BT download

<<:  KrakenServers: $3.5/month/1GB memory/45GB space/1TB traffic/KVM/Los Angeles

>>:  Cloudxtiny: £3/year/96MB RAM/5GB storage/200GB bandwidth/OpenVZ/Germany

Recommend

EH VPS: $5/month/1 core/1GB memory/50GB space/unlimited traffic/1 IP/KVM

EH VPS is an American hosting company founded in ...

$6/month/1.5G space/75G traffic/independent IP virtual host: ReliableHosting

ReliableHosting is a long-established hosting com...

Cloudhards: $13.5/year/1 core/128M/7G/250G/OpenVZ

cloudshards(Query Foundry, LLC)是一家成立于2012年的澳大利亞主機...

vpshosting: $7/year/512MB/10GB SSD/VMware/Canada/Windows

vps-hosting is a Canadian hosting provider, and i...

LeaseWeb: $2.97/month/1GB memory/40GB space/4TB traffic/KVM/Singapore/San Jose

LeaseWeb, a Dutch hosting provider, was founded i...

Hostodo: $4.99/month/1GB memory/30GB space/1.5TB traffic/KVM/Los Angeles

Hostodo's latest offer continues with kvm and...