首页 » SQL Server, 系统相关 » sql server 备份文件ftp批处理

sql server 备份文件ftp批处理

sql server 的维护计划可以定期的备份与删除备份文件,下面只提供备份文件从OS角度的处理方法,如何压缩传ftp服务器,及删除本地过期的压缩文件

策略:sqlserver每天备份删除昨天备份,rar每天压缩所有的库文件,每天删除三天前的rar文件,每天只上传当天的rar文件到ftp服务器

按顺序如下

--rar.bat--
start rar.exe a E:\daybak\192.168.217.141_db_%date:~0,10%.rar   E:\backup\*%date:~0,4%%date:~5,2%%date:~8,2%*.bak

--ftp.bat--
echo search current day rar-file
echo open 192.168.217.148 >ftp.txt
echo ftpuser>>ftp.txt
echo ftppassword>>ftp.txt
echo bin>>ftp.txt
echo lcd E:\daybak>>ftp.txt
echo put>>ftp.txt
dir /b e:\daybak\*%date:~0,10%.rar>>ftp.txt
dir /b e:\daybak\*%date:~0,10%.rar>>ftp.txt
echo bye>>ftp.txt
echo ok!
ftp -s:ftp.txt

--ftp.txt--
有上面的批处理生成
--del.bat--
@echo off
set /a date=%date:~0,4%%date:~5,2%%date:~8,2%-4
set date=%date:~0,4%-%date:~4,2%-%date:~6,2%
del /f/s/q E:\daybak\*%date%*.rar

加上操作系统的计划任务,合理的安排时间
打赏

目前这篇文章有1条评论(Rss)评论关闭。

  1. Christa Kirsten | #1
    2011-12-21 at 08:07

    Thanks for the writeup. I definitely agree with what you are saying. I have been talking about this subject a lot lately with my father so hopefully this will get him to see my point of view. Fingers crossed!