You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
QingLong/Doc/方法与技巧/Navicat定时清除数据库备份.md

51 lines
2.1 KiB

2 years ago
## [【Navicat】定时清除数据库备份并保留最近7天](https://blog.csdn.net/ladymorgana/article/details/126967855)
<font color='red' size=4><b>黄海整理</b></font>
### 1. 打开任务计划程序
此电脑---右键-管理----弹出如下界面
- Step1 创建基本任务
- ![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202309141121096.png)
- Step2 设置每天13:00 (午休时间,可以自行设置)
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202309141122447.png)
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202309141122298.png)
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202309141122824.png)
- Step3 创建脚本,并设置
脚本文件 delte_bak.bat
> **注意**:路径不能包含中文否则会报错。
```cpp {.line-numbers}
forfiles /p "C:\Users\Administrator\Documents\Navicat\PostgreSQL\Servers\10.10.14.14\gtzz_base_db\public" /m *.nb3 /d -7 /c "cmd /c del @path"
CHOICE /T 7 /C ync /CS /D y /n
exit
```
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202309141138182.png)
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202309141139775.png)
### 2. 测试
测试任务效果,右键点击运行看结果(立即运行)
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202309141139118.png)
ERROR: No files found with the specified search criteria. 表示没有要清理的文件(因为作者这里已经清理过)
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202309141139320.png)
查看文件夹7天之前的备份文件已删除
![](https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/{year}/{month}/{md5}.{extName}/202309141139908.png)