//============================================================================== // // Task: SYNCDTSZ.TSK // (SYNC files less than 1 year old and less than 10 MB in size) // Author: Avanti Technology, Inc. // http://www.avanti-tech.com // Version: 1.0 - New Template // (04 June 2003) // // Description: // ============ // This task is designed to synchronize files within a directory structure // that are less than a year old and under 10 MB in size to a backup structure. // // Three options exist: // -------------------- // 1). SYNC matching files individually // - Potentially to be too slow and resource intensive (due to repetitive // launch of SYNC for only a single file) IF many files must be processed. // // 2). SYNC the entire source base directory structure after building an // exclusion list of files not matching the synchronization criteria // - The exclusion list may become too large to process (limit 12288 // files) if there are too many files which do not meet the criteria // in the directory structure. // // Example: // -------- // Base directory: USERS // Subdirs & count: USER1 (18 dirs/5000 files total/200 match criteria) // USER2 (12 dirs/4000 files total/100 match criteria) // USER3 (15 dirs/6000 files total/300 match criteria) // // The USERS base directory tree structure contains 3 User directories // with 45 subdirectories and 15000 files, of which only 600 match the // synchronization criteria. Therefore, 14400 files need to be excluded // (greater than the 12288 limit for the exclusion list) in a SYNC. // // 3). SYNC the individual subdirectory structures underneath the base // directory structure after building an exclusion list of files not // matching the synchronization criteria for each subdirectory structure. // - This is the approach this task takes. // // Example: // -------- // Using the example table figures above, each User directory would be // processed individually so that no more than 5700 files would need to // be excluded by any SYNC process (USER3 - 6000 files / 300 matches - // well within the 12288 limit for an exclusion list). // // Note: If you want to further limit the processing to a specific file type // ----- by extension (e.g., WordPerfect files - .WPD 8.3 DOS extensions), // change the *.* in both the %DIR_FILE_*.*% and in the SYNC %0\%2\*.* // to only process files matching that extension (i.e., *.WPD). // // // Usage: // ====== // Script can be manually executed using the TaskMaster TMRUN command // at the TMConsole (Shell) Screen: // // Example: TMRUN [vol:path\]SYNCDTSZ.TSK // // Note: [vol:path\] is not required if the task resides either // in SYS:SYSTEM or the TaskMaster NLM load directory. // // Script can be scheduled for automatic execution using Client interface or // using the TaskMaster TMSCHEDULE command at the TMConsole (Shell) Screen: // // Examples: TMSCHEDULE ADD SYNCDTSZ.TSK 01 02:00 // (Executes the 1st of each month at 2:00am) // // TMSCHEDULE ADD SYNCDTSZ.TSK YNNNNNN 02:00 // (Executes every Sunday [SMTWTFS] at 2:00am) // // Note: Scheduled tasks must reside either in SYS:SYSTEM or the // TaskMaster NLM load directory for security reasons. // // Compatibility: // ============== // This task has been tested on the following platforms without demonstrating // any compatibility issues or any other reported/confirmed conflicts: // TaskMaster v3.23, TaskMaster Lite v3.23 // NetWare v3.12 / v3.2 / v4.1x / v5.x / v6.0 // // Warning: // ======== // AS WITH ANY NEW SOFTWARE PROGRAM, BATCH SCRIPT, OR AUTOMATED PROCESSING // PROCEDURE, CAUTION SHOULD BE EXERCISED AND DUE DILIGENCE OBSERVED DURING // INITIAL IMPLEMENTATION. WHERE POSSIBLE, TESTING SHOULD BE PERFORMED ON // NON-PRODUCTION SYSTEMS PRIOR TO FULL IMPLEMENTATION. // // Comments: // ========= // This task script is provided free of charge and without any warranty or // guarantee of fitness of purpose or performance. // // For additional TaskMaster script examples, visit the Sample Tasks page // on the Avanti Technology, Inc. WEB Site: http://www.avanti-tech.com // //============================================================================= // // Variables used: // // %0 Source base directory containing User subdirectories // %1 Destination base directory containing User subdirectories // %2 User directories processed under the source base directory // %3 User directory tree structure // %4 File within User directory tree structure (to be checked for date/size) // %7 Last update date (yyyy/mm/dd) to SYNC (i.e., exclude older/previous dates) // %8 SYNC exclusion file (listing files NOT to be synchronized) // %9 Task log file (for status/error logging) // //============================================================================== // Source base directory containing the User directories to be processed DEFINE %0 SYS:\HOME // Destination base directory containing the User directories to be synchronized DEFINE %1 BACKUP:\USERS // SYNC exclusion file list DEFINE %8 SYS:\HOME\SYNCDTSZ.EXC // Task status/error log to track the processing DEFINE %9 SYS:\HOME\SYNCDTSZ.LOG // Create/overwrite the status/error log OPEN_WRITE %9 TRUNCATE IF ERRORLEVEL ECHO_WRITE. ECHO_WRITE %TASK% - ERROR ECHO_WRITE %9 - Unable to Create/overwrite status/error log! ECHO_WRITE Check validity of path/name and for conflicts. ECHO_WRITE. ABORT ENDIF // Write a header to record the start WRITE *********************************** WRITE Task started: %MONTH%/%DAY%/%YEAR% @ %HOUR%:%MINUTE% %AM_PM% WRITE *********************************** // Change CWD to source base directory CD %0 // Determine the year one year ago CALC %7 %YEAR%-1 // Last update date (yyyy/mm/dd) to SYNC (i.e., exclude older/previous dates) DEFINE %7 %7/%MONTH%/%DAY% // Update the status WRITE Excluding files older than %7 or larger than 10 MB // Base WHILE/LOOP which processes each User directory under the source WHILE // Initial/first %DIR_SUB_% pass assumes %2 NULL (undefined) and // CWD as source base directory to initiate User directory search. // Subsequent/next %DIR_SUB_% passes do not supply a spec and return a // NULL value once all User subdirs are returned (i.e., no more subdirs). IF "%2"=="" DEFINE %2 %DIR_SUB_*.*% ELSE DEFINE %2 %DIR_SUB_% ENDIF // Check for NULL return (search exhausted/complete - no more) IF "%2"=="" THEN BREAK // Change the CWD to the first/next User directory CD %2 // Update the status WRITE %CWD% - processing // Create exclusion list file // (Note: The status/error log is closed by reuse of the OPEN_WRITE.) OPEN_WRITE %8 TRUNCATE IF ERRORLEVEL // Re-open status/error log (in case closed by failed OPEN_WRITE) OPEN_WRITE %9 ECHO_WRITE. ECHO_WRITE %TASK% - ERROR ECHO_WRITE %9 - Unable to Create/overwrite status/error log! ECHO_WRITE Check validity of path/name and for conflicts. ECHO_WRITE. ABORT ENDIF // Clear %3 to insure proper initialization of the User directory search DEFINE %3 // This loop does the actual processing of each User directory structure WHILE // Clear %4 to insure proper initialization of the directory file search DEFINE %4 // Process files in this dir before traversing next subdir in User tree WHILE // Initial/first %DIR_FILE_% pass assumes %4 NULL (undefined) and // CWD set to the desired User directory to initiate file search. // Subsequent/next %DIR_FILE_% passes do not need spec and return // NULL value once all files returned (i.e., no more files). IF "%4"=="" DEFINE %4 %DIR_FILE_*.*% ELSE DEFINE %4 %DIR_FILE_% ENDIF // Check for NULL return (search exhausted/complete - no more) IF "%4"=="" THEN BREAK // Check %FILE_UPDATE_% date for %7 or later (newer) // Check %FILE_SIZE_% for 10 MB or less // Skip the file if it matches both criteria IF "%7"<"%FILE_UPDATE_%CWD%\%4%" IF "%FILE_SIZE_%CWD%\%4%"<"10000000" CONTINUE ENDIF ENDIF // File did not meet one or more of the above criteria so exclude it WRITE %CWD%\%4 LOOP // Initial/first %DIR_TREE_% pass assumes %3 NULL (undefined) and // CWD as base User directory to initiate directory structure search. // Subsequent/next %DIR_TREE_% passes do not supply a spec and return a // NULL value once the tree has been traversed (i.e., no more subdirs). IF "%3"=="" DEFINE %3 %DIR_TREE_%CWD%% ELSE DEFINE %3 %DIR_TREE_% ENDIF // Check for NULL return (search exhausted/complete - no more) IF "%3"=="" THEN BREAK LOOP // Close the exclusion file (must be closed for SYNC to read) // CLOSE WRITE // Reset CWD to the base source directory CD %0 // Finished processing the directory structure for this User // so launch the SYNC to perform the actual synchronization // Note: Append %2 (%DIR_SUB_% return) to both %0 and %1 to // limit synchronization to the appropriate User structure. SYNC %0\%2\*.* %1\%2 /A /D /I /L /M /S <%8 >>%9 // Re-open the status/error log after SYNC redirection OPEN_WRITE %9 IF ERRORLEVEL ECHO_WRITE. ECHO_WRITE %TASK% - ERROR ECHO_WRITE %9 - Unable to re-open status/error log! ECHO_WRITE Check for conflicts. ECHO_WRITE. ABORT ENDIF LOOP // Update the status OPEN WRITE %9 IF NOT ERRORLEVEL WRITE ************************************ WRITE Task complete: %MONTH%/%DAY%/%YEAR% @ %HOUR%:%MINUTE% %AM_PM% WRITE Elapsed time: %ELAPSED_TIME% WRITE ************************************ ENDIF // Good housekeeping dictates that all open files be closed prior to exiting CLOSE