当前位置:网站首页>ThinkPHP realizes database backup
ThinkPHP realizes database backup
2022-07-24 12:19:00 【Chenqing Nuo language】
1 The importance of database backup
In production environment , Data security is critical , Any loss of data can have serious consequences
The importance of database backup is mainly reflected in :
- Improve the high availability and disaster recoverability of the system , When the database system crashes , No data can be found without database backup
- Use database backup to restore the database , It is the best solution to provide the minimum cost of data recovery when the database crashes , If you let users add data again , The price is too high
- Without data, there is nothing , Database backup is a powerful means to prevent disasters
Program error : It is inevitable that there are some mistakes in the program of database operation , Cause data loss
- Human error : It refers to the data destruction caused by the misoperation of the user , There may also be data loss caused by hackers' attacks on the system
- Computer failure : It refers to the damage of the server operating system or software running the database , It may cause data damage
- Disk failed : Refers to hard disk and other hardware devices that store data , It may be damaged after long-term operation , Resulting number
- It is lost
- disaster ( Such as fire 、 The earthquake ) And theft : Refers to the occurrence of natural disasters, etc , It may cause data loss
In the process of using database , There are many reasons for data loss :
Install the extension
composer require tp5er/tp5-databackup dev-masterpublic function asd()
{
$config=array(
'path' => './Data/',// Database backup path
'part' => 20971520,// Database backup volume size
'compress' => 0,// Whether compression is enabled for database backup files 0 Uncompressed 1 Compress
'level' => 9 // Database backup file compression level 1 Ordinary 4 commonly 9 The highest
);
$db= new Backup($config);
$tables=$db->dataList();// obtain x Information of all tables in the database
foreach($tables as $k=>$v){
$db->backup($v['name'],0);// Cycle all tables back up tables and data
}
$file=$db->getFile();// Get the file name of the backed up file
var_dump($file);
} The effect is as follows 
边栏推荐
- Opencv:08 image pyramid
- [rust] what software should I use to develop rust? Recommended editors commonly used to support rust
- L1-064 估值一亿的AI核心代码
- 4*4图片权重的收敛规则
- Understand the storage and retrieval of data
- 微信公众号开发:素材管理(临时、永久)
- Buckle exercise - 35 combination sum II
- The art of management - driving software R & D efficiency through leadership
- TypeNameExtractor could not be found
- Use and expansion of fault tolerance and fusing
猜你喜欢

【网络空间安全数学基础第9章】有限域

Opencv:08 image pyramid

The art of management - driving software R & D efficiency through leadership

在kuborad图形化界面中,操作Kubernetes 集群,实现mysql中的主从复制

With the strong development of cloud native, how should enterprises seize business opportunities

Wechat applet - drawing dashboard

One of his birds sold for 60million -- the collection of eight mountain people in the Ming and Qing Dynasties
![Detailed OSPF configuration of layer 3 switch / router [Huawei ENSP experiment]](/img/a9/f080940ec7bf94ab83c922990efa62.png)
Detailed OSPF configuration of layer 3 switch / router [Huawei ENSP experiment]

L1-059 ring stupid bell
![Detailed explanation of MSTP protocol for layer 3 switch configuration [Huawei ENSP experiment]](/img/ee/e0770298d0534014485145c434491a.png)
Detailed explanation of MSTP protocol for layer 3 switch configuration [Huawei ENSP experiment]
随机推荐
makefile快速使用
Agile? DevOps ?
Basic usage of GCC
基于ARM和FPGA的数字示波器设计——QMJ
[mathematical basis of Cyberspace Security Chapter 3] congruence
[C and pointer Chapter 11] dynamic memory allocation
One of his birds sold for 60million -- the collection of eight mountain people in the Ming and Qing Dynasties
【C和指针第11章】动态内存分配
[I also want to brush through leetcode] 468. Verify the IP address
Blue team resource collection
L1-059 敲笨钟
[data mining engineer - written examination] sheen company in 2022
Learn some programming: anti unemployment "vaccine"
动态内存管理
Day3: branch structure
Force deduction exercise - 26 split array into continuous subsequences
【功能测试】项目的测试——登录和发布文章功能
L2-011 play with binary tree
Counter attack dark horse: devdbops training, give you the best courses!
QT notes - qtablewidget table spanning tree, qtreewidget tree node generates table content