File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ services:
1616 build: .
1717 container_name: "sync"
1818 volumes:
19- - /home/docker/bareos-sd /data/storage:/data
19+ - . /data/storage:/data
2020 - ./logs:/var/log/s3sync
2121```
2222the directory to watch must mounted in volume. In this exemple (for bareos : /home/docker/bareos-sd/data/storage)
Original file line number Diff line number Diff line change @@ -4,5 +4,5 @@ services:
44 build : .
55 container_name : " sync"
66 volumes :
7- - /home/docker/bareos-sd /data/storage:/data
7+ - . /data/storage:/data
88 - ./logs:/var/log/s3sync
Original file line number Diff line number Diff line change 1+ #!/usr/bin/python3
2+ import os .path
3+ import argparse
4+ import pyinotify
5+
6+ class EventHandler (pyinotify .ProcessEvent ):
7+ def process_IN_CLOSE_WRITE (self , event ):
8+ print (f"IN_CLOSE_WRITE event detected on: { event .pathname } " )
9+ def process_IN_DELETE (self ,event ):
10+ print (f"IN_DELETE event detected on: { event .pathname } " )
11+ def main ():
12+ global __SECTION__
13+ parser = argparse .ArgumentParser ()
14+ parser .add_argument ('--path' , help = 'configFile' ,default = '/data' )
15+ args = parser .parse_args ()
16+ path = args .path
17+ wm = pyinotify .WatchManager ()
18+ mask = pyinotify .IN_CLOSE_WRITE | pyinotify .IN_DELETE
19+ notifier = pyinotify .Notifier (wm , EventHandler ())
20+ wm .add_watch (path , mask )
21+ try :
22+ notifier .loop ()
23+ except KeyboardInterrupt :
24+ print ("Stopped." )
25+ if __name__ == "__main__" :
26+ main ()
You can’t perform that action at this time.
0 commit comments