当前位置:网站首页>Shell script topic (07): file from cfs to bos
Shell script topic (07): file from cfs to bos
2022-08-01 18:53:00 【51CTO】
一、背景
Production produces thousands of audio files every day,There are several sizesG.这些文件存放在cfs内,由于cfsThe usage fee is higher,容量较小,Periodic manual transfers to larger spaces are required for less costbos内.This procedure is to change the manual operation to the automatic way.Involves log output、文件比对、文件复制、文件删除、监控告警等.
二、名词解释
cfs:文件储存CFSare file and protocol storage,It can be understood as a higher-level object storageBOS,文件储存CFSCan't do calculations,Just gateway protocol storage,Reading and writing of pictures and documents、and higher level of security.
bos:对象储存BOSSimilar to Baidu Cloud Disk,But it's enterprise level,对象储存BOS提供一个简单的 Web 服务接口,Can be used to store and extract any amount of data.
cfsShared use by multiple servers,Use cost ratiobos高很多.
三、Program working logic
Most of the audio files generated each day are stored in date-named directories,This directory also has one level of subdirectoriesxxdata,A small number of recording files are stored in this subdirectory.首先将n天前的cfsDate directory copied tobos,Then compare whether they are consistent,Alignment containsmd5和diffand file count comparison,If they are consistent, delete the originalcfsRecording file directory,Exit if there is an inconsistency,Finally, a successful notification or a failed alarm is sent through WeChat.
四、日志说明
Every step of the program has a detailed log record,Including the existence of the source file directory and the target directory、Which files were copied、删除了哪些文件、md5Generation and alignment、Which operations failed etc.The normal operation of the program or the failure of the operation can be viewed through the log location.
五、各模块介绍
本程序共有9个模块,下面一一介绍
1.日志模块logs_bak

本程序共有4个日志,分别是all:Record all actions during the execution of this program;alter:Only the error content of each step is recorded,The log is empty if successful;cron:Record the execution of scheduled tasks every day;md5:记录md5Generation and alignment.
除了cron日志外,The other three logs will be backed up by date cutover when the program is running.
2.Directory inspection modulefile_check
Check the source file directorySOURCE_PATHand backup directoryDEST_PATH是否存在,因为有可能出现cfs或者bosMount failed problem.Continue if all paths exist, otherwise report an error and exit.
运行日志截图:

3.生成源文件md5value modulemd5_a
Get a list of audio files in the first level of the date directory and generate themmd5文件md5_a.txt,The file is being copied tobos后进行md5will be used for comparison.Continue if the file is generated normally,Otherwise, write to the alarm log and exit.
运行日志截图:


4.生成源文件md5value modulemd5_b
Get the list of recording files in the second level of the date directory and generate themmd5文件md5_b.txt,The file is being copied tobos后进行md5will be used for comparison.Continue if the file is generated normally,Otherwise, write to the alarm log and exit.
运行日志截图:


5.File copy modulefile_cp
通过cpThe command will record the file bycfs复制到bos,A detailed log is recorded during the replication process.Continue if the copy is successful,Otherwise, write to the alarm log and exit.
运行日志截图:

6.md5比较模块diff_md5_a
在bosThe first level target directory to run’md5sum -c md5_a.txt’Make the recording file of the first layermd5比对,If the comparison is normal, continue,Otherwise, write to the alarm log and exit.
运行日志截图:

7.md5比较模块diff_md5_b
在bosrun from the second level target directory’md5sum -c md5_b.txt’Make the recording file of the second layermd5比对,If the comparison is normal, continue,Otherwise, write to the alarm log and exit.
运行日志截图:

8.Source file remove moduleorg_file_rm
The first layer and the second layer will be performed before the automatic deletion of the source recording filediffAlignment and alignment of the number of source and target files,Continue if all three conditions are met,If one is not satisfied, write the alarm log and exit.
运行日志截图:


9.Alarm or notification module
通过spugThe platform custom script issues an alert or notification message

If the alarm log is empty, a notification message is sent’the files ${DATE} copy sucessed’,If it is not empty, the alarm content will be issued.
A screenshot of the alert or notification WeChat:

spugSee the platform for details: 自动化运维平台Spug测试
六、运行方式
This program runs in a timed task mode,每天凌晨1点开始.
运行日志截图:

更多shell文章详见: shell脚本专题
边栏推荐
猜你喜欢

Zabbix6.0 DingTalk robot alarm

Solve the problem that MySQL cannot insert Chinese data

How many steps does it take to convert an ENS domain name into music?

Leetcode71. Simplified Paths

MySQL数据库————存储过程和函数

How opencv implements image skew correction

亚马逊云科技Build On2022技能提升计划第二季——揭秘出海爆款新物种背后的黑科技

ExcelPatternTool: Excel表格-数据库互导工具

MySQL中超键、主键及候选键的区别是什么

How to use the Golang coroutine scheduler scheduler
随机推荐
Leetcode71. Simplified Paths
LeetCode 0152. Product Maximum Subarray: dp + Roll in Place
如何让固定点的监控设备在EasyCVR平台GIS电子地图上显示地理位置?
MLX90640 红外热成像仪测温模块开发笔记(完整篇)
【木棉花】#夏日挑战赛# 鸿蒙小游戏项目——数独Sudoku(3)
Go GORM transaction instance analysis
Selenium在远程中的截图
What is the implementation principle of Go iota keyword and enumeration type
无需破解,官网安装Visual Studio 2013社区版
C#/VB.NET 从PDF中提取表格
ACID Characteristics and Implementation Methods of MySQL Relational Database Transactions
MySQL Lock wait timeout exceeded; try restarting transaction 锁等待
如何记录分析你的炼丹流程—可视化神器Wandb使用笔记【1】
三种方案解决:npm WARN config global --global, --local are deprecated. Use --location=global instead.
屏:全贴合工艺之GFF、OGS、Oncell、Incell
MySQL中超键、主键及候选键的区别是什么
打开微信客服
Summer vacation first week wrap-up blog
金鱼哥RHCA回忆录:CL210管理OPENSTACK网络--网络配置选项
COS User Practice Call for Papers