markdown Rclone与COS的例子

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Rclone与COS的例子相关的知识,希望对你有一定的参考价值。

This is an example of using rclone to keep a local directory in sync with a COS bucket. 

```
root@s3:~# ls -l images/
total 0
root@s3:~# rclone ls COS-US-SOUTH:klscreenshots
1073741824 1Gfile.txt
    99005 IBM_Bluemix.png
   912051 IMG_1096.PNG
   874304 IMG_1097.PNG
   478401 IMG_1098.PNG
   917939 IMG_1099.PNG
   237556 LinuxFileRestore.zip
    29805 Screen-Shot-2017-05-16-at-11.10.25-AM.png
   739392 Screen-Shot-2017-05-24-at-8.53.50-AM.png
    30836 Screen-Shot-2017-05-25-at-10.16.53-AM.png
    28156 Screen-Shot-2017-05-25-at-10.33.40-AM.png
   232354 Screen-Shot-2017-05-25-at-11.22.38-AM.png
    53292 Screenshot_2017-05-22-13.50.35_jUby1C.png
    29901 Screenshot_2017-05-22-13.51.45_0eaQkh.png
    25077 Screenshot_2017-05-22-15.57.52_bsoLxB.png
   133026 Screenshot_2017-05-23-13.12.59_j9EEBj.png
    51884 SoftLayer_Customer_Portal____Security_Group_Details.png
    45684 backupSchedule.png
    37724 chooseHypervType.png
    64982 createBackupJob1.png
    40106 deployingVeeamComponents.
   142901 deviceListTag.png
    25474 generalOptions.png
    25443 injectingBackups.png
    10982 lbHealthChecks.png
     2017 octicons_4-3-0_beaker_256_0_ffffff_none.png
    32994 restoreFiles1.png
    33100 restoreFiles2.png
    29842 restoreFiles3.png
    28719 restoreFiles5.png
    32876 restoreStep1.png
    30638 restoreStep2.png
    29300 restoreStep3.png
    29482 restoreStep4.png
    21205 restoreStep5.png
    35645 setCredentials.png
    25455 setServerIp.png
     1740 stroke-7_1-2-0_rocket_128_0_ffffff_none.png
    15118 testingIops.png
    32977 vmSize.png
   127336 winChoice.png
    84294 veeamLinuxFileRestore/restoreGuestFiles1.png
    34487 veeamLinuxFileRestore/restoreGuestFiles2.png
    28075 veeamLinuxFileRestore/restoreGuestFiles3.png
    26355 veeamLinuxFileRestore/restoreGuestFiles4.png
    31906 veeamLinuxFileRestore/restoreGuestFiles5.png
    42348 veeamLinuxFileRestore/restoreGuestFiles6.png
    24627 veeamLinuxFileRestore/restoreGuestFilesComplete.png
     8196 screenshots/.DS_Store
  ```
  
  ## Syncing the bucket to a local directory
  
  For real world usage or automation I would recommend skipping the `-v` flag here. I am using it simply to show some more detail of the process. 
  
  ```
  root@s3:~# rclone -v sync COS-US-SOUTH:klscreenshots ~/images
2017/12/15 11:41:35 INFO  : Local file system at /root/images: Modify window is 1ns
2017/12/15 11:41:35 INFO  : IBM_Bluemix.png: Copied (new)
2017/12/15 11:41:35 INFO  : IMG_1096.PNG: Copied (new)
2017/12/15 11:41:35 INFO  : IMG_1097.PNG: Copied (new)
2017/12/15 11:41:35 INFO  : IMG_1098.PNG: Copied (new)
2017/12/15 11:41:35 INFO  : Screen-Shot-2017-05-16-at-11.10.25-AM.png: Copied (new)
2017/12/15 11:41:35 INFO  : LinuxFileRestore.zip: Copied (new)
2017/12/15 11:41:35 INFO  : IMG_1099.PNG: Copied (new)
2017/12/15 11:41:35 INFO  : Screen-Shot-2017-05-25-at-10.16.53-AM.png: Copied (new)
2017/12/15 11:41:35 INFO  : Screen-Shot-2017-05-24-at-8.53.50-AM.png: Copied (new)
2017/12/15 11:41:35 INFO  : Screen-Shot-2017-05-25-at-10.33.40-AM.png: Copied (new)
2017/12/15 11:41:36 INFO  : Screenshot_2017-05-22-13.50.35_jUby1C.png: Copied (new)
2017/12/15 11:41:36 INFO  : Screenshot_2017-05-22-13.51.45_0eaQkh.png: Copied (new)
2017/12/15 11:41:36 INFO  : Screen-Shot-2017-05-25-at-11.22.38-AM.png: Copied (new)
2017/12/15 11:41:36 INFO  : Screenshot_2017-05-22-15.57.52_bsoLxB.png: Copied (new)
2017/12/15 11:41:36 INFO  : Screenshot_2017-05-23-13.12.59_j9EEBj.png: Copied (new)
2017/12/15 11:41:36 INFO  : SoftLayer_Customer_Portal____Security_Group_Details.png: Copied (new)
2017/12/15 11:41:36 INFO  : backupSchedule.png: Copied (new)
2017/12/15 11:41:36 INFO  : chooseHypervType.png: Copied (new)
2017/12/15 11:41:36 INFO  : createBackupJob1.png: Copied (new)
2017/12/15 11:41:36 INFO  : deployingVeeamComponents.: Copied (new)
2017/12/15 11:41:36 INFO  : deviceListTag.png: Copied (new)
2017/12/15 11:41:36 INFO  : generalOptions.png: Copied (new)
2017/12/15 11:41:36 INFO  : injectingBackups.png: Copied (new)
2017/12/15 11:41:36 INFO  : lbHealthChecks.png: Copied (new)
2017/12/15 11:41:36 INFO  : octicons_4-3-0_beaker_256_0_ffffff_none.png: Copied (new)
2017/12/15 11:41:36 INFO  : restoreFiles1.png: Copied (new)
2017/12/15 11:41:36 INFO  : restoreFiles2.png: Copied (new)
2017/12/15 11:41:36 INFO  : restoreFiles3.png: Copied (new)
2017/12/15 11:41:36 INFO  : restoreFiles5.png: Copied (new)
2017/12/15 11:41:36 INFO  : restoreStep2.png: Copied (new)
2017/12/15 11:41:36 INFO  : restoreStep1.png: Copied (new)
2017/12/15 11:41:36 INFO  : restoreStep3.png: Copied (new)
2017/12/15 11:41:36 INFO  : restoreStep4.png: Copied (new)
2017/12/15 11:41:36 INFO  : setCredentials.png: Copied (new)
2017/12/15 11:41:36 INFO  : restoreStep5.png: Copied (new)
2017/12/15 11:41:36 INFO  : setServerIp.png: Copied (new)
2017/12/15 11:41:36 INFO  : testingIops.png: Copied (new)
2017/12/15 11:41:36 INFO  : stroke-7_1-2-0_rocket_128_0_ffffff_none.png: Copied (new)
2017/12/15 11:41:36 INFO  : screenshots/.DS_Store: Copied (new)
2017/12/15 11:41:36 INFO  : winChoice.png: Copied (new)
2017/12/15 11:41:36 INFO  : vmSize.png: Copied (new)
2017/12/15 11:41:36 INFO  : Local file system at /root/images: Waiting for checks to finish
2017/12/15 11:41:36 INFO  : Local file system at /root/images: Waiting for transfers to finish
2017/12/15 11:41:36 INFO  : veeamLinuxFileRestore/restoreGuestFiles1.png: Copied (new)
2017/12/15 11:41:36 INFO  : veeamLinuxFileRestore/restoreGuestFiles3.png: Copied (new)
2017/12/15 11:41:36 INFO  : veeamLinuxFileRestore/restoreGuestFiles2.png: Copied (new)
2017/12/15 11:41:36 INFO  : veeamLinuxFileRestore/restoreGuestFiles5.png: Copied (new)
2017/12/15 11:41:36 INFO  : veeamLinuxFileRestore/restoreGuestFiles4.png: Copied (new)
2017/12/15 11:41:37 INFO  : veeamLinuxFileRestore/restoreGuestFiles6.png: Copied (new)
2017/12/15 11:41:37 INFO  : veeamLinuxFileRestore/restoreGuestFilesComplete.png: Copied (new)

2017/12/15 11:42:13 INFO  : 1Gfile.txt: Copied (new)
2017/12/15 11:42:13 INFO  : Waiting for deletions to finish
2017/12/15 11:42:13 INFO  :
Transferred:   1.006 GBytes (27.071 MBytes/s)
Errors:                 0
Checks:                 0
Transferred:           49
Elapsed time:         38s

root@s3:~# ls images/
1Gfile.txt                 IMG_1099.PNG                                 restoreStep3.png                           Screen-Shot-2017-05-25-at-11.22.38-AM.png
backupSchedule.png         injectingBackups.png                         restoreStep4.png                           screenshots
chooseHypervType.png       lbHealthChecks.png                           restoreStep5.png                           setCredentials.png
createBackupJob1.png       LinuxFileRestore.zip                         Screen-Shot-2017-05-16-at-11.10.25-AM.png  setServerIp.png
deployingVeeamComponents.  octicons_4-3-0_beaker_256_0_ffffff_none.png  Screenshot_2017-05-22-13.50.35_jUby1C.png  SoftLayer_Customer_Portal____Security_Group_Details.png
deviceListTag.png          restoreFiles1.png                            Screenshot_2017-05-22-13.51.45_0eaQkh.png  stroke-7_1-2-0_rocket_128_0_ffffff_none.png
generalOptions.png         restoreFiles2.png                            Screenshot_2017-05-22-15.57.52_bsoLxB.png  testingIops.png
IBM_Bluemix.png            restoreFiles3.png                            Screenshot_2017-05-23-13.12.59_j9EEBj.png  veeamLinuxFileRestore
IMG_1096.PNG               restoreFiles5.png                            Screen-Shot-2017-05-24-at-8.53.50-AM.png   vmSize.png
IMG_1097.PNG               restoreStep1.png                             Screen-Shot-2017-05-25-at-10.16.53-AM.png  winChoice.png
IMG_1098.PNG               restoreStep2.png                             Screen-Shot-2017-05-25-at-10.33.40-AM.png
root@s3:~#

```

