Instructions to backup data to Google Drive on CentOS operating system

73 Likes 1 Comment
Screenshot_3

2K- FB – News Instructions to backup data to Google Drive on CentOS operating system

wget -O drive https://drive.google.com/uc?id=0B3X9GlR6EmbnMHBMVWtKaEZXdDg  
mv drive /usr/sbin/drive  
chmod 755 /usr/sbin/drive

If you get an error

wget: command not found

then you install wget with the following command

yum install wget -y

2). Execute the file gdrive and get the token of the Gmail account

You just need to type drive , the file will return the path as \

https://accounts.google.com/o/oauth2/auth?client_id=123456789123-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=%3&response_type=% 2Fwww.googleapis.com%2Fauth%2Fdrive&state=state 

Open a browser and copy the above link into the address bar, and log in with your google drive account.

You will receive a token after confirming the permission to interact with the Google Drive service

Copy the token to the SSH window

Enter verification code: 4/9gKYAFAJ326XIP6JJHAEhs342t35LPiA5QGW0935GHWHy9

So you are done allowing VPS to connect to your Google Drive account

3). Create the upload script as follows:

nano /root/autobackup.sh

 Copy the following content

#!/bin/bash
LOCALFOLDER=/backup
GFOLDERID=0B5I8-U7RcQGieF9rYmNudkkwQWM
for i in $(ls $LOCALFOLDER)
do
drive  upload --file /backup/$i -p $GFOLDERID
done

Inside

LOCALFOLDER is the location of the folder where your backup files are located

GFOLDERID is the ID of the folder that will store your backup files

3.a) How to get Google Drive Folder ID

– Sign in to your google drive account, and create folder

– After creating the folder, double click on the folder to open the folder. Now on the address bar will be your Google Drive Folder ID, copy Google Drive Folder ID to the script file

*** After completing the declarations, press the following keys ” Ctrl + X “,  Y  ,  [Enter]  in turn to save the executable file

4), Schedule automatic backup by typing the following command into the SSH window

echo "0 4 */6 * * sh /root/autobackup.sh" >> /etc/crontab

This command will execute the backup file every 6 days at 4am.


Bình Luận - Comment

You might like

About the Author: admin

1 Comment

  1. Good day! I just wish to give you a huge thumbs up for your excellent information you have got here on this post. I am coming back to your blog for more soon. Good day! I just wish to give you a huge thumbs up for your excellent information you have got here on this post. I am coming back to your blog for more soon.

Leave a Reply

Your email address will not be published.