File: fssync_root

package info (click to toggle)
fssync 1.7-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 176 kB
  • sloc: python: 1,605; makefile: 26
file content (32 lines) | stat: -rw-r--r-- 858 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python3
import os, stat, sys

# Example wrapper for Debian root partition.

def my_filter(root, p, s):
  try:
    r, p = p.split('/', 1)
  except ValueError:
    pass
  else:
    try:
      d, b = p.rsplit('/', 1)
    except ValueError:
      pass
    else:
      if r == 'var':
        if p.startswith('lib/apt/lists/'):
          return b != 'lock' and stat.S_ISREG(s.mode)
        if d in ('lib', 'log'):
          return b.startswith('fssync.')
        if d == 'cache/apt':
          return b.endswith('cache.bin')
        return d == 'tmp'

log = '/var/log/fssync.log'
remote = '/mnt/backup-root'
sys.argv[1:1] = ('-f', my_filter.__name__, '-R', remote,
                 '-v', '-l', log, '-L', remote + log,
                 '-d', '/var/lib/fssync.db', '-r', '/')
fssync = '/usr/bin/fssync'
exec(compile(open(fssync).read(), fssync, 'exec'))