/* REXX script to copy SOURCE storage to TARGET storage folders */ CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' CALL SysLoadFuncs /* parse the command line to pick up the BACKUP_TYPE, SOURCE and TARGET locations */ arg backup_type source target /* check to see if a backup_type was specified */ if backup_type = '' then backup_type = 'UNKNOWN' say 'Starting RSYNC for LOCAL to' backup_type 'backup!' say "" say "SOURCE => " || source say "TARGET => " || target say "" /* check to see if we have the input params */ if (backup_type = '') | (source = '') | (target = '') then do say "ERROR => Missing BACKUP_TYPE, SOURCE and/or TARGET locations!" say say "Usage => RSYNC_BACKUP (LOCAL/NAS) SOURCE TARGET" return end else do /* let's make the RSYNC LOG filename */ rsync_log_file = 'G:\tmp\log\rsync_'||backup_type||'_backup.log ' /* OK, ready to run, so let's put together the RSYNC CLI */ if backup_type = 'NAS' then do CLI = '--dry-run --archive --delete --progress --stats --whole-file --no-xattrs --human-readable --quiet --exclude-from=G:\mptn\etc\rsync_exclude --log-file='||rsync_log_file source target end else if backup_type = 'LOCAL' then do /* WIP => need to put in LOCAL OS/2 specific RSYNC parameters to preserve the extended attributes, etc. */ CLI = '--dry-run --archive --delete --progress --stats --whole-file --no-xattrs --human-readable --quiet --exclude-from=G:\mptn\etc\rsync_exclude --log-file='||rsync_log_file source target end /* show the RSYNC command line */ say "RSYNC CLI =>" CLI say "" /* get the START message built */ datetime_stamp = date('U')||" - "||time('N') msg_start = "RSYNC started: "||datetime_stamp||"..." /* update the RSYNC LOG file with NEW run stamp */ call lineout rsync_log_file,"==================================================================================" call lineout rsync_log_file,msg_start call lineout rsync_log_file,"" call lineout rsync_log_file,"SOURCE => "||source call lineout rsync_log_file,"TARGET => "||target call lineout rsync_log_file,"" call lineout rsync_log_file,"RSYNC CLI =>"||CLI call lineout rsync_log_file,"-----------------------------------------" call lineout rsync_log_file say msg_start /* reset the timer to 0, we will use later to get TOTAL duration */ call time('r') /* run the RSYNC command with command line input params */ '@g:\usr\bin\rsync' CLI /* get the FINISH message built */ datetime_stamp = date('U')||" - "||time('N') msg_finish = "RSYNC completed: "||datetime_stamp||"..." /* update the RSYNC LOG file with NEW run stamp */ call lineout rsync_log_file,"-----------------------------------------" call lineout rsync_log_file,msg_finish call lineout rsync_log_file,"==================================================================================" call lineout rsync_log_file say "" say msg_finish say "" say "RSYNC took "||time('e')||" seconds to complete the "||backup_type||" backup task!" end exit