Article directory
- What does WordPress mean?What are you doing?What can a website do?
- How much does it cost to build a personal/company website?Cost of building a business website
- How to choose the right domain name?Website Construction Domain Name Registration Recommendations & Principles
- NameSiloDomain Name Registration Tutorial (Send you $1 NameSiloPromo Code)
- What software is needed to build a website?What are the requirements for making your own website?
- NameSiloResolve Domain Name NS to Bluehost/SiteGround Tutorial
- How to manually build WordPress? WordPress Installation Tutorial
- How to log in to the WordPress backend? WP background login address
- How to use WordPress? WordPress background general settings & Chinese Title
- How to change language settings in WordPress?Change Chinese/English setting method
- How to Create a WordPress Category Directory? WP Category Management
- How does WordPress publish articles?Editing options for self-published articles
- How to create a new page in WordPress?Add/edit page setup
- How does WordPress add menus?Customize navigation bar display options
- What is a WordPress theme?How to install WordPress templates?
- FTP how to decompress zip files online? PHP online decompression program download
- FTP tool connection timeout failed How to configure WordPress to connect to the server?
- How to install a WordPress plugin? 3 Ways to Install a WordPress Plugin - wikiHow
- How about BlueHost hosting?Latest BlueHost USA Promo Codes/Coupons
- How does Bluehost automatically install WordPress with one click? BH website building tutorial
- How to use VPScloneBackup?CentOSAutomatic Sync Tutorial with GDrive
due toWeb PromotionThe most efficient method inSEO, so many people with rich SEO experienceInternet marketingPeople will choose to buy a VPS (Virtual Private Server) to build a website.
Since VPS is used, it is necessary to backup the VPS. The VPS backup can be synchronized to the GDrive network disk with rclone backup.
What is rclone?
RClone can easily and conveniently manage network disks such as Google Drive and Dropbox, and supports mount drive letters and command line upload and download:
- Mounting disk, easy to use, but slow, more suitable for small and fragmented files
- Command line upload and download is very fast, suitable for uploading large files
- Rclone is less prone to interruption problems than Google Drive AP, and compared to the [gdrive] project on github.
Let's share the method of installing rclone backup on CentOS and syncing it to Google Drive.
How to backup VPS with rclone?
Here are the tools that need to be prepared:
- Google Dirve account
- an rclone file
- OneLinuxMachine (this article takes CentOS7 as an example)
Then start to install rclone, the installation is very simple, copy and paste plus permissions.
Step 1:Download file ▼
yum install unzip wget -y wget https://downloads.rclone.org/rclone-current-linux-amd64.zip unzip rclone-current-linux-amd64.zip cd rclone-*-linux-amd64
Step 2:Copy the file to the relevant path ▼
cp rclone /usr/bin/ chown root:root /usr/bin/rclone chmod 755 /usr/bin/rclone
- (This step can be omitted, but it is not recommended. After omission, there will be no prompt, so it is not recommended to omit)
Step 3:Installation help page▼
mkdir -P /usr/local/share/man/man1 cp rclone.1 /usr/local/share/man/man1/ mandb
Step 4:Create a new configuration ▼
rclone config
Step 5:rclone configuration
It is recommended to use Rclone to mount the Google team shared cloud disk for remote synchronization ▼
The following is an example reference of rclone binding Google Dirve network disk (non-team disk) ▼
n) New remote d) Delete remote q) Quit config e/n/d/q> n name> gdrive(你的配置名称,此处随意填写但之后需要用到) Type of storage to configure. Choose a number from below, or type in your own value 1 / Amazon Drive \ "amazon cloud drive" 2 / Amazon S3 (also Dreamhost, Ceph, Minio) \ "s3" 3 / Backblaze B2 \ "b2" 4 / Dropbox \ "dropbox" 5 / Encrypt/Decrypt a remote \ "crypt" 6 / Google Cloud Storage (this is not Google Drive) \ "google cloud storage" 7 / Google Drive \ "drive" 8 / Hubic \ "hubic" 9 / Local Disk \ "local" 10 / Microsoft OneDrive \ "onedrive" 11 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ "swift" 12 / SSH/SFTP Connection \ "sftp" 13 / Yandex Disk \ "yandex" Storage> 7(请根据网盘类型选择Google Dirve) Google Application Client Id - leave blank normally. client_id>此处留空 Google Application Client Secret - leave blank normally. client_secret>此处留空 Edit advanced config? (y/n) y) Yes n) No y/n> 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 n) No y/n> n(此处一定要选择n) Option config_token. For this to work, you will need rclone available on a machine that has a web browser available. For more help and alternate methods see: https://rclone.org/remote_setup/ Execute the following on the machine with the web browser (same rclone version recommended): rclone authorize "drive" "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" Then paste the result. Enter a value. config_token>
The "config_token" here needs to be obtained by downloading and installing Rclone on the local computer first▼
Take Windows as an example, go to the folder where rclone.exe is located after decompression, enter cmd in the address bar of the explorer and press Enter to open the command prompt in the current path.
Configure by copying configuration files
Rclone stores all its configuration in a configuration file, which makes it easy to copy configuration files to remote Rclone.
So, first you need to configure Rclone on your desktop computer ▼
rclone config
on computerrclone
configuration, there is a problemUse auto config?
when, answerY
.
Edit advanced config? y) Yes n) No (default) y/n> n 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> y NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=oAg82wp7fFgAxvIIo59kxA NOTICE: Log in and authorize rclone for access NOTICE: Waiting for code... NOTICE: Got code
A browser will pop up next, asking you to log in to your account to authorize it.
How to authorize a Google account?
- If you are in mainland China, first you have to bypass the X wall, then you need to have a Google account and log in.
- If "This app has not been verified by Google" appears, click "Advanced".
- Then, click Allow to authorize.
Do you configure Google Teams to share cloud disks?
If you do not use the Google team shared cloud disk, choosen
▼
Configure this as a team drive? y) Yes n) No (default) y/n> n
Verify remote configuration information
Finally, verify the parameters of the remote configuration, and confirm by typingyOK▼
-------------------- [gdrive] type = drive token = {"access_token":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} team_drive = -------------------- y) Yes this is OK (default) e) Edit this remote d) Delete this remote y/e/d> y
It will display the romete list saved on the current machine, just take a look, pressqexit ▼
Current remotes:
Name Type
==== ====
gdrive drive
onedrive onedrive
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
- At this point, the rclone configuration of the local computer is completed.
After the local computer is configured, directly set the local computerrclone.conf
The content in the configuration file is copied to the Linux serverrclone.conf
configuration file.
On the local computer and the server, enter the following commands toView Rclone configuration file location command▼
rclone config file
Query the Rclone configuration file, and the obtained results are as follows▼
rclone config file Configuration file is stored at: /root/.config/rclone/rclone.conf
- Just put the local computer's configuration file
rclone.conf
copy the contents to the Linux serverrclone.conf
Configuration file, you can solve the Rclone configuration problem.
rclone use command example
List files and directories command
List the directory where the network disk named gdrive is configured (files will not be displayed)▼
rclone lsd gdrive:
List the files in the backup directory in the network disk with the configuration name gdrive (all files including subdirectories will be displayed, but the directory will not be displayed) ▼
rclone ls gdrive:backup
Copy Cut Delete Command
Copy the Rclone configuration file to the root directory of the gdrive network disk ▼
rclone copy /root/.config/rclone/rclone.conf gdrive:/
copy local /home/backup
Go to the backup directory where the network disk named gdrive is configured, and vice versa ▼
rclone copy --progress /home/backup gdrive:backup
- by adding this parameter
--ignore-existing
Files that have been backed up on the network disk can be ignored, which is equivalent to incremental backup ▼
rclone copy --ignore-existing /home/backup gdrive:backup
Copy the local CWP manual backup file to the backup directory of the network disk named gdrive, and vice versa ▼
rclone copy --progress /newbackup/full/manual/accounts/eloha.tar.gz gdrive:cwp-newbackup/full/manual/accounts/
From the gdrive network disk, copy the CWP automatic scheduled backup file to the local /newbackup
Catalog▼
rclone copy --progress gdrive:cwp-newbackup/full/daily/Friday/accounts/eloha.tar.gz /newbackup/ rclone copy --progress gdrive:cwp-backup2/ /home/backup2/
From the gdrive network disk, copy the CWP manual backup file to the local /newbackup/full/manual/accounts/
Catalog▼
rclone copy --progress gdrive:cwp-newbackup/full/manual/accounts/eloha.tar.gz /newbackup/full/manual/accounts/
From gdrive's network disk, copyVestaCPBackup files to local /home/backup
Catalog▼
rclone copy --progress gdrive:backup/admin.2018-04-12_13-10-02.tar /home/backup
Move (Cut) Command ▼
rclone move /home/backup gdrive:backup
Delete the backup directory of the network disk with the configuration name gdrive▼
rclone delete gdrive:backup
Create a backup directory that configures a network disk named gdrive ▼
rclone mkdir gdrive:backup
sync file command
Synchronize the local /home/backup to the backup directory in the network disk with the configuration name gdrive, and vice versa ▼
rclone sync /home/backup gdrive:backup
Synchronize the configuration name gdrive2 in the network diskUFOdirectory, to the backup directory where the network disk named gdrive is configured, and vice versa ▼
rclone sync gdrive2:ufo gdrive:backup
After a while, if no error message is returned, you can see the backup file on the network disk after the backup is completed.
How to automatically sync VPS backup files to GDrive?
In timed tasks, add synchronization commands to achieve automatic synchronizationCWP Control Panelbackup files to GDrive.
- (Automatically sync local directory at 2 am every day
/newbackup
to config namegdrive
in the network diskcwp-newbackup
Table of contents)
SSH how to add crontab Scheduled tasks automatically sync to GDrive?
First, SSH into the following crontab command▼
crontab -e
Next, add the command to the last line▼
00 7 * * * rclone sync /backup2 gdrive:cwp-backup2 55 7 * * * rclone sync /newbackup gdrive:cwp-newbackup
- SSH, press CTRL + C, then enter
:wq
Save and exit.
Delete remote files 50 days or older (delete files older than 50 days)▼
rclone delete koofr:ETUFO.ORG --min-age 50d
Delete remote files for 50 days or less (delete files within 50 days) ▼
rclone delete koofr:ETUFO.ORG --max-age 50d
How to set the Crontab timed task to automatically sync to GDrive in the CWP control panel?
If using the CWP Control Panel, log in to the CWP Control Panel's Server Setting
→ Crontab for root
▼
In "Add Full Custom Cron Jobs", enter the following fully custom cron command ▼
00 7 * * * rclone sync /backup2 gdrive:cwp-backup2 55 7 * * * rclone sync /newbackup gdrive:cwp-newbackup
- (Automatically sync local directory every morning at 7:00 am
/backup2
to the network disk with the configuration name gdrivebackup2
Table of contents) - (Automatically sync local directory every morning at 7:55 am
/newbackup
to the network disk with the configuration name gdrivecwp-newbackup
Table of contents) - SynchronizeWordPressFor website files, it is recommended not to back up incrementally, because the test found that if the file names are the same, but the contents of the files are different, they will not be synchronized.
After the automatic synchronization of rclone is started regularly, the rclone process will still run in the background, which may occupy up to 20% of the CPU resources, resulting in a waste of server resources.
Therefore, it is necessary to add a fully customized scheduled task command to force the rclone process to close ▼
00 09 * * * killall rclone
- (Automatically forcibly close the rclone process at 9:00 every morning)
Copy the specified local directory to the configuration name at 4:0 a.m. every daykoofr
in the network diskETUFO.ORG
Catalog▼
0 4 * * * rclone copy /home/eloha/public_html/img.etufo.org/backwpup-xxxxx-backups/ koofr:ETUFO.ORG -P
Delete remote files 4 days or older at 50:50 am every day (delete files older than 50 days)▼
50 4 * * * rclone delete koofr:ETUFO.ORG --min-age 50d
This cron command is to delete the file named "koofr:ETUFO.ORG
"In the target, all files and folders whose last modification time was 50 days ago, the following is an explanation of each part:
- The first number "50" means to execute the command every 50 minutes.
- The second number "4" means to execute the command at 4 am.
- "* * *" means the command will be executed on all days of the month, day and week.
- "rclone delete" means to execute the delete operation of the rclone tool.
- "koofr:ETUFO.ORG" is the name of the target to delete.
- "--min-age 50d" means only delete files and folders whose last modification time is 50 days ago.
Common commands of rclone
Of course, rclone is much more than that, and some common commands are listed below.
Copy ▼
rclone copy
move ▼
rclone move
delete ▼
rclone delete
Sync ▼
rclone sync
Additional parameters: display real-time speed ▼
-P
Additional parameters: limit speed 40MB ▼
--bwlimit 40M
Additional parameter: number of parallel files ▼
--transfers=N
start rclone ▼
systemctl start rclone
stop rclone ▼
systemctl stop rclone
View rclone status ▼
systemctl status rclone
View Profile Location ▼
rclone config file
It is really easy to use Rclone to automatically synchronize backup VPS ^_^
At this point, the tutorial on how to sync a local Linux directory to Google Drive is complete.
Extended reading:
Hope Chen Weiliang Blog ( https://www.chenweiliang.com/ ) shared "How to use rclone backup for VPS? CentOS uses GDrive automatic synchronization tutorial" to help you.
Welcome to share the link of this article:https://www.chenweiliang.com/cwl-694.html
Welcome to the Telegram channel of Chen Weiliang's blog to get the latest updates!
📚 This guide contains huge value, 🌟This is a rare opportunity, don’t miss it! ⏰⌛💨
Share and like if you like!
Your sharing and likes are our continuous motivation!