windows bat 备份脚本

简介:
备份脚本:
@echo off
echo 日期:%date%
@set stryear=%date:~0,4%&set strmonth=%date:~5,2%&set strday=%date:~8,2%
echo 时间:%time%
@set strhh=%time:~0,2%&set strmm=%time:~3,2%&set strss=%time:~6,2%
@set strdatetime = %stryear%%strmonth%%strday%%strhh%%strmm%%strss%
@md "web_backup_%stryear%%strmonth%%strday%%strhh%%strmm%"
@xcopy "E:\www" /e /c "web_backup_%stryear%%strmonth%%strday%%strhh%%strmm%\" >>"web_backup_%stryear%%strmonth%%strday%%strhh%%strmm%\web_backup_%stryear%%strmonth%%strday%%strhh%%strmm%.txt"
 
 
删除脚本:

@echo off
@del G:\web_backup\*.log /f /s /a /q
@set srcdir=G:\web_backup
>"%srcdir%\getdate.vbs" echo dt=date()-7
>>"%srcdir%\getdate.vbs" echo x=right(year(dt),4) ^& right("0" ^& month(dt),2) ^& right("0" ^& day(dt),2)
>>"%srcdir%\getdate.vbs" echo wscript.echo x
@for /f %%a in ('cscript /nologo "%srcdir%\getdate.vbs"') do set dateflag=%%a
@set dateflag=%dateflag:~0,4%-%dateflag:~4,2%-%dateflag:~6,2%
@for /f "tokens=*" %%a in ('dir /b /ad "%srcdir%"') do (if "%%a" lss "web_backup_%dateflag% 000" (rd /s /q "%srcdir%\%%a"))


本文转自 liang3391 51CTO博客,原文链接:http://blog.51cto.com/liang3391/663335
相关文章
|
安全 Unix Linux
Veritas NetBackup 11 for Linux & Windows - 领先的企业备份和恢复解决方案
Veritas NetBackup 11 for Linux & Windows - 领先的企业备份和恢复解决方案
658 0
Veritas NetBackup 11 for Linux & Windows - 领先的企业备份和恢复解决方案
|
监控 Windows
Veeam Backup & Replication 12.3.2 Windows x64 - 备份和恢复
Veeam Backup & Replication 12.3.2 Windows x64 - 备份和恢复
549 1
|
Python Windows
python之windows脚本启动bat
python之windows脚本启动bat
|
存储 安全 开发工具
windows开发环境备份,再也不怕重装系统了
【9月更文挑战第2天】在Windows系统中备份开发环境可大幅提升重装系统后的效率。本文详细介绍五个关键步骤:备份开发工具及软件包;保存配置文件;备份数据库与数据文件;确保代码仓库的安全;记录安装步骤与注意事项。遵循这些建议,重装系统时可迅速恢复开发环境,避免重复劳动。
1988 7
|
监控 关系型数据库 MySQL
PowerShell 脚本编写 :自动化Windows 开发工作流程
PowerShell 脚本编写 :自动化Windows 开发工作流程
894 0
|
Windows
Windows批处理(BAT)文件执行时“一闪而过或闪退”问题及解决方法
Windows批处理(BAT)文件执行时“一闪而过或闪退”问题及解决方法
12457 1
|
Windows
windows系统bat批处理 打开乱码
windows系统bat批处理 打开乱码
225 4
|
关系型数据库 MySQL 数据安全/隐私保护
windows系统bat批处理 mysql 脚本启动关闭
windows系统bat批处理 mysql 脚本启动关闭
486 3
|
Windows
windows系统bat批处理 打开设备管理器
windows系统bat批处理 打开设备管理器
345 1
|
安全 Shell Windows
记windows自定义bat脚本自启动
【8月更文挑战第27天】在Windows系统中,可让自定义bat脚本自启动的方法有两种:一是利用“启动”文件夹,通过创建bat脚本的快捷方式并将其放置于该文件夹;二是使用任务计划程序,创建一个启动时触发的任务来运行bat脚本。需确保脚本正确安全,避免对系统产生不良影响。
3560 0