?
Solved

Backup script from windows to linux server

Posted on 2006-11-02
2
Medium Priority
?
191 Views
Last Modified: 2010-03-18
Hello,
i'am looking for a script that can permit to do backup.
I am using a windows 2003 file server and a linux redhat 9.
Some files are generated daily on windows and i want to put them on linux server at a specified moment.
After 7 days I want to delete files older than a week on both servers (windows and linux)

Regards!
0
Comment
Question by:brainskill
1 Comment
 
LVL 29

Accepted Solution

by:
mass2612 earned 375 total points
ID: 17863026
Hi,

Are do you have a shared folder configured on the Linux server that can be accessed from the Windows server? If so you can use a simple backup task via the default Windows Backup tool and backup your files to the Linux box and then schedule the backup job as a scheduled task. Here's some code to remove files older than 7 days. As always test these in a test environment first.

*** Windows vbScript ***
      ' WScript.Echo "Processing old backup file cleanup ...... "
      Dim oFSO, sDirectoryPath, oFolder, oFileCollection, oFile, iDaysOld
      'Customize values here to fit your needs
      iDaysOld = 7
      Set oFSO = CreateObject("Scripting.FileSystemObject")
      sDirectoryPath = "e:\backup"           ' can be a UNC path as well \\backupserver\share
      set oFolder = oFSO.GetFolder(sDirectoryPath)
      set oFileCollection = oFolder.Files
      'Walk through each file in this folder collection.
      'If it is older than 3 weeks (7) days, then delete it.
      For each oFile in oFileCollection
            If oFile.DateLastModified < (Date() - iDaysOld) Then
                  oFile.Delete(True)
            End If
      Next
      'Clean up
      Set oFSO = Nothing
      Set oFolder = Nothing
      Set oFileCollection = Nothing
      Set oFile = Nothing
*** End ***

*** Linux script  ***
# This will delete all files found in the backup_dir that have not been modifed in more than 7 days
export backup_dir=/data/backup
find $backup_dir -type f -mtime +7 | xargs rm -f
*** End ***
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve DNS query failed errors for Exchange
Measuring Server's processing rate with a simple powershell command. The differences in processing rate also was recorded in different use-cases, when a server in free and busy states.
Integration Management Part 2
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question