天天看點

本地檔案上傳到阿裡雲OSS對象存儲中

需求:檔案本地備份,安全性低,需要在雲端備份一份

系統 ossutil版本
centos7 ossutil1.7.3 64位

這裡使用的是

ossutil

工具,至于為什麼不使用

ossimport

,我這裡需要持續備份,本地與雲端OSS需要保持一緻性,

ossutil

工具中

sync

指令加上參數

--delete -f

可以滿足我的需求,

ossimport

是一次性遷移,不具有與本地檔案一緻性功能,建議在第一次備份時使用,後續可以使用

ossutil

sync

指令。

安裝工具

wget http://gosspublic.alicdn.com/ossutil/1.7.3/ossutil64
           

賦予權限

chmod 755 ossutil64
           

工具配置

./ossutil64 config
           
Please enter the config file name,the file name can include path(default /root/.ossutilconfig, carriage return will use the default file. If you specified this option to other file, you should specify --config-file option to the file when you use other commands):
(直接回車)
No config file entered, will use the default config file /root/.ossutilconfig

For the following settings, carriage return means skip the configuration. Please try "help config" to see the meaning of the settings
Please enter language(CH/EN, default is:EN, the configuration will go into effect after the command successfully executed):
(直接回車)
Please enter endpoint:輸入阿裡雲oss的位址。例如張家口區oss檔案存儲服務:oss-cn-zhangjiakou.aliyuncs.com
Please enter accessKeyID:填寫AccessKeyID
Please enter accessKeySecret:填寫AccessKey Secret
Please enter stsToken:(直接回車)
           
./ossutil64 sync /dwz/oss/  oss://nextcloud-onlyoffice --delete -f
 
total file(directory) count:7
oss://nextcloud-onlyoffice,total oss object count:10
object will be deleted count:3
Succeed: Total num: 7, size: 9. OK num: 7(upload 7 files).

           
/dwz/oss/:本地路徑
oss://nextcloud-onlyoffice:oss服務Bucket名稱
--delete -f:檢查一緻性并強制覆寫oss服務上的同名檔案
           

繼續閱讀