def initCache(): global _initialized if _initialized: return None zfsreturn = runZFS( ["list", "-Hp", "-o", "name,mountpoint,usedbydataset,usedbysnapshots"]) for line in iter(zfsreturn.stdout.splitlines()): arr = line.split() dataset, path, data_used, snap_used = arr zfsmap[path] = dataset zfsmap[dataset] = path if path in config.paths: place = config.paths[path] zfsmap[place.name] = dataset place.data_used = data_used place.snap_used = snap_used zfsreturn = runZFS(["list", "-Hp", "-t", "snap"]) for line in iter(zfsreturn.stdout.splitlines()): arr = line.split() snapname = arr[0] dataset, snap = snapname.split('@') if Snapshot.isSnappyZFS(snap) and dataset in zfsmap and zfsmap[ dataset] in config.paths: newsnapshot = Snapshot.factory(config.paths[zfsmap[dataset]].name, Snapshot.isSnappyZFS(snap).group(1)) newsnapshot.setZFS(snapname) _initialized = True
def initCache(): global _initialized if _initialized: return None zfsreturn = runZFS(["list","-Hp","-o","name,mountpoint,usedbydataset,usedbysnapshots"]) for line in iter(zfsreturn.stdout.splitlines()): arr = line.split() dataset, path, data_used, snap_used = arr zfsmap[path] = dataset zfsmap[dataset] = path if path in config.paths: place = config.paths[path] zfsmap[place.name] = dataset place.data_used = data_used place.snap_used = snap_used zfsreturn = runZFS(["list","-Hp","-t","snap"]) for line in iter(zfsreturn.stdout.splitlines()): arr = line.split() snapname = arr[0] dataset,snap = snapname.split('@') if Snapshot.isSnappyZFS(snap) and dataset in zfsmap and zfsmap[dataset] in config.paths: newsnapshot = Snapshot.factory(config.paths[zfsmap[dataset]].name, Snapshot.isSnappyZFS(snap).group(1)) newsnapshot.setZFS(snapname) _initialized = True
def list(): util.loadSnapshots() for name, place in sorted(config.places.items()): print("***** %s (%s) %s / %s" % (name, place.path, util.readableBytes( place.data_used), util.readableBytes(place.snap_used))) Snapshot.printHeader() for stamp in sorted(snapshots[name].keys(), key=lambda i: int(i)): snapshots[name][stamp].printListing()
def createSnapshot(place, stamp): initCache() zfssnapname = "snappy-%s" % stamp zfsfullsnapname = "%s@%s" % (zfsmap[place.name], zfssnapname) print("snapZFS: %s" % zfsfullsnapname) runZFS(["snapshot", zfsfullsnapname]) # Place this in the global list in case tarsnap is going to want it newsnapshot = Snapshot.factory(place, stamp) newsnapshot.setZFS(zfsfullsnapname)
def createSnapshot(place,stamp): initCache() zfssnapname = "snappy-%s" % stamp zfsfullsnapname = "%s@%s" % (zfsmap[place.name],zfssnapname) print("snapZFS: %s" % zfsfullsnapname) runZFS(["snapshot", zfsfullsnapname]) # Place this in the global list in case tarsnap is going to want it newsnapshot = Snapshot.factory(place,stamp) newsnapshot.setZFS(zfsfullsnapname)
def initCache(): global _initialized global cache if _initialized: return None if os.path.isfile(CACHE_FILE): readCache() else: tsout = runTarsnap(["--list-archives"]) cache = tsout.stdout.splitlines() for line in cache: if Snapshot.isSnappyTS(line): groups = Snapshot.isSnappyTS(line) place = groups.group(1) stamp = groups.group(2) newsnapshot = Snapshot.factory(place, stamp) newsnapshot.setTarsnap(line.rstrip()) writeCache() _initialized = True
def initCache(): global _initialized global cache if _initialized: return None if os.path.isfile(CACHE_FILE): readCache() else: tsout = runTarsnap(["--list-archives"]) cache = tsout.stdout.splitlines() for line in cache: if Snapshot.isSnappyTS(line): groups = Snapshot.isSnappyTS(line) place = groups.group(1) stamp = groups.group(2) newsnapshot = Snapshot.factory(place,stamp) newsnapshot.setTarsnap(line.rstrip()) writeCache() _initialized = True