Fix counting issue, Readme

This commit is contained in:
2022-11-01 19:26:56 +01:00
parent 21301838de
commit b60c086071
2 changed files with 38 additions and 36 deletions

View File

@@ -87,13 +87,6 @@ It'll work according this scheme:
* Rewrites VM configurations so they match the new VMID and/or poolname on the destination * Rewrites VM configurations so they match the new VMID and/or poolname on the destination
* Secure an encrypted transfer (SSH), so it's safe to mirror between datacenter without an additional VPN * Secure an encrypted transfer (SSH), so it's safe to mirror between datacenter without an additional VPN
## Protected / unprotected snapshot
!TBD!
You can protect Ceph Snapshots by the according Ceph/RDB flag, to avoid accidental deletion
and thus damaging your chain. Keep in mind that Proxmox won't let you delete VM's then, because
it's not aware of that paramter.
## Installation of prerequisites ## Installation of prerequisites
```apt install git pv gawk jq ```apt install git pv gawk jq
@@ -106,37 +99,41 @@ git clone https://github.com/lephisto/crossover/ /opt
Ensure that you can freely ssh from the Node you plan to mirror _from_ to _all_ nodes in the destination cluster, as well as localhost. Ensure that you can freely ssh from the Node you plan to mirror _from_ to _all_ nodes in the destination cluster, as well as localhost.
## Usage ## Examples
Mirror VM to another Cluster: Mirror VM to another Cluster:
``` ```
root@pve01:~/crossover# ./crossover mirror --vmid=100:10100 --destination=pve04 --pool=data2 --keeplocal=4 --keepremote=8 --overwrite --keep-dlock --online root@pve01:~/crossover# ./crossover mirror --vmid=all --prefixid=99 --excludevmids=101 --destination=pve04 --pool=data2 --overwrite --online
ACTION: Onlinemirror
Start mirror 2022-10-21 18:09:36 Start mirror 2022-11-01 19:21:44
Transmitting Config for VM 100 to desination 10100 VM 100 - Starting mirror for testubuntu
update VM 100: -lock backup VM 100 - Checking for VM 99100 on Destination Host pve04 /etc/pve/nodes/*/qemu-server
update VM 10100: -lock backup VM 100 - Transmitting Config for to destination pve04 VMID 99100
VM 100 - Issuing fsfreeze-freeze to 100 on pve01 VM 100 - locked 100 [rc:0]
2 VM 99100 - locked 99100 [rc:0]
VM 100 - Creating snapshot data/vm-100-disk-0@mirror-20221021180936 VM 100 - Creating snapshot data/vm-100-disk-0@mirror-20221101192144
Creating snap: 100% complete...done. VM 100 - Creating snapshot data/vm-100-disk-1@mirror-20221101192144
VM 100 - Creating snapshot data/vm-100-disk-1@mirror-20221021180936 VM 100 - unlocked source VM 100 [rc:0]
Creating snap: 100% complete...done. VM 100 - I data/vm-100-disk-0@mirror-20221101192144: e:0:00:01 c:[ 227KiB/s] a:[ 227KiB/s] 372KiB
VM 100 - Issuing fsfreeze-thaw to 100 on pve01 VM 100 - Housekeeping: localhost data/vm-100-disk-0, keeping Snapshots for 0s
2 VM 100 - Removing Snapshot localhost data/vm-100-disk-0@mirror-20221101192032 (106s) [rc:0]
Exporting image: 100% complete...done. VM 100 - Housekeeping: pve04 data2/vm-99100-disk-0-data, keeping Snapshots for 0s
Importing image diff: 100% complete...done. VM 100 - Removing Snapshot pve04 data2/vm-99100-disk-0-data@mirror-20221101192032 (108s) [rc:0]
Houskeeping localhost data vm-100-disk-0, keeping previous 4 Snapshots VM 100 - Disk Summary: Took 2 Seconds to transfer 372.89 KiB in a incremental run
Removing snap: 100% complete...done. VM 100 - I data/vm-100-disk-1@mirror-20221101192144: e:0:00:00 c:[ 346 B/s] a:[ 346 B/s] 74.0 B
Houskeeping pve04 data2 vm-10100-disk-0, keeping previous 8 Snapshots VM 100 - Housekeeping: localhost data/vm-100-disk-1, keeping Snapshots for 0s
Exporting image: 100% complete...done. VM 100 - Removing Snapshot localhost data/vm-100-disk-1@mirror-20221101192032 (114s) [rc:0]
Importing image diff: 100% complete...done. VM 100 - Housekeeping: pve04 data2/vm-99100-disk-1-data, keeping Snapshots for 0s
Houskeeping localhost data vm-100-disk-1, keeping previous 4 Snapshots VM 100 - Removing Snapshot pve04 data2/vm-99100-disk-1-data@mirror-20221101192032 (115s) [rc:0]
Removing snap: 100% complete...done. VM 100 - Disk Summary: Took 1 Seconds to transfer 372.96 KiB in a incremental run
Houskeeping pve04 data2 vm-10100-disk-1, keeping previous 8 Snapshots VM 99100 - Unlocking destination VM 99100
Unlocking source VM 100 Finnished mirror 2022-11-01 19:22:30
root@pve01:~/crossover# Job Summary: Bytes transferd 2 bytes for 2 Disks on 1 VMs in 00 hours 00 minutes 46 seconds
VM Freeze OK/failed...: 1/0
RBD Snapshot OK/failed: 2/0
Full xmitted..........: 0 byte
Differential Bytes ...: 372.96 KiB
``` ```
This example creates a mirror of VM 100 (in the source cluster) as VM 10100 (in the destination cluster) using the ceph pool "data2" for storing all attached disks. It will keep 4 Ceph snapshots prior the latest (in total 5) and 8 snapshots on the remote cluster. It will keep the VM on the target Cluster locked to avoid an accidental start (thus causing split brain issues), and will do it even if the source VM is running. This example creates a mirror of VM 100 (in the source cluster) as VM 10100 (in the destination cluster) using the ceph pool "data2" for storing all attached disks. It will keep 4 Ceph snapshots prior the latest (in total 5) and 8 snapshots on the remote cluster. It will keep the VM on the target Cluster locked to avoid an accidental start (thus causing split brain issues), and will do it even if the source VM is running.

View File

@@ -78,7 +78,7 @@ function usage(){
_____ _____
| |___ ___ ___ ___ ___ _ _ ___ ___ | |___ ___ ___ ___ ___ _ _ ___ ___
| --| _| . |_ -|_ -| . | | | -_| _| | --| _| . |_ -|_ -| . | | | -_| _|
|_____|_| |___|___|___|___|\_/|___|_| |_____|_| |___|___|___|___|\_/|___|_| v$VERSION
EOF EOF
fi fi
@@ -394,6 +394,7 @@ function mirror() {
local -i enddisk local -i enddisk
local -i startjob local -i startjob
local -i endjob local -i endjob
local -i duration
local -i vmcount=0 local -i vmcount=0
local -i diskcount=0 local -i diskcount=0
@@ -415,6 +416,8 @@ function mirror() {
end_process 1 end_process 1
fi fi
map_source_to_destination_vmid map_source_to_destination_vmid
map_vmids_to_host map_vmids_to_host
map_vmids_to_dsthost "$opt_destination" map_vmids_to_dsthost "$opt_destination"
@@ -597,7 +600,9 @@ function mirror() {
done done
endjob=$(date +%s) endjob=$(date +%s)
log info "Finnished mirror $(date "+%F %T")" log info "Finnished mirror $(date "+%F %T")"
humantime=$(date -ud "@$endjob" +'$((%s/3600/24)) days %H hours %M minutes %S seconds') #duration=$((endjob-startjob))
#echo "duration:$duration"
humantime=$(date -ud "@$((endjob-startjob))" +'%H hours %M minutes %S seconds')
log info "Job Summary: Bytes transferd $(human_readable $totalbytes 2) for $diskcount Disks on $vmcount VMs in $humantime" log info "Job Summary: Bytes transferd $(human_readable $totalbytes 2) for $diskcount Disks on $vmcount VMs in $humantime"
log info "VM Freeze OK/failed...: $perf_freeze_ok/$perf_freeze_failed" log info "VM Freeze OK/failed...: $perf_freeze_ok/$perf_freeze_failed"
log info "RBD Snapshot OK/failed: $perf_ss_ok/$perf_ss_failed" log info "RBD Snapshot OK/failed: $perf_ss_ok/$perf_ss_failed"