Tutorial of backup synchronization artifact Rclone
summary
function
-
Backup (and encrypt) files to cloud storage -
Recover (and decrypt) files from cloud storage -
Mirror cloud data to other cloud services or local -
Migrate data to the cloud or among cloud storage providers -
Mount multiple, encrypted, cached or diversified cloud storage as disks -
Use lsf, ljson, size, and ncdu to analyze and describe the data saved on cloud storage -
Federated file systems present multiple local and/or cloud file systems together as one
characteristic
Transfer service -
Always check MD5, SHA1 hash values to ensure file integrity -
Timestamp remains in file -
Operation can be restarted at any time -
You can access the network, for example, two different cloud providers -
You can use multithreading to download to the local disk
-
-
Copy new or changed files to cloud storage -
Synchronize (one way) to make the directory the same -
Move files to cloud storage after verification Delete local -
Check hash and missing/extra files -
Mount your cloud storage as a network disk -
Local or remote files via HTTP/WebDav/FTP/SFTP/DLNA services -
Experimental web-based GUI
use
install
curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip unzip rclone-current-linux-amd64.zip cd rclone-*-linux-amd64 sudo cp rclone /usr/bin/ sudo chown root:root /usr/bin/rclone sudo chmod 755 /usr/bin/rclone
to configure
[tencent cos] # Custom name Type=s3 # Storage type, refer to all supported types in official documents Provider=TencentCOS # provider, refer to official documents or all Env_auth=false # Do not pass the environment variable configuration authentication Access_key_id=AKxxxxxxxx # Key key generated by Tencent Cloud background Secret_access_key=Secretxxxxxxx # The secret key generated in the background of Tencent Cloud Endpoint=cos. ap chengdu. myqcloud. com # Look at the public network address of your bucket in the region where Tencent Cloud cos is located
grammar
#Local to network disk Rclone [Function Options]<Local Path><Configuration Name: Path>[Parameters] [Parameters] #Network disk to local Rclone [Function Options]<Configuration Name: Path><Local Path>[Parameters] [Parameters] #Online disk to online disk Rclone [Function Options]<Configuration Name: Path><Configuration Name: Path>[Parameters] [Parameters] #[Parameter] is optional
#Synchronize the contents of the local/data/file folder to the/beifen folder under the tencent cos storage, and exclude the file contents specified in/root/excludes.txt rclone sync /data/file tencent-cos:/beifen --exclude-from '/root/excludes.txt' #File synchronization of two network disks Rclone copy configuration network disk name 1: network disk path configuration network disk name 2: network disk path
Command List
| |
---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Common parameters
| |
---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
journal
-q -Rclone will only generate ERROR Message. -v -Rclone will generate ERROR , NOTICE and INFO Message, Recommend this item 。 -vv -Rclone will generate ERROR , NOTICE , INFO and DEBUG Message. --log-level LEVEL -Flag controls log level.
filter
| |
---|---|
| |
| |
| |
| |
| |
| |
File Type Filtering such as --exclude "*.bak" , which means excluding all .bak The ending document can also be written --filter "- *.bak" such as --include "*.{png,jpg}" , including all png and jpg Documents, excluding other documents, can also be written --filter "+ *.{png,jpg}" --delete-excluded Delete excluded files. It must be used together with the filter parameters, otherwise it is invalid. Directory filtering Directory filtering requires adding / , otherwise it will be matched as a file. with / At the beginning, only the root directory (under the specified directory) will be matched, otherwise, the directory will be matched. The same applies to documents. --exclude ".git/" Exclude .git catalog. --exclude "/.git/" Exclude only those under the root directory .git catalog. --exclude "{Video,Software}/" Exclude Video and Software catalog. --exclude "/{Video,Software}/" Exclude only those under the root directory Video and Software catalog. --include "/{Video,Software}/**" Only include Video and Software All contents of the directory. Size filtering The default size unit is kBytes , but can use k , M or G suffix. --min-size Filter files smaller than the specified size. such as --min-size 50 Indicates that files smaller than 50k will not be transferred. --max-size Filter files larger than the specified size. such as --max-size 1G Indicates that files larger than 1G will not be transferred. Filter rules come from a file --Exclude from<rule file> : Add Include Rule from File --Include from<rule file> : Add Delete Rule from File --Filter from<rule file> : Add an include/exclude rule from a file. such as --filter-from filter-file.txt 。 filter-file.txt Example: - secret*.jpg + *.jpg + *.png + file2.avi - /dir/Trash/** + /dir/** - *
environment variable
| |
---|---|
| |
| |
| |
| |
| |
| |
| |
| |
Best Practices
catalog /data/file Create under excludes.txt , fill in the list of files to be excluded. Logs/* * # Exclude all files under logs *. bak # Exclude files ending in. bak *. zip # Exclude files at the end of. zip Configure Tencent Cloud COS to ignore here and write directly rclone Command to test whether the execution is synchronized. rclone sync -v /data/file tencent-cos:/beifen --exclude-from '/data/file/excludes.txt' >> /root/rclone.log 2>&1 Manually execute one and check tail -f /root/rclone.log Whether the log has been output. If no error is reported, it will succeed. Configure scheduled tasks and execute them automatically every day implement crontab -e #Open the scheduled task list and jump to the last line to add step 2. The successful command is saved as follows: (it means that synchronization is performed at 3:30 every night) 30 4 * * * rclone sync -v /data/file tencent-cos:/beifen --exclude-from '/data/file/excludes.txt' >> /root/rclone.log 2>&1 implement systemctl restart cron.service Restart the scheduled task to take effect -
Check after execution time /root/rclone.log The logs under are guaranteed to be OK.
summary
Reference link