mpalmer / lvmsync

Synchronise LVM LVs across a network by sending only snapshotted changes
http://theshed.hezmatt.org/lvmsync
GNU General Public License v3.0
380 stars 60 forks source link

Way to reset?? #42

Closed pepa65 closed 9 years ago

pepa65 commented 9 years ago

On my very first run of lvmsync I did: lvmsync /dev/secret/os /dev/secret/osbackup I decided I wanted a verbose switch, so I interrupted, with this output: ^C/var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:292:in write': Interrupt from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:292:inprint' from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:292:in block (2 levels) in dump_changes' from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:282:ineach' from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:282:in block in dump_changes' from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:281:inopen' from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:281:in dump_changes' from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:231:inblock in run_client' from /usr/lib/ruby/1.9.1/open3.rb:208:in popen_run' from /usr/lib/ruby/1.9.1/open3.rb:90:inpopen3' from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:228:in run_client' from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:124:inmain' from /var/lib/gems/1.9.1/gems/lvmsync-3.3.0/bin/lvmsync:357:in <top (required)>' from /usr/local/bin/lvmsync:23:inload' from /usr/local/bin/lvmsync:23:in `

'

So then I did: lvmsync -v /dev/secret/os /dev/secret/osbackup Which led to this output: Data source: /dev/mapper/secret-ubuntu remote:Writing changed data to "/dev/secret/osbackup" Transferred 1290240 bytes in 2.58 seconds You transferred your changes 30112.10x faster than a full dd!

Which can't be true for a 36GB partition. The resulting /dev/secret/osbackup isn't mountable. So I'm wondering how to proceed, how can I 'reset' the somehow wrong information lvmsync is working with?

pepa65 commented 9 years ago

I removed both logical volumes, then created os again as a snapshot of my root partition, osbackup as a fresh logical volume, and got the same result as last time... The snapshot (os) is mountable, the lvsync-ed volume (osbackup) isn't... I'll try again with different names..?

pepa65 commented 9 years ago

Apparently I'm not understanding the capabilities of lvmsync... I tried again with different names. I am looking for a rsync-on-blockdevices tool, and since my blockdevices are lvm logical volumes, lvmsync sounded suitable from my understanding of reading the description...

mpalmer commented 9 years ago

Without knowing exactly how you created the snapshot, I can't determine what's going wrong. Could you please provide the complete set of commands you ran, from the point at which you created the snapshot?

As far as lvmsync being an "rsync-for-blockdevices" tool, it's not a complete equivalent to rsync. lvmsync only copies changes; it doesn't do the initial sync -- that's what the dd command, run between the snapshot creation and the lvmsync run, is for.

pepa65 commented 9 years ago

(What went wrong is, I didn't do the dd.) OK, so I want to periodically make device2 the same as device1. I make a snapshot of device1, dd that over to device2. Device1 will change further, but whenever I want to syncronize them, I use lvmsync to make device2 the same as device1. As long as the snapshot of device1 exists, this works.

Is this how it works?

mpalmer commented 9 years ago

That is one way to make it work. However, the snapshot will gradually get larger and larger, and the lvmsync runs will get longer and longer as a consequence.

The more efficient way of doing what you want is to make a second snapshot before you do the first lvmsync (against the first snapshot), then delete the first snapshot. You can continue to periodically do this "take new snapshot, lvmsync old snapshot, delete old snapshot" process, to update your mirror LV. It's not pretty, but it works.

pepa65 commented 9 years ago

Thanks for your help and explanations. I should have been able to gather all this from the documentation. Knowing about making a snapshot of the snapshot regularly is very helpful. Will try again.