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

HostBastic: £0.99/month/256MB RAM/5GB HDD/500GB bandwidth/KVM/OVH Canada

HostBastic, a British hosting provider, is a form...

simplecloud: $3.6/month/1GB RAM/20GB SSD/unlimited traffic/KVM/Russia

simplecloud.ru, a Russian hosting provider, has i...

Server Viking: £4/month/2GB memory/200GB space/2TB bandwidth/KVM/UK

Server Viking, a British hosting provider, a form...

Optimizing OpenVZ VPS using BBR acceleration

The recommended operating systems are Debian 8 64...

Share the process of Aiba Blog joining Baidu Encyclopedia

I applied for Baidu Encyclopedia a few days ago a...

DataWagon: $9/month/1GB RAM/20GB storage/unlimited traffic/OpenVZ/New York

DataWagon, a US hosting provider, has its own ASN...