更新FileMgr.dll,优化创建目录逻辑
This commit is contained in:
parent
61a7287932
commit
2e099473c0
|
|
@ -1,7 +1,7 @@
|
||||||
FTP数据备份工具
|
<h1>FTP数据备份工具</h1>
|
||||||
|
|
||||||
使用步骤:
|
使用步骤:
|
||||||
1、TsFTP目录放入解释器所在目录的funcext中;
|
1、TsFTP目录放入解释器所在目录的funcext中,更新替换plugin\FileMgr.dll;
|
||||||
2、(可选)修改默认配置信息:TsFTP\TsFTPBackupConfig.tsf;
|
2、(可选)修改默认配置信息:TsFTP\TsFTPBackupConfig.tsf;
|
||||||
3、参考examples\example1.tsl编写备份脚本;
|
3、参考examples\example1.tsl编写备份脚本;
|
||||||
4、(可选)添加备份脚本的定时调度。
|
4、(可选)添加备份脚本的定时调度。
|
||||||
|
|
@ -19,7 +19,7 @@ Type TsFTPBackup = Class
|
||||||
Begin
|
Begin
|
||||||
if not Host then Host := defaultConfig['Host'];
|
if not Host then Host := defaultConfig['Host'];
|
||||||
if not port then port := defaultConfig['Port'];
|
if not port then port := defaultConfig['Port'];
|
||||||
if not port then port := 21;
|
if not port then port := 990;
|
||||||
if not username then username := defaultConfig['username'];
|
if not username then username := defaultConfig['username'];
|
||||||
if not password then password := defaultConfig['password'];
|
if not password then password := defaultConfig['password'];
|
||||||
if not initFtpObj() then return 0;
|
if not initFtpObj() then return 0;
|
||||||
|
|
@ -48,14 +48,14 @@ Type TsFTPBackup = Class
|
||||||
Begin
|
Begin
|
||||||
path := ExtractFilePath(src);
|
path := ExtractFilePath(src);
|
||||||
files := filelist('',src);
|
files := filelist('',src);
|
||||||
|
try
|
||||||
|
ftpObj.MakeDir(destPath);
|
||||||
|
except
|
||||||
|
end;
|
||||||
for j,f in files do begin
|
for j,f in files do begin
|
||||||
if f['FileName']='.' or f['FileName']='..' then continue;
|
if f['FileName']='.' or f['FileName']='..' then continue;
|
||||||
if pos('D',f['Attr']) then begin
|
if pos('D',f['Attr']) then begin
|
||||||
if recursive then begin
|
if recursive then begin
|
||||||
try
|
|
||||||
ftpObj.MakeDir(destPath+f['FileName']+'/');
|
|
||||||
except
|
|
||||||
end;
|
|
||||||
backupPath(path+'\\'+f['FileName']+"\\*",destPath+f['FileName']+'/',recursive);
|
backupPath(path+'\\'+f['FileName']+"\\*",destPath+f['FileName']+'/',recursive);
|
||||||
end;
|
end;
|
||||||
end else if f['Attr']='A' then begin
|
end else if f['Attr']='A' then begin
|
||||||
|
|
@ -100,7 +100,13 @@ Type TsFTPBackup = Class
|
||||||
return 2;
|
return 2;
|
||||||
end;
|
end;
|
||||||
st_put:=CreateObject("TFileStream","",srcfile,0);
|
st_put:=CreateObject("TFileStream","",srcfile,0);
|
||||||
ret := ftpObj.Put(st_put,destfile,0);
|
try
|
||||||
|
ret := ftpObj.Put(st_put,destfile,0);
|
||||||
|
except
|
||||||
|
msg := '源文件('+srcfile+')->目标文件('+destfile+')上传失败。';
|
||||||
|
log(msg,'error');
|
||||||
|
return 0;
|
||||||
|
end;
|
||||||
size_d := ftpObj.Size(destfile);
|
size_d := ftpObj.Size(destfile);
|
||||||
if size_s=size_d then begin
|
if size_s=size_d then begin
|
||||||
msg := '源文件('+srcfile+')->目标文件('+destfile+')上传成功。';
|
msg := '源文件('+srcfile+')->目标文件('+destfile+')上传成功。';
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
Function TsFTPBackupConfig();
|
Function TsFTPBackupConfig();
|
||||||
Begin
|
Begin
|
||||||
return array(
|
return array(
|
||||||
'Host':'192.168.0.1',
|
'Host':'192.168.104.42',
|
||||||
'Port':21,
|
'Port':990,
|
||||||
'username':'',
|
'username':'',
|
||||||
'password':'',
|
'password':'',
|
||||||
'logPath':'',
|
'logPath':'',
|
||||||
Binary file not shown.
Loading…
Reference in New Issue