Tag

backup vps to Google Drive

Browsing

With vps data, you can use snapshot feature to backup all vps data but usually this’s a paid feature. Some of server provider don’t event have this feature. So to backup VPS you can use Rclone and move data to some of cloud storage such as: Google Drive, One Drive, Mega, Zoho storage…

Rclone is a command line program to manage files on cloud storage. It is a feature rich alternative to cloud vendors’ web storage interfaces. Over 40 cloud storage products support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols.

Rclone helps you:

  • Backup (and encrypt) files to cloud storage
  • Restore (and decrypt) files from cloud storage
  • Mirror cloud data to other cloud services or locally
  • Migrate data to cloud, or between cloud storage vendors
  • Mount multiple, encrypted, cached or diverse cloud storage as a disk
  • Analyse and account for data held on cloud storage using lsfljsonsizencdu
  • Union file systems together to present multiple local and/or cloud file systems as one

To install Rclone on Linux/Mac/BSD you can use this command:

curl https://rclone.org/install.sh | sudo bash

Below is some of popular commands of rclone

CommandDescription
rcloneShow help for rclone commands, flags and backends.
rclone cleanupClean up the remote if possible.
rclone configEnter an interactive configuration session.
rclone config createCreate a new remote with name, type and options.
rclone config deleteDelete an existing remote name.
rclone config disconnectDisconnects user from remote
rclone config dumpDump the config file as JSON.
rclone config editEnter an interactive configuration session.
rclone config fileShow path of configuration file in use.
rclone config passwordUpdate password in an existing remote.
rclone config providersList in JSON format all the providers and options.
rclone config reconnectRe-authenticates user with remote.
rclone config showPrint (decrypted) config file, or the config for a single remote.
rclone config updateUpdate options in an existing remote.
rclone config userinfoPrints info about logged in user of remote.
rclone copyCopy files from source to dest, skipping already copied.
rclone copytoCopy files from source to dest, skipping already copied.
rclone copyurlCopy url content to dest.
rclone cryptcheckCryptcheck checks the integrity of a crypted remote.
rclone cryptdecodeCryptdecode returns unencrypted file names.
rclone dedupeInteractively find duplicate filenames and delete/rename them.
rclone deleteRemove the files in path.
rclone deletefileRemove a single file from remote.
rclone genautocompleteOutput completion script for a given shell.
rclone genautocomplete bashOutput bash completion script for rclone.
rclone genautocomplete fishOutput fish completion script for rclone.
rclone genautocomplete zshOutput zsh completion script for rclone.
rclone gendocsOutput markdown docs for rclone to the directory supplied.
rclone hashsumProduces a hashsum file for all the objects in the path.
rclone linkGenerate public link to file/folder.
rclone listremotesList all the remotes in the config file.
rclone lsList the objects in the path with size and path.
rclone lsdList all directories/containers/buckets in the path.
rclone lsfList directories and objects in remote:path formatted for parsing.
rclone lsjsonList directories and objects in the path in JSON format.
rclone lslList the objects in path with modification time, size and path.
rclone md5sumProduces an md5sum file for all the objects in the path.
rclone mkdirMake the path if it doesn’t already exist.
rclone mountMount the remote as file system on a mountpoint.
rclone moveMove files from source to dest.
rclone movetoMove file or directory from source to dest.
rclone ncduExplore a remote with a text based user interface.
rclone obscureObscure password for use in the rclone config file.
rclone purgeRemove the path and all of its contents.
rclone rcRun a command against a running rclone.
rclone rcatCopies standard input to file on remote.
rclone rcdRun rclone listening to remote control commands only.
rclone rmdirRemove the empty directory at path.
rclone rmdirsRemove empty directories under the path.
rclone selfupdateUpdate the rclone binary.
rclone serveServe a remote over a protocol.
rclone serve dlnaServe remote:path over DLNA
rclone serve ftpServe remote:path over FTP.
rclone serve httpServe the remote over HTTP.
rclone serve resticServe the remote for restic’s REST API.
rclone serve sftpServe the remote over SFTP.
rclone serve webdavServe remote:path over webdav.
rclone settierChanges storage class/tier of objects in remote.
rclone sha1sumProduces an sha1sum file for all the objects in the path.
rclone sizePrints the total size and number of objects in remote:path.
rclone syncMake source and dest identical, modifying destination only.
rclone testRun a test command
rclone cheat sheet

Here is an overview of the major features of each cloud storage system Rclone supports.

