需求:文件本地备份,安全性低,需要在云端备份一份
系统 | 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
赋予权限
工具配置
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服务上的同名文件
查看oss服务,此时我本地删除1 2 3文件,执行./ossutil64 sync /dwz/oss/ oss://nextcloud-onlyoffice --delete -f
命令后,oss服务也会删除1 2 3 文件

阿里云官方安装ossutil教程
阿里云官方sync命令教程