Codeegg’s 898th tweet
Delete library run, reproduce river’s lake!
The love affair between programmer and data often ends in deletion. Although most of the database deletion accidents are based on misoperation, but sporadic cases often wake up the boss at night. I don’t know if you still remember last year: game company main program lock library event?
And recently, The Shanghai Micro Alliance company once again occurred core operation and maintenance staff deleted database run bridge section. According to the announcement: At 18:56 on February 23, he, an operation and maintenance staff member, logged into the company’s Intranet through VPN to damage the production environment due to personal spirit and other reasons.
Although the company cooperated with Tencent Cloud to recover the data immediately after the event, the significant impact on the company has already occurred within 36 hours, and the impact on users is even more profound. Different from the small company that deleted the library event in the past, the protagonist of this time is actually the Hong Kong stock listed company invested by Tencent!
Founded in April 2013, Weimeng has more than 3,200 employees, more than 1,600 channel agents and more than 3 million registered merchants.
Weimeng is a cloud business and marketing solution provider for Small and medium-sized enterprises in China, mainly providing SaaS services for retail, advertising and other online businesses. It is also a precision marketing service provider for small and medium-sized enterprises on Tencent’s social network service platform. After the accident, cha-cha Guazi, Natantang, Carbin and other small program e-commerce customers were unable to open.
Delete library for a while, look at the moonlight behind bars
No matter what kind of conflict occurs with the company, malicious sabotage will not only not solve the problem, but also intensify the conflict, and bring serious disaster to the individual and the company. What’s more, this kind of behavior is a serious illegal and criminal behavior. Let’s give everyone another wake-up call.
Article 286 Whoever, in violation of State regulations, deletes, modifies, increases or interferes with the functions of a computer information system, thus causing the normal operation of the computer information system to fail, if the consequences are serious, shall be sentenced to fixed-term imprisonment of not more than five years or criminal detention; If the consequences are especially serious, he shall be sentenced to fixed-term imprisonment of not less than five years. Whoever, in violation of State regulations, deletes, modifies or adds data or application programs stored, processed or transmitted in a computer information system, if the consequences are serious, shall be punished in accordance with the provisions of the preceding paragraph. Whoever intentionally creates or disseminates computer viruses or other destructive programs that affect the normal operation of a computer system, if the consequences are serious, shall be punished in accordance with the provisions of the first paragraph.
Criminal Law of the People’s Republic of China
The behavior of deleting the database and running away mainly commits the crime of “destroying the computer information system” in criminal Law, and one of the following behaviors constitutes “serious consequences” :
-
(1) causing the normal operation of major software or hardware of more than ten computer information systems;
-
(2) deleting, modifying or adding data stored, processed or transmitted in more than 20 computer information systems;
-
(3) illegal gains of more than 5,000 yuan or economic losses of more than 10,000 yuan;
-
(4) the computer information system providing basic services such as domain name resolution, identity authentication and billing for more than 100 computer information systems or providing services for more than 10,000 users cannot run normally for more than one hour in total;
-
(5) causing other serious consequences
Criminal law warning, do not imitate
Strengthen management and plan for a rainy day
As a good programmer like you, you must have been motivated to “change the world”. Yeah, one bloody tragedy after another. It can’t happen again. We can improve both management and technology.
Scientific management
Separate accounts to avoid incorrect commands. For example, business development students are given THE DML permission instead of the TRUNCate/DROP permission. If business developers have DDL requirements, they can be supported through the development management system. Even MEMBERS of the DBA team have a daily policy to use only read-only accounts and update only when necessary.
Create a specification to avoid writing wrong table names to be deleted. Before dropping a table, you must rename the table. Then, watch for a period of time to ensure that there is no business impact before deleting the table; When changing a table name, a fixed suffix (such as _to_BE_DELETED) is required for the table name, and the deletion of the table must be performed through the management system. When the management system deletes a table, only the table with a fixed suffix can be deleted.
Technology to prevent
Speaking of prevention, we have to talk about the death command “RM” :
rm -rf
Copy the code
Rm is the Linux command to delete files. -r stands for delete everything under this, everything and everything. F indicates that the command is executed without user confirmation.
If the following folder path is not correct, rm -rf on the server means… Relieved…
Solution 1: Redirects the RM command to be transferred to the MV command, which is equivalent to customizing a recycle bin for the Linux system.
# define the recycle bin directory
trash_path= '~/.trash'
If the file defined by $trash_path exists, then $trash_path is created.
if[ ! -d $trash_path ]; then
mkdir -p $trash_path
fi
# Define alias: use rm to call trash
aliasrm=trash
# call 'ls ~/.trash'
# If you want to change the recycle bin directory, you need to change the recycle bin directory
aliasrl= 'ls ~/.trash'
Restorefile is called using unrm and needs to be executed in the parent directory of the deleted directory
aliasunrm=restorefile
# claearteash is called using rmTrash
aliasrmtrash=cleartrash
Function to restore files
restorefile()
{
mv -i ~ /.trash/$@ ./
}
# Delete file function
trash()
{
mv $@ ~ /.trash/
}
Empty the recycle bin function
cleartrash()
{
Read-p "Are you sure you want to empty the recycle bin? [y/n]"confirm
[ $confirm == 'y'] ||[ $confirm == 'Y'] && /bin/rm-rf ~ /.trash/*
}
Copy the code
Write the above script to /etc/bashrc and run the source /etc/bashrc command immediately.
Scheme 2: I recommend an open source project: Trash-CLI, 1.4K Star, which has some users. It’s like a trashcan. It restores files.
https://github.com/andreafrancia/trash-cli
Finally, may every programmer be treated with kindness.
Refer to the article: https://www.sohu.com/a/292017569_355140
https://www.cnblogs.com/asdf89/p/9699665.html
Related articles:
-
After reading this article on garbage collection, you’re good to go with the interviewer
-
How hard is it to learn?
-
IDEA shortcut keys with good, work early
Question of the day:
When did you first try to delete the library and run away?
Exclusive upgrade community: I Finally Figured it out