`bup midx` creates a multi-index (.midx) file from one or more
git pack index (.idx) files.
-You should run this command
-occasionally to ensure your backups run quickly and without
-requiring too much RAM.
+Note: you should no longer need to run this command by hand.
+It gets run automatically by `bup-save`(1) and similar
+commands.
# OPTIONS
--o, --output
+-o, --output=*filename.midx*
: use the given output filename for the .midx file.
Default is auto-generated.
already exist. This will result in the fastest backup
performance, but may take a long time to run.
+--dir=*packdir*
+: specify the directory containing the .idx/.midx files
+ to work with. The default is $BUP_DIR/objects/pack and
+ $BUP_DIR/indexcache/*.
+
--max-files
: maximum number of .idx files to open at a time. You
can use this if you have an especially small number of file
consecutive objects are often stored in the same pack, so
we can search that one first using an MRU algorithm.)
-With large repositories, you should be sure to run
-`bup midx -a` or `bup midx -f` every now and then so that
-creating backups will remain efficient.
-
# SEE ALSO
: Print detailed help for the given command
`bup-index`(1)
: Create or display the index of files to back up
-`bup-midx`(1)
-: Index objects to speed up future backups
`bup-on`(1)
: Backup a remote machine to the local one
`bup-save`(1)
: Determine how close your bup repository is to armageddon
`bup-memtest`(1)
: Test bup memory usage statistics
+`bup-midx`(1)
+: Index objects to speed up future backups
`bup-newliner`(1)
: Make sure progress messages don't overlap with output
`bup-random`(1)
a,auto automatically create .midx from any unindexed .idx files
f,force automatically create .midx from *all* .idx files
max-files= maximum number of idx files to open at once [-1]
+dir= directory containing idx/midx files
"""
def _group(l, count):
DESIRED_HWM = opt.force and 1 or 5
DESIRED_LWM = opt.force and 1 or 2
existed = dict((name,1) for sz,name in all)
- log('%d indexes; want no more than %d.\n' % (len(all), DESIRED_HWM))
+ log('midx: %d indexes; want no more than %d.\n' % (len(all), DESIRED_HWM))
if len(all) <= DESIRED_HWM:
- log('Nothing to do.\n')
+ log('midx: nothing to do.\n')
while len(all) > DESIRED_HWM:
all.sort()
part1 = [name for sz,name in all[:len(all)-DESIRED_LWM+1]]
if extra:
do_midx(git.repo('objects/pack'), opt.output, extra)
elif opt.auto or opt.force:
- paths = [git.repo('objects/pack')]
- paths += glob.glob(git.repo('index-cache/*/.'))
+ if opt.dir:
+ paths = [opt.dir]
+ else:
+ paths = [git.repo('objects/pack')]
+ paths += glob.glob(git.repo('index-cache/*/.'))
for path in paths:
log('midx: scanning %s\n' % path)
do_midx_dir(path)
self.check_ok()
f.close()
os.rename(fn + '.tmp', fn)
+ git.auto_midx(self.cachedir)
def _make_objcache(self):
ob = self._busy
return os.path.join(repodir, sub)
+def auto_midx(objdir):
+ main_exe = os.environ.get('BUP_MAIN_EXE') or sys.argv[0]
+ args = [main_exe, 'midx', '--auto', '--dir', objdir]
+ rv = subprocess.call(args, stdout=open('/dev/null', 'w'))
+ if rv:
+ add_error('%r: returned %d' % (args, rv))
+
+
def mangle_name(name, mode, gitmode):
"""Mangle a file name to present an abstract name for segmented files.
Mangled file names will have the ".bup" extension added to them. If a
os.unlink(self.filename + '.map')
os.rename(self.filename + '.pack', nameprefix + '.pack')
os.rename(self.filename + '.idx', nameprefix + '.idx')
+
+ auto_midx(repo('objects/pack'))
return nameprefix
def close(self):
fuse = 'Mount your backup sets as a filesystem',
help = 'Print detailed help for the given command',
index = 'Create or display the index of files to back up',
- join = 'Retrieve a file backed up using "bup split"',
- ls = 'Browse the files in your backup sets',
- midx = 'Index objects to speed up future backups',
on = 'Backup a remote machine to the local one',
save = 'Save files into a backup set (note: run "bup index" first)',
- split = 'Split a single file into its own backup set',
web = 'Launch a web server to examine backup sets',
)