How to upload a file to Google Drive from the command line friend.com.vn

I’ve been looking at several linux projects here recently, such as LibreNMS, and you’ll need to be sure you are backing them up. I wanted to quickly backup a compressed copy of my LibreNMS install and so I went looking for a super easy way to upload a file to Google Drive, and I found it with gdrive.

gdrive, not to be mistaken for Google Drive itself, is a command line tool by Petter Rasmussen for Linux, Windows and OSX. Just what I needed. It’s proved itself so useful that I can’t imagine how I lived without it.

Linux

  1. SSH on to your linux box and download the Linux version of gdrive from GitHub. cd ~ wget friend.com.vn/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&export=download 12 cd ~wget friend.com.vn/uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE&export=download
  2. You should see a file in your home directory called something list uc=0B3X9GlR6EmbnWksyTEtCM0VfaFE. Rename this file to gdrive. mv uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive 1 mv uc?id=0B3X9GlR6EmbnWksyTEtCM0VfaFE gdrive
  3. Assign this file executable rights. chmod +x gdrive 1 chmod +x gdrive
  4. Install the file to your usr folder. sudo install gdrive /usr/local/bin/gdrive 1 sudo install gdrive /usr/local/bin/gdrive
  5. You’ll need to tell Google Drive to allow this program to connect to your account. To do this, run the gdrive program with any parameter and copy the text it gives you to your browser. Then paste in to your SSH window the response code that Google gives friend.com.vn the following. gdrive list 1 gdrive list 2016-03-18-16_44_23-olly@ollys-backup-server_-_backups_sql
  6. YOU ARE DONE! Now you can upload files as required. gdrive upload friend.com.vn 1 gdrive upload friend.com.vn

Windows

  1. Download the Windows version of gdrive from github.
  2. Copy the friend.com.vn file to your c:windows folder copy downloadsfriend.com.vn c:windows 1 copy downloadsfriend.com.vn c:windows
  3. Run gdrive with a parameter to get the Google authentication code and then copy that to a browser windows. Paste back the verification code. 2016-03-18-16_58_22-C__Windows_system32_cmd.exe-gdrive-windows-x64-list
  4. Now upload a file. WOOOT! friend.com.vn upload c:testfriend.com.vn 1 friend.com.vn upload c:testfriend.com.vn

Common Switches

GDrive supports a load of useful features which you should take a look at. The follow are grabbed from the gDrive page at friend.com.vn.

Upload file or directory

MS DOS gdrive [global] upload [options] <path> global: -c, -config <configDir> Application path, default: /Users/<user>/.gdrive -refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) -access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) options: -r, -recursive Upload directory recursively -p, -parent <parent> Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents -name <name> Filename -no-progress Hide progress -mime <mime> Force mime type -share Share file -delete Delete local file when upload is successful -chunksize <chunksize> Set chunk size in bytes, default: 8388608 12345678910111213141516 gdrive [global] upload [options] <path> global: -c, -config <configDir> Application path, default: /Users/<user>/.gdrive -refresh-token <refreshToken> Oauth refresh token used to get access token (for advanced users) -access-token <accessToken> Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) options: -r, -recursive Upload directory recursively -p, -parent <parent> Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents -name <name> Filename -no-progress Hide progress -mime <mime> Force mime type -share Share file -delete Delete local file when upload is successful -chunksize <chunksize> Set chunk size in bytes, default: 8388608

Download file or directory

MS DOS gdrive [global] download [options] global: -c, -config Application path, default: /Users//.gdrive -refresh-token Oauth refresh token used to get access token (for advanced users) -access-token Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) options: -f, -force Overwrite existing file -r, -recursive Download directory recursively, documents will be skipped -path Download path -delete Delete remote file when download is successful -no-progress Hide progress -stdout Write file content to stdout 1234567891011121314 gdrive [global] download [options] global: -c, -config Application path, default: /Users//.gdrive -refresh-token Oauth refresh token used to get access token (for advanced users) -access-token Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) options: -f, -force Overwrite existing file -r, -recursive Download directory recursively, documents will be skipped -path Download path -delete Delete remote file when download is successful -no-progress Hide progress -stdout Write file content to stdout

List files

MS DOS gdrive [global] list [options] global: -c, -config Application path, default: /Users//.gdrive -refresh-token Oauth refresh token used to get access token (for advanced users) -access-token Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) options: -m, -max Max files to list, default: 30 -q, -query Default query: “trashed = false and ‘me’ in owners”. See friend.com.vn/drive/search-parameters -order Sort order. See friend.com.vn/google.golang.org/api/drive/v3#FilesListCall.OrderBy -name-width Width of name column, default: 40, minimum: 9, use 0 for full width -absolute Show absolute path to file (will only show path from first parent) -no-header Dont print the header -bytes Size in bytes 123456789101112131415 gdrive [global] list [options] global: -c, -config Application path, default: /Users//.gdrive -refresh-token Oauth refresh token used to get access token (for advanced users) -access-token Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) options: -m, -max Max files to list, default: 30 -q, -query Default query: “trashed = false and ‘me’ in owners”. See friend.com.vn/drive/search-parameters -order Sort order. See friend.com.vn/google.golang.org/api/drive/v3#FilesListCall.OrderBy -name-width Width of name column, default: 40, minimum: 9, use 0 for full width -absolute Show absolute path to file (will only show path from first parent) -no-header Dont print the header -bytes Size in bytes

Share file or directory

MS DOS gdrive [global] share [options] global: -c, -config Application path, default: /Users//.gdrive -refresh-token Oauth refresh token used to get access token (for advanced users) -access-token Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) options: -role Share role: owner/writer/commenter/reader, default: reader -type Share type: user/group/domain/anyone, default: anyone -email The email address of the user or group to share the file with. Requires ‘user’ or ‘group’ as type -discoverable Make file discoverable by search engines -revoke Delete all sharing permissions (owner roles will be skipped) 12345678910111213 gdrive [global] share [options] global: -c, -config Application path, default: /Users//.gdrive -refresh-token Oauth refresh token used to get access token (for advanced users) -access-token Oauth access token, only recommended for short-lived requests because of short lifetime (for advanced users) options: -role Share role: owner/writer/commenter/reader, default: reader -type Share type: user/group/domain/anyone, default: anyone -email The email address of the user or group to share the file with. Requires ‘user’ or ‘group’ as type -discoverable Make file discoverable by search engines -revoke Delete all sharing permissions (owner roles will be skipped)

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *