TapeTrack Documentation

Because there is more to tape management than you ever realized

User Tools

Site Tools


technote:syncwatcher

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
technote:syncwatcher [2019/04/15 18:36] dcummingtechnote:syncwatcher [2025/01/21 22:07] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Running Syncs with inotify ======+====== Running Syncs with incrond ======
  
-The following script can be used to run the TapeTrack Synchronization command whenever a file is uploaded with FTP or SFTP.+{{tag>technote schedule sync linux update-doco}}
  
-The script does the following: 
- 
-  - Listens using ''inotify'' for a change to the directory ''/var/sftp/user/upload''. 
-  - Spawns a separate thread to run the syncronization. 
-  - Writes output to the reports directory with a time and date stamp. 
-  - Loops back to listen to for the next uploaded file. 
- 
-<sxh bash;> 
-#!/bin/bash 
- 
-function control_c { 
-   logger -s -t TapeTrackSyncWatcher Request to end TapeTrack Sync Watcher recieved 
-   exit 
-}; 
- 
-set -e 
- 
-trap control_c SIGINT 
-trap control_c SIGTERM 
- 
-logger -s -t TapeTrackSyncWatcher Starting TapeTrack Sync Watcher 
- 
-outfile=$(mktemp "${TMPDIR:-/tmp/}syncwatch.XXXXXXXXXXXX") 
- 
-while true; do 
-   # 
-   # Wait on a change to the sftp directory 
-   # 
-   inotifywait -r -e close_write /var/sftp > $outfile 2> /dev/null 
- 
-   # 
-   # A chance has been made so read the results into 3 variables (path, type, file) 
-   # 
-   read -r r1 r2 r3 < $outfile 
- 
-   # 
-   # Delete the temp file 
-   # 
-   rm $outfile 
- 
-   base=`cut -d'/' -f-4 <<< $r1` 
- 
-   if grep -q "/upload/" <<< $r1 ; then 
-      logger -s -t TapeTrackSyncWatcher Launching Sync fpr file $r1$r3 
-      now=$(date +"%m_%d_%Y_%H_%M_%S") 
-      syncfile=$r1$r3 TMSS10Sync -d $base/etc/default.ttidef > $base/reports/stdout-$now.txt 2> $base/reports/stderr-$now.txt & 
-   else 
-      logger -s -t TapeTrackSyncWatcher Skipping file update for file $r1$r3 
-   fi 
-done 
- 
-exit 
-</sxh> 
technote/syncwatcher.1555353379.txt.gz · Last modified: 2025/01/21 22:07 (external edit)