-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
One usage of your script is to make backup of LVM volumes. Or more precisely snapshots of LVM volumes. This works quite well.
However there are some security considerations that might make it better to initiate the backup process from the backup target - if the production machine is impacted then the backups are still inaccessible.
I have made a small modification. Looks like it is working for LVM2LVM copy. I have not touched any aspects of file creating and safety. Would be nice if someone reviews this (maybe improves) and merges.
diff blocksync.py blocksync_v2.py
110c110,114
< f, size = do_open(dev, 'rb+')
---
> if options.reverse:
> f, size = do_open(dev, 'rb')
> else:
> f, size = do_open(dev, 'rb+')
>
133,138c137,146
< newblock = stdin.read(blocksize)
< newblocklen = len(newblock)
< f.seek(-newblocklen, 1)
< f.write(newblock)
< if USE_DONTNEED:
< fadvise(f, f.tell() - newblocklen, newblocklen, POSIX_FADV_DONTNEED)
---
> if options.reverse:
> stdout.write(block)
> stdout.flush()
> else:
> newblock = stdin.read(blocksize)
> newblocklen = len(newblock)
> f.seek(-newblocklen, 1)
> f.write(newblock)
> if USE_DONTNEED:
> fadvise(f, f.tell() - newblocklen, newblocklen, POSIX_FADV_DONTNEED)
188c196,199
< f, size = do_open(srcdev, 'rb')
---
> if options.reverse:
> f, size = do_open(srcdev, 'rb+')
> else:
> f, size = do_open(srcdev, 'rb')
245a257,259
> if options.reverse:
> cmd += ['-R']
>
320,322c334,343
< p_in.write(l_block)
< p_in.flush()
<
---
> if options.reverse:
> newblock = p_out.read(blocksize)
> newblocklen = len(newblock)
> f.seek(-newblocklen, 1)
> f.write(newblock)
> if USE_DONTNEED:
> fadvise(f, f.tell() - newblocklen, newblocklen, POSIX_FADV_DONTNEED)
> else:
> p_in.write(l_block)
> p_in.flush()
361a383
> parser.add_option("-R", "--reverse", dest = "reverse", action = "store_true", help = "Remote location to local", default = False)
Metadata
Metadata
Assignees
Labels
No labels