Linux系统使用
一、下载obsutil安装包安装
我这里是x86架构的,ARM架构:wget https://obs-community.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_arm64.tar.gz
执行wget命令下载obsutil工具
wget https://obs-community.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_amd64.tar.gz
在软件包所在目录,执行以下解压命令
进入obsutil所在目录,执行以下命令,为obsutil增加可执行权限
cd obsutil_linux_amd64_5.5.12/
chmod 755 obsutil
继续在目录中执行以下命令,如果能顺利返回obsutil版本号,说明安装成功
./obsutil version
二、初始化配置
终端节点地址:https://console.huaweicloud.com/apiexplorer/#/endpoint/OBS
使用永久AK、SK进行初始化配置:
./obsutil config -i=ak -k=sk -e=endpoint
三、复制对象
相关参数说明参考文档:https://support.huaweicloud.com/utiltg-obs/obs_11_0012.html
# 创建测试目录
[root@ecs-9ebe obsutil_linux_amd64_5.5.12]# mkdir /opt/ceshi
[root@ecs-9ebe obsutil_linux_amd64_5.5.12]# touch /opt/ceshi/flag.txt
# 复制目录至OBS桶并输出日志文件
[root@ecs-9ebe obsutil_linux_amd64_5.5.12]# ./obsutil cp /opt/ceshi/ obs://aap-lpg/ceshi -f -r -u -o=/root/huaweilogs
Start at 2024-07-26 05:21:27.79570047 +0000 UTC
Parallel: 5 Jobs: 5
Threshold: 50.00MB PartSize: auto
VerifyLength: false VerifyMd5: false
CheckpointDir: /root/.obsutil_checkpoint
Task id: eebef15d-6b30-4619-a043-4572372e52c4
OutputDir: /root/huaweilogs
[---------------------------------------] 100.00% tps:15.04 ?/s 2/2 0B/0B 334ms
Succeed count: 2 Failed count: 0
Succeed bytes: 0B
Metrics [max cost:282 ms, min cost:186 ms, average cost:234.00 ms, average tps:5.92, transfered size:0B]
Task id: eebef15d-6b30-4619-a043-4572372e52c4
[root@ecs-9ebe ~]# ls
huaweilogs obsutil_linux_amd64_5.5.12 obsutil_linux_amd64.tar.gz
[root@ecs-9ebe ~]# cd huaweilogs/
[root@ecs-9ebe huaweilogs]# ls
cp_succeed_report_20240726052128_eebef15d-6b30-4619-a043-4572372e52c4.txt
[root@ecs-9ebe huaweilogs]# cat cp_succeed_report_20240726052128_eebef15d-6b30-4619-a043-4572372e52c4.txt
2024-07-26T05:21:28Z Start at 2024-07-26 05:21:28.12420061 +0000 UTC
2024-07-26T05:21:28Z [file size, md5 value, src --> dst, cost(ms), status code, success message, request id]
2024-07-26T05:21:28Z 0B, n/a, /opt/ceshi --> obs://aap-lpg/ceshi/ceshi/, cost [282], status [200], success message [succeed], request id [00000190ED7CA94596C84CBA2BED3A88]
2024-07-26T05:21:28Z 0B, n/a, /opt/ceshi/flag.txt --> obs://aap-lpg/ceshi/ceshi/flag.txt, cost [186], status [200], success message [upload succeed], request id [00000190ED7CA944934E3A113B0E73F8]
2024-07-26T05:21:28Z Succeed count: 2/2
2024-07-26T05:21:28Z Succeed bytes: 0B/0B
2024-07-26T05:21:28Z End at 2024-07-26 05:21:28.462403672 +0000 UTC, cost [338]
四、设置定时任务,定时备份上传至OBS
[root@ecs-9ebe obsutil_linux_amd64_5.5.12]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
[root@ecs-9ebe obsutil_linux_amd64_5.5.12]# crontab -l
00 23 * * * cd /root/obsutil_linux_amd64_5.5.12 && nohup ./obsutil cp /opt/ceshi obs://aap-lpg/ceshi -f -r -u -o=/root/huaweilogs &>obsutil_crond.log &
Windows系统使用
一、下载obsutil安装包安装
下载地址:https://support.huaweicloud.com/utiltg-obs/obs_11_0003.html#obs_11_0003__table685142311232
解压
双击obsutil.exe进行使用
二、初始化配置
终端节点地址:https://console.huaweicloud.com/apiexplorer/#/endpoint/OBS
使用永久AK、SK进行初始化配置:
obsutil config -i=ak -k=sk -e=endpoint
三、复制对象
相关参数说明参考文档:https://support.huaweicloud.com/utiltg-obs/obs_11_0012.html
创建测试目录
复制目录至OBS桶并输出日志文件
验证
四、设置定时任务,定时备份上传至OBS
编写bat脚本
设置任务计划程序