当前位置:网站首页>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脚本专题
边栏推荐
- Prometheus's Recording rules practice
- University of California | Inverse Reinforcement Learning from Different Third-Person Videos via Graph Abstraction
- Map传值
- 日志工厂(详细)
- 亚马逊云科技Build On2022技能提升计划第二季——揭秘出海爆款新物种背后的黑科技
- C#/VB.NET: extracted from the PDF document all form
- The function realization of the national standard GB28181 protocol EasyGBS platform compatible with the old version of the inflow port
- Leetcode71. Simplified Paths
- Leetcode75. 颜色分类
- Goldfish Brother RHCA Memoirs: CL210 manages OPENSTACK network -- network configuration options
猜你喜欢

Redis的内存淘汰策略和过期删除策略的区别是什么

Three solutions: npm WARN config global --global, --local are deprecated. Use --location=global instead.

How to use the Golang coroutine scheduler scheduler

explain 各字段介绍

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

A simple Flask PIN

MySQL Lock wait timeout exceeded; try restarting transaction 锁等待

屏:全贴合工艺之GFF、OGS、Oncell、Incell

odoo coding conventions (programming conventions, coding guidelines)

云原生全景图详解
随机推荐
暑假第二周总结博客
Prometheus的Recording rules实践
国标GB28181协议EasyGBS平台兼容老版本收流端口的功能实现
Go GORM transaction instance analysis
2022,程序员应该如何找工作
How to build a CMDB driven by consumption scenarios?
面试必问的HashCode技术内幕
【翻译】CNCF培养的OpenMetrics成为一个孵化项目
WinRAR | Generate multiple installers into one installer
顺序表的简单描述及代码的简单实现
亚马逊云科技Build On2022技能提升计划第二季——揭秘出海爆款新物种背后的黑科技
What is the implementation principle of Go iota keyword and enumeration type
483-82 (23, 239, 450, 113)
Fuzzy query in Map pass-by-value and object pass-by-value
The life cycle and scope
mysql函数的作用有哪些
How to solve the dynamic binding of el-form-item prop attribute does not take effect
shell脚本专题(07):文件由cfs到bos
【无标题】setInterval和setTimeout详解
Prometheus's Recording rules practice