It seems that there has been a lot of talk about backing up your apps or data. I see that several use sys_shell(). But why do you have to do that? Why cant you do what I have listed down below. This is a scaled down version. You could have it copy the files somwhere else and rename them.EX: lets say I have main.dbf and I want to back it up every day and keep a week of backups always handy. Have it copy the files once a day renaming the file file.rename(filename,date()+filename)(I havent tested this, I am just suggesting it). That way you would get 08/14/00main.dbf + 08/15/00main.dbf + etc..... You could have the app delete anything anything older than 7 days. Just a thought. Let me know what you think.
Of course this "|" is actually a back slash since this board eats them.
'These 3 lines can be whatever directories you want
source_dir = "||server1|c|visioneer docs"+chr(92)
old_dir=dir_get()
destination_dir="c:|Visioneer Backup"+chr(92)
dir_put(source_dir)
'I use *.max. You can set it to whatever you want. I believe you can use .AND. also.
'Read up on filefind. There are other options with it.
files=filefind.first("*.max")
WHILE .not. files.eof()
'The next three lines check the size of the file to be copied and store them in var->Filebytes
file_pointer=file.open(files.name(),FILE_RO_SHARED)
Filebytes=file_pointer.bytes_get()
file_pointer.close()
'Stores the name of the file in var->filenames
filenames=files.name()
file_copy(source_dir+var->filenames,destination_dir+var->filenames)
'The next lines check to see if the copy was successful
if file.exists(var->destination_dir+var->filenames)
file_pointer=file.open(files.name(),FILE_RO_SHARED)
Filebytecheck=file_pointer.bytes_get()
file_pointer.close()
if var->filebytecheck=var->filebytes
'Place what ever you want. In my App I have it write to a log file.
'Basically the above file check for corruption too. I figured
'if the bytes were off then something must of happened. I havent had
' a problem yet.
else
'Send it back to try and copy again. If it still doesnt match up have
'it terminate the script or skip that file
end if
End If
files.next()
END WHILE
dir_put(old_dir)
END
Of course this "|" is actually a back slash since this board eats them.
'These 3 lines can be whatever directories you want
source_dir = "||server1|c|visioneer docs"+chr(92)
old_dir=dir_get()
destination_dir="c:|Visioneer Backup"+chr(92)
dir_put(source_dir)
'I use *.max. You can set it to whatever you want. I believe you can use .AND. also.
'Read up on filefind. There are other options with it.
files=filefind.first("*.max")
WHILE .not. files.eof()
'The next three lines check the size of the file to be copied and store them in var->Filebytes
file_pointer=file.open(files.name(),FILE_RO_SHARED)
Filebytes=file_pointer.bytes_get()
file_pointer.close()
'Stores the name of the file in var->filenames
filenames=files.name()
file_copy(source_dir+var->filenames,destination_dir+var->filenames)
'The next lines check to see if the copy was successful
if file.exists(var->destination_dir+var->filenames)
file_pointer=file.open(files.name(),FILE_RO_SHARED)
Filebytecheck=file_pointer.bytes_get()
file_pointer.close()
if var->filebytecheck=var->filebytes
'Place what ever you want. In my App I have it write to a log file.
'Basically the above file check for corruption too. I figured
'if the bytes were off then something must of happened. I havent had
' a problem yet.
else
'Send it back to try and copy again. If it still doesnt match up have
'it terminate the script or skip that file
end if
End If
files.next()
END WHILE
dir_put(old_dir)
END
Comment