]> arthur.barton.de Git - bup.git/blobdiff - cmd/index-cmd.py
Set pipefail so that "x | y || exit $?" will work properly.
[bup.git] / cmd / index-cmd.py
index 5a8913d378733d32435c57c8708031891067c089..539bc50561cf1e7e130a1137db434e9d889e5d37 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-import sys, stat, time, os, errno
+import sys, stat, time, os, errno, re
 from bup import metadata, options, git, index, drecurse, hlinkdb
 from bup.helpers import *
 from bup.hashsplit import GIT_MODE_TREE, GIT_MODE_FILE
@@ -62,7 +62,7 @@ def clear_index(indexfile):
                 raise
 
 
-def update_index(top, excluded_paths):
+def update_index(top, excluded_paths, exclude_rxs):
     # tmax and start must be epoch nanoseconds.
     tmax = (time.time() - 1) * 10**9
     ri = index.Reader(indexfile)
@@ -82,7 +82,8 @@ def update_index(top, excluded_paths):
     bup_dir = os.path.abspath(git.repo())
     for (path,pst) in drecurse.recursive_dirlist([top], xdev=opt.xdev,
                                                  bup_dir=bup_dir,
-                                                 excluded_paths=excluded_paths):
+                                                 excluded_paths=excluded_paths,
+                                                 exclude_rxs=exclude_rxs):
         if opt.verbose>=2 or (opt.verbose==1 and stat.S_ISDIR(pst.st_mode)):
             sys.stdout.write('%s\n' % path)
             sys.stdout.flush()
@@ -117,7 +118,8 @@ def update_index(top, excluded_paths):
             # in from_stat().
             meta.ctime = meta.mtime = meta.atime = 0
             meta_ofs = msw.store(meta)
-            rig.cur.from_stat(pst, meta_ofs, tstart)
+            rig.cur.from_stat(pst, meta_ofs, tstart,
+                              check_device=opt.check_device)
             if not (rig.cur.flags & index.IX_HASHVALID):
                 if hashgen:
                     (rig.cur.gitmode, rig.cur.sha) = hashgen(path)
@@ -179,11 +181,13 @@ clear      clear the index
  Options:
 H,hash     print the hash for each object next to its name
 l,long     print more information about each file
+no-check-device don't invalidate an entry if the containing device changes
 fake-valid mark all index entries as up-to-date even if they aren't
 fake-invalid mark all index entries as invalid
 f,indexfile=  the name of the index file (normally BUP_DIR/bupindex)
 exclude=   a path to exclude from the backup (can be used more than once)
 exclude-from= a file that contains exclude paths (can be used more than once)
+exclude-rx= skip paths that match the unanchored regular expression
 v,verbose  increase log output (can be used more than once)
 x,xdev,one-file-system  don't cross filesystem boundaries
 """
@@ -223,13 +227,14 @@ if opt.clear:
     clear_index(indexfile)
 
 excluded_paths = parse_excludes(flags, o.fatal)
+exclude_rxs = parse_rx_excludes(flags, o.fatal)
 paths = index.reduce_paths(extra)
 
 if opt.update:
     if not extra:
         o.fatal('update mode (-u) requested but no paths given')
     for (rp,path) in paths:
-        update_index(rp, excluded_paths)
+        update_index(rp, excluded_paths, exclude_rxs)
 
 if opt['print'] or opt.status or opt.modified:
     for (name, ent) in index.Reader(indexfile).filter(extra or ['']):