#!/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
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)
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()
s,status print each filename with a status char (A/M/D) (implies -p)
u,update recursively update the index entries for the given file/dir names (default if no mode is specified)
check carefully check index file integrity
-clear clear the index
+clear clear the default index
Options:
H,hash print the hash for each object next to its name
l,long print more information about each file
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
"""
o.fatal('--fake-{in,}valid are meaningless without -u')
if opt.fake_valid and opt.fake_invalid:
o.fatal('--fake-valid is incompatible with --fake-invalid')
+if opt.clear and opt.indexfile:
+ o.fatal('cannot clear an external index (via -f)')
# FIXME: remove this once we account for timestamp races, i.e. index;
# touch new-file; index. It's possible for this to happen quickly
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 ['']):