NameHashModTimeCase InsensitiveDuplicate FilesMIME Type
1FichierWhirlpoolNoNoYesR
Amazon DriveMD5NoYesNoR
Amazon S3MD5YesNoNoR/W
Backblaze B2SHA1YesNoNoR/W
BoxSHA1YesYesNo
Citrix ShareFileMD5YesYesNo
DropboxDBHASH ¹YesYesNo
Enterprise File FabricYesYesNoR/W
FTPNoNoNo
Google Cloud StorageMD5YesNoNoR/W
Google DriveMD5YesNoYesR/W
Google PhotosNoNoYesR
HDFSYesNoNo
HTTPNoNoNoR
HubicMD5YesNoNoR/W
JottacloudMD5YesYesNoR
KoofrMD5NoYesNo
Mail.ru CloudMailru YesYesNo
MegaNoNoYes
MemoryMD5YesNoNo
Microsoft Azure Blob StorageMD5YesNoNoR/W
Microsoft OneDriveSHA1YesYesNoR
OpenDriveMD5YesYesPartial
OpenStack SwiftMD5YesNoNoR/W
pCloudMD5, SHA1YesNoNoW
premiumize.meNoYesNoR
put.ioCRC-32YesNoYesR
QingStorMD5NoNoNoR/W
SeafileNoNoNo
SFTPMD5, SHA1YesDependsNo
SugarSyncNoNoNo
TardigradeYesNoNo
WebDAVMD5, SHA1 Yes DependsNo
Yandex DiskMD5YesNoNoR
Zoho WorkDriveNoNoNo
The local filesystemAllYesDependsNo

Backup vps data to Google Drive

After installed Rclone you type

[root@racknerd racknerd]# rclone config
Current remotes:

Name                 Type
====                 ====

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> n
name> learncode24h_com
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / 1Fichier
   \ "fichier"
 2 / Alias for an existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, and Tencent COS
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Citrix Sharefile
   \ "sharefile"
 9 / Compress a remote
   \ "compress"
10 / Dropbox
   \ "dropbox"
11 / Encrypt/Decrypt a remote
   \ "crypt"
12 / Enterprise File Fabric
   \ "filefabric"
13 / FTP Connection
   \ "ftp"
14 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
15 / Google Drive
   \ "drive"
16 / Google Photos
   \ "google photos"
17 / Hadoop distributed file system
   \ "hdfs"
18 / Hubic
   \ "hubic"
19 / In memory object storage system.
   \ "memory"
20 / Jottacloud
   \ "jottacloud"
21 / Koofr
   \ "koofr"
22 / Local Disk
   \ "local"
23 / Mail.ru Cloud
   \ "mailru"
24 / Mega
   \ "mega"
25 / Microsoft Azure Blob Storage
   \ "azureblob"
26 / Microsoft OneDrive
   \ "onedrive"
27 / OpenDrive
   \ "opendrive"
28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
29 / Pcloud
   \ "pcloud"
30 / Put.io
   \ "putio"
31 / QingCloud Object Storage
   \ "qingstor"
32 / SSH/SFTP Connection
   \ "sftp"
33 / Sugarsync
   \ "sugarsync"
34 / Tardigrade Decentralized Cloud Storage
   \ "tardigrade"
35 / Transparently chunk/split large files
   \ "chunker"
36 / Union merges the contents of several upstream fs
   \ "union"
37 / Webdav
   \ "webdav"
38 / Yandex Disk
   \ "yandex"
39 / Zoho
   \ "zoho"
40 / http Connection
   \ "http"
41 / premiumize.me
   \ "premiumizeme"
42 / seafile
   \ "seafile"
Storage> 15
** See help for drive backend at: https://rclone.org/drive/ **

Google Application Client Id
Setting your own is recommended.
See https://rclone.org/drive/#making-your-own-client-id for how to create your own.
If you leave this blank, it will use an internal key which is low performance.
Enter a string value. Press Enter for the default ("").
client_id>
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
Scope that rclone should use when requesting access from drive.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
rclone configy/n> n
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> n
Please go to the following link: https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=11111111.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=****************
Log in and authorize rclone for access
Enter verification code> ******************************************
Configure this as a Shared Drive (Team Drive)?
y) Yes
n) No (default)
y/n> n
--------------------
[learncode24h_com]
type = drive
scope = drive
token = {"access_token":"************","token_type":"Bearer","refresh_token":"**********","expiry":"2021-04-21T11:40:40.21300654+07:00"}
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name                 Type
====                 ====
ducquyen_dev         drive
leducquyen_it        drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q

You access generated link by Rclone to grant permission read/write for Rclone and get access token then enter it in terminal like this

That’s all with Rclone. After backup data you type rclone copy to push file to cloud storage

rclone copy /home/backup.tar.gz learcode24h_com:backup_folder
  • learncode24h_com is my remote name configured for my Google Drive
  • backup_folder is folder contains backup data on my Google Drive

For deleting old backup data you can use this command:

rclone -q --min-age 1w delete learncode24h_com:backup_folder #Remove all backups older than 1 week