And if we run the sync command again we can see that it behaves like rsync. This means that it will only sync any new files that have been added to the bucket.

```
root@s3:~# rclone -v sync COS-US-SOUTH:klscreenshots ~/images
2017/12/15 11:44:13 INFO  : Local file system at /root/images: Modify window is 1ns
2017/12/15 11:44:13 INFO  : Local file system at /root/images: Waiting for checks to finish
2017/12/15 11:44:13 INFO  : Local file system at /root/images: Waiting for transfers to finish
2017/12/15 11:44:13 INFO  : Waiting for deletions to finish
2017/12/15 11:44:13 INFO  :
Transferred:      0 Bytes (0 Bytes/s)
Errors:                 0
Checks:                49
Transferred:            0
Elapsed time:       400ms
```

## The rclone configuration file

In this case I have rclone hitting the private Dallas regional endpoint. 

```
root@s3:~# cat ~/.rclone.conf
[COS-US-SOUTH]
type = s3
env_auth = false
access_key_id = YOURACCESSKEY
secret_access_key = YOURSECRETKEY
region = other-v4-signature
endpoint = s3-api.dal-us-geo.objectstorage.service.networklayer.com
location_constraint =
acl = private
server_side_encryption =
storage_class =
```

以上是关于markdown Rclone与COS的例子的主要内容,如果未能解决你的问题,请参考以下文章

如何使用rclone从AWS S3迁移到IBM COS - part 1

使用电报机器人在 Heroku 上的 docker 中安装 Rclone [帮助]

技术方案:Go 实现的存储服务器,文件系统,Key-Value 存储(特别是Rclone)

硬盘里面的rclone.exe是啥

Python rclone检查两个文件夹的差异

Ubuntu安装配置rclone(Onedrive应用)