Corsinvest / cv4pve-barc

Backup And Restore Ceph for Proxmox VE
https://www.cv4pve-tools.com
GNU General Public License v3.0
82 stars 22 forks source link

[Bug-0.2.5-renew] Restore fails #54

Open MRLOLKOPF opened 4 years ago

MRLOLKOPF commented 4 years ago

Hi,

I just tested the new version (0.2.5-renew) on my test Proxmox environment, unfortunately I found some bugs. I might try to fix them myself and make a pull request, but due to the corona situation I'm quite busy now. Just want to report those bugs, so that others might be aware of it. But really nice improvements with fsfreeze, checksum check, etc.!!

I'm not able to run a restore with the new version. This backup/diff was already made with the new version. A restore with the version before (0.2.1) is working without any issue. Output:

root@pve03:/mnt/pve/bak2hetznerCeph/barc# eve4pve-barc restore --vmid=104 --label='daily' --path='/mnt/pve/bak2hetznerCeph/'
ACTION: Restore image
Start restore 2020-04-06 09:12:08 20200406023001RBD01.vm-104-disk-0.diff
Remove all snapshots
rbd: error opening image vm-114-disk-0: (2) No such file or directory
ERROR: rbd snap purge RBD01/vm-114-disk-0
Backup 20200406023001RBD01.vm-104-disk-0.diff restored in RBD01/vm-114-disk-0 with success!
Consider to manually create VM/CT and change config file from backup adapting restored image.
End restore 2020-04-06 09:12:20
0 Bytes restored in 12 Seconds. [0 Bytes/s] [Compressed Size 0 Bytes]
Issuing qm-rescan
rescan volumes...

Then I tried it with a new VM, which was never backed up by this tool. Those diffs were made manually within just several minutes in a row in comparison to the output above. With the version before, again, no problem. I got this output:

root@pve02:~# eve4pve-barc restore --vmid=114 --label='daily' --path='/mnt/pve/bak2hetznerCeph/'
ACTION: Restore image
Start restore 2020-04-06 09:54:29 20200406095123RBD01.vm-114-disk-0.diff
Remove all snapshots
rbd: error opening image vm-114-disk-1: (2) No such file or directory
ERROR: rbd snap purge RBD01/vm-114-disk-1
Backup 20200406095123RBD01.vm-114-disk-0.diff restored in RBD01/vm-114-disk-1 with success!
Consider to manually create VM/CT and change config file from backup adapting restored image.
End restore 2020-04-06 09:54:29
/usr/sbin/eve4pve-barc: line 1258: local: 0/0: division by 0 (error token is "0")

Stay healthy! Greetings from Germany, Andy

franklupo commented 4 years ago

@lephisto do you have any idea?

lephisto commented 4 years ago

I am wondering why VM ID's are mixed up here:

rbd: error opening image vm-114-disk-0: (2) No such file or directory
ERROR: rbd snap purge RBD01/vm-114-disk-0

Have you changed the ID for that Vm maybe?

thanks, Bastian

MRLOLKOPF commented 4 years ago

Hello,

in the first case, yes, I recovered the backup from VM 104 and named it 114. In the second case, no, I restored VM 114 and named it 114.

lephisto commented 4 years ago

But the restore in the second case was OK, so it was just the issue that reporting was not ok?

lephisto commented 4 years ago

I double checked everything now for proper restore functionality. I can't reproduce your issue. I might write something into the docs, that if VM's have been renumbered one should start with a clean set of snapshots..

MRLOLKOPF commented 4 years ago

Hi, I actually don't know if the restore in the second case was successful, I didn't checked that after the RBD and division by 0 errors.

The second case was a fresh VM, which never was backed up by this tool in the past. It was a fresh backup with the new version. No VMID renumbering. I might give it a new try in the future to further analyze this...

GizMoOfr commented 4 years ago

Hello developpers ;)
Thanks for your all of your work 👍 We encountering the same issue when restoring VM with backup files named like this :

YYYYMMddHHmmssMYCEPHPOOL_1.vm-100-disk-0.diff

We identified that the regex into the the function "restore" do not match correctly the file name.

`...

Create actionplan

    regex='^([0-9]+)([a-zA-Z-]+)\.(.*)\.(diff|img).?(.*)?'  

...

Execute actionplan

    local backup=''  
    for backup in "${plan[@]}"; do  
        regex='^([0-9]+)([a-zA-Z-]+)\.(.*)\.(diff|img).?(.*)?'  

...
`

We do not want to change CEPH pool we've decided to "fork" the code and inclue our file name specification :

`...

Create actionplan

    regex='^([0-9]+)([a-zA-Z0-9\_]+)\.(.*)\.(diff|img).?(.*)?'  

...

Execute actionplan

    local backup=''  
    for backup in "${plan[@]}"; do  
        regex='^([0-9]+)([a-zA-Z0-9\_]+)\.(.*)\.(diff|img).?(.*)?'  

...
` Hopes it can help.

franklupo commented 4 years ago

Hi, @lephisto you can fix it? I can't do it now.

Thanks

lephisto commented 4 years ago

@GizMoOfr can you send a PR so I can test it.

franklupo commented 4 years ago

For full information using parameter --debug

franklupo commented 4 years ago

Hi, I fixed it using a single regex for everyone. and to be verified by downloading the code

declare -r redateex='^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$'

Best regards

Tatsu-Kishi commented 4 years ago

Just ran into this too - the issue seems to be ceph pools that have numbers (and/or underscore if they are valid) in them. In both plan actionplan and execute actionplan $regex, lines 1161 and 1187, need to be adjusted to ^([0-9]+)([a-zA-Z0-9_-]+)\.(.*)\.(diff|img).?(.*)?

The second definition isn't even required though and could be removed entirely (or commented out to have the regex visible, but only active once in the code)

franklupo commented 4 years ago

Hi, I modified the regexp, try to check if it works

best regards

Xeronzz commented 3 years ago

In my case I'm on a newly installed Proxmox 6.2-11 environment where I am testing backups for Ceph. When using 0.2.6 restores fail due to the same error. When I downgrade to 0.2.5 the backup restore is working. I'm not using any fancy pool names. So probably the fix did create a bug :)

root@pve1:~# eve4pve-barc restore --vmid=201 --label='hourly' --path=/mnt/pve/backups ACTION: Restore image Start restore 2020-08-28 14:32:01 20200828131501vmstorage.vm-201-disk-0.diff.zz Remove all snapshots rbd: error opening image vm-201-disk-0: (2) No such file or directory ERROR: rbd snap purge vmstorage/vm-201-disk-0 Backup 20200828131501vmstorage.vm-201-disk-0.diff.zz restored in vmstorage/vm-201-disk-0 with success! Consider to manually create VM/CT and change config file from backup adapting restored image. End restore 2020-08-28 14:32:01 /usr/sbin/eve4pve-barc: line 1256: local: 0/0: division by 0 (error token is "0")