VBS 备份文件
http://www.cnblogs.com/top5/archive/2009/11/17/1604767.html
参考上面的博客
' =============== 局域网文件自动备份 VBS 脚本 =================
'
' 条件:10.97.1.X 开用户xcopy/xcopy 属于adminstrator
' 共享BACKUP 文件所在目录,使xcopy 用户完全控制!
' 运行后在管理进程中有2个进程:wscript.exe,ping.exe
' 以日期为log文件名称,只保留7天的日志
'
' =============================================================
Do While True
dim f,txtfile
Set f = CreateObject("Scripting.FileSystemObject")
set txtfile = f.opentextfile("D:\web\barcodeprinter\BACKUP\"&date&".txt",8,True)
'==== 判定7天前的log 文件是否存在,存在则删除!
If f.FileExists("D:\web\barcodeprinter\BACKUP\"&date-5&".txt") Then
f.DeleteFile("D:\web\barcodeprinter\BACKUP\"&date-5&".txt")
end if
'====
txtfile.writeline("========= 实时备份开始: "&date&" "&time&"==========")
txtfile.writeline(" ")
Call backupfile(f,txtfile)
WScript.Sleep 10000
txtfile.writeline("========= 实时备份结束: "&date&" "&time&"==========")
txtfile.writeline("")
set f =nothing
set txtfile=nothing
Loop
'------------------------------------ 实时备份过程 -----------------------------------
sub backupfile(f,txtfile)
Dim Path,fso,net
num=1
do while num<10
if num=1 then
ip="10.97.1.3"&num
source_path="\\"&ip&"\产品数码跟踪"
target_path="BACKUP\barcodeprinter31.mdb"
end if
if num=2 then
ip="10.97.1.3"&num
source_path="\\"&ip&"\产品数码跟踪"
target_path="BACKUP\barcodeprinter32.mdb"
end if
if num=3 then
ip="10.97.1.3"&num
source_path="\\"&ip&"\产品数码跟踪"
target_path="BACKUP\barcodeprinter33.mdb"
end if
if num=4 then
ip="10.97.1.3"&num
source_path="\\"&ip&"\产品数码跟踪"
target_path="BACKUP\barcodeprinter34.mdb"
end if
if num=5 then
ip="10.97.1.3"&num
source_path="\\"&ip&"\qjcf_no1"
target_path="BACKUP\barcodeprinter35.mdb"
end if
if num=6 then
ip="10.97.1.3"&num
source_path="\\"&ip&"\产品数码跟踪(BarCodePrinter)"
target_path="BACKUP\barcodeprinter36.mdb"
end if
if num=7 then
ip="10.97.1.3"&num
source_path="\\"&ip&"\产品数码跟踪(BarCodePrinter)"
target_path="BACKUP\barcodeprinter37.mdb"
end if
if num=8 then
ip="10.97.1.3"&num
source_path="\\"&ip&"\产品数码跟踪"
target_path="BACKUP\barcodeprinter38.mdb"
end if
if num=9 then
ip="10.97.1.3"&num
source_path="\\"&ip&"\产品数码跟踪(BarCodePrinter)"
target_path="BACKUP\barcodeprinter39.mdb"
end if
'
ip="10.97.1.3"&num
source_path="\\"&ip&"\产品数码跟踪"
target_path="D:\WEB\barcodeprinter\BACKUP\barcodeprinter3"&num&".mdb"
'------------ ping 测试,网络通ping="T"; -------------------
Set FileSys = CreateObject("Scripting.FileSystemObject")
Set WShShell = CreateObject("WScript.Shell")
RetCode = WShShell.Run("ping " &IP , 0, True )
if RetCode = 0 Then ' ping 测试通过
ping="T"
else
ping="F"
end if
set filesys = nothing
set wshshell = nothing
'------------ ping 结束 ------------------------------------
if ping="T" then
On Error Resume Next '出错不显示,执行下一条
Path="X:"
Set fso = CreateObject("Scripting.FileSystemObject")
Set net = CreateObject("WScript.Network")
If Not fso.DriveExists(fso.GetDriveName(Path)) Then
net.MapNetworkDrive Path,source_path,False,"xcopy","xcopy"
End If
Set file = fso.GetFile(Path&"\barcodeprinter.mdb")
file.Copy(target_path)
net.RemoveNetworkDrive Path,True
If Err.Number<>0 Then
txtfile.writeline("--- "&ip&" 备份失败! "&date&" "&time)
else
txtfile.writeline("--- "&ip&" 备份成功! "&date&" "&time&"--- OK!")
end if
else
txtfile.writeline("--- "&ip&" 网络不通! "&date&" "&time)
end if
set fso=nothing
set net=nothing
num=num+1
loop
end sub
'------------------------------------ 实时备份过程 -----------------------------------
这里备份的文件是barcodeprinter.mdb这个数据库文件,大家可以根据自己的实际情况进行代码修改
VBS 备份文件的更多相关文章
- oracle_自动备份用户数据,删除N天前的旧数据(非rman,bat+vbs)
有时数据没有实时备份恢复那么高的安全性需求,但每天 ,或者定期备份表结构 和数据依旧是很有必要的,介绍一种方法 在归档和非归档模式均可使用的自动备份方法. 预期效果是备份用户下的数据含表结构,备份文件 ...
- 用批处理文件自动备份文件及文件夹,并自动删除n天前的文件
原文:用批处理文件自动备份文件及文件夹,并自动删除n天前的文件 ---恢复内容开始--- 下是备份的批处理,添加到"计划任务"中,设定时间自动运行 复制代码 代码如下:@echo ...
- CMD批处理——forfiles命令使用,自动删除过期备份文件
公司服务器用来备份数据的硬盘过段时间就会被备份文件占满,弄得我老是要登录到服务器去手工删除那些老的文件,有时忘记了就会导致硬盘空间不足而无法备份.因为只要保留最近几天的备份,如果可以做一个批处理让系统 ...
- 通过windows计划任务和Dos批处理备份文件
目的: 1.计划每天每半小时备份1次,每天8点开始,执行12小时,20点结束. 2.定期删除历史备份文件,由于每天有多个时间段备份,删除前只保留当天最后一个备份. 说明: 由于删除的操作只有每天第一次 ...
- backup4:数据库自动备份,自动删除备份文件
一:手写TSQL 脚本 1,自动备份 每周进行一次Database 的 Full Backup,设置 Schedule Interval 为Weekly use master go ) )+N'.ba ...
- C#调用vbs脚本实现Windows版Siri
最近新加入,把自己一些有意思的小东西分享给大家,我是一个学生,代码写得少,哪里不规范,希望大家见谅. 这事我封装好的一个类,可以直接实例化对象之后,调用"对象.Talk()"方法, ...
- 在WinCC中通过VBS操作SQL Server2005
在项目中需要在一定条件满足时,保存一些数据到数据库中,并可根据条件查询.考虑到WinCC6.2以后采用的就是SQL Server2005数据库,所以直接利用该数据库即可,通过SQL Server Ma ...
- 使用vbs脚本进行批量编码转换
使用vbs脚本进行批量编码转换 最近需要使用SourceInsight查看分析在Linux系统下开发的项目代码,我们知道Linux系统中文本文件默认编码格式是UTF-8,而Windows中文系统中的默 ...
- SQL Server 通过备份文件初始化复制
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 搭建过程(Process) 注意事项(Attention) 疑问(Questions) 参考文 ...
随机推荐
- AR增强现实开发介绍(续)
AR增强现实开发介绍(续) ---开发基础篇 开发增强现实技术,无论是商业级应用,还是面向幼儿教育的游戏产品,都需要从了解.获取.下载增强现实插件开始.目前全世界使用量最大公认最好的增强现实插件是高通 ...
- [SpringBoot guides系列翻译]调用RESTfulWebService
原文 参考链接 CommandLineRunner Bean 翻译如何调用RESTful WebService 这节将演示如何在SpringBoot里面调用RESTful的WebService. 构建 ...
- Eureka配置instanceId显示IP
直接配置: eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ instance: prefer-ip-add ...
- .net MVC +EF+VUE做回合制游戏(二)
Emmm,游戏中的属性购买页面 话不多说先上代码 <form id="vue" action="/ltgdGame.Web/Main/Index" met ...
- 携程Apollo一键编译脚本+部署实现
系统编译安装 ubuntu16.11 java 1.8 系统规划 Portal共用 其它环境每个两台机器 mysql都做主从,所以每个环境的机器上都会安装admin 服务,config服务,以及一个m ...
- SAP MM ME29N 试图取消审批报错 - Document has already been outputed(function not possible) -
SAP MM ME29N 试图取消审批报错 - Document has already been outputed(function not possible) - 今天收到用户的一个问题,说他试图 ...
- 基于python的种子搜索网站,你懂得!
该项目是基于python的web类库django开发的一套web网站,给师弟做的毕业设计.本人的研究方向是一项关于搜索的研究项目.在该项目中,笔者开发了一个简单版的搜索网站,实现了对数据库数据的检索和 ...
- 一种解决Android studio 3.0 Build报错的方法
问题背景: 最近在开始使用AndroidStudio3.0,刚好有一个开源的项目(Material-Movies),需要学习下.因为该项目比较早(2015年),而这段时间AndroidStudio和G ...
- 30号快手笔试(三道ac两道半)————-历史上最大的网络失误orz
case 50 ,20,100 做题以来第一次重大失误:最后两分钟发现手机关机了,然后充电开机orz 页面是js代码, 钟表是一直会走的, 手机没电了, 电脑连接的手机的热点: 只顾在调试,先过了第 ...
- 手把手教新手小白在window把自己的项目上传到github
作为一个开发者,写博客,上传项目到github好像是不可不会的技能,很多有经验的老司机都会这么建议你.本宝宝第一次要把项目传到github的时候,确实有点蒙蔽,什么鬼,传个东西有必要这么难吗? git ...