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) 参考文 ...
随机推荐
- 如何在linux下使用git管理上传代码&误删文件修复
首先需要安装git,sudo apt-get install git,这时就可以下载代码了. 然后先在gituhub上新建一个仓库,然后先在本地建一个git目录,git init 然后再配置用户名和邮 ...
- C# net request payload形式发送post请求
因为开发微信群发电脑版需要模拟微信POST请求,微信发送消息使用request payload发送,实际发送的是json字符串.我们只需要生成的json字符串和请求的一致,header头完全模拟即可. ...
- 浅谈基于Intellij IDEA Maven的配置与使用
在java开发中,引入jar包的方式从种类上划分,可分为自动导入和手动导入,然而,手动导入繁琐,不是很适合当前开发模式,手动导入也被自动导入所取代. 当前,Maven和Gradle是比较主流的自动导入 ...
- Python generator和yield介绍
Python生成器(generator)并不是一个晦涩难懂的概念.相比于MetaClass和Closure等概念,其较为容易理解和掌握.但相对于程序结构:顺序.循环和分支而言其又不是特别的直观.无论学 ...
- 使用Atlas进行元数据管理之容错和高可用
1. 介绍 Apache Atlas使用各种系统并与之交互,为数据管理员提供元数据管理和数据血缘信息.通过适当地选择和配置这些依赖关系,可以使用Atlas实现高度的服务可用性.本文档介绍了Atlas中 ...
- spring boot 2.0 ribbon 负载均衡配置
1.pom.xml <dependency> <groupId>org.springframework.cloud</groupId> <artifactId ...
- 基于windows环境的Flask网站搭建(mysql + conda + redis)
1下载mysql-installer-community-5.7.24.0.msi (https://dev.mysql.com/downloads/windows/installer/8.0.htm ...
- Android破解学习之路(十五)—— 【Unity3D】洛菲斯的呼唤(Lophis roguelike)无限金币(道具)的实现 破解
前言 之前玩月圆之夜玩的挺high的,最近又找到了个与月圆之夜类似的卡牌游戏,游戏名为Lophis roguelike,中文翻译名洛菲斯的呼唤. 但是这个与月圆之夜有所不同,如果失败了,只能从开头重新 ...
- windows下vagrant的安装使用
vagrant是简便虚拟机操作的一个软件,而使用虚拟机有几个好处: 1.为了开发环境与生产环境一致(很多开发环境为windows而生产环境为linux),不至于出现在开发环境正常而移步到正式生产环境时 ...
- SpringMVC归纳-1(model数据模型与重定向传参技术)
要点: model是一个Map结构的数据模型,能重定向时传递数据(拼接URL),但不安全,主要用于渲染前端页面,配合Thymeleaf填充html里面里设置好的参数. @RequestParam用来获 ...