mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 01:16:10 +00:00
feat(vmbackups): read the backups of a target into the panel
Read backups from target, on a backup target's page, is a backup.import job holding the target: through the first of its computes that reaches the pool, it reads each manifest whose backup the panel does not list, checks its files as a restore does (the disks at their size, the small files by SHA-256), and adds the backup with its files, its time and, when the panel has that VM, its VM. A manifest with a missing or changed file is reported incomplete, not added. Nothing on the target changes. A panel rebuilt after losing its database adds the target again, reads it, and restores. README: a VM backups section (what a backup holds, what is not backed up, what a target must be, an NFS target's virsh commands). Permissions: backups are superusers'.
This commit is contained in:
parent
823d34cc18
commit
1123d7e8e5
10 changed files with 426 additions and 124 deletions
24
README.md
24
README.md
|
|
@ -50,6 +50,7 @@ WebVirtCloud and `virt-manager`/`virsh` can manage the same libvirt host **concu
|
|||
* Cloud-init datasource interface (OpenStack metadata compatible) and NoCloud seed media
|
||||
* REST API — OpenAPI 3.0 (Swagger & ReDoc), with API tokens
|
||||
* LDAP / Active Directory integration (optional)
|
||||
* VM backups, of a running or shut-off VM, into a storage pool of your choice; a backup is restored as a new VM
|
||||
* Daily backups of the panel, with an optional off-site copy (restic over SFTP)
|
||||
* English, Turkish and Simplified Chinese
|
||||
|
||||
|
|
@ -58,7 +59,7 @@ WebVirtCloud and `virt-manager`/`virsh` can manage the same libvirt host **concu
|
|||
1. [Installation](#installation): [installer](#installer), [Docker](#docker), [manual](#manual-installation), [first login](#first-login)
|
||||
2. [Adding a Compute Node](#adding-a-compute-node)
|
||||
3. [Configuration](#configuration): [environment variables](#environment-variables), [HTTPS and reverse proxy](#https-and-reverse-proxy), [cloud-init datasource](#cloud-init-datasource), [LDAP](#ldap), [OTP](#two-factor-login-otp), [serial console](#serial-console)
|
||||
4. [Backups](#backups): [off-site copy](#off-site-copy)
|
||||
4. [Backups](#backups): [off-site copy](#off-site-copy), [VM backups](#vm-backups)
|
||||
5. [Updating](#updating): [Docker](#docker-1), [installer and manual](#installer-and-manual-installation), [restore and rollback](#restore-and-rollback), [moving to a new machine](#moving-to-a-new-machine), [behavior changes](#behavior-changes)
|
||||
6. [Usage](#usage): [users and permissions](#users-roles-and-permissions), [REST API](#rest-api), [screenshots](#screenshots)
|
||||
7. [Development](#development)
|
||||
|
|
@ -585,6 +586,27 @@ b=$(find /root/offsite-restore -type d -name 'webvirtcloud-backup-*' | sort | ta
|
|||
|
||||
and follow [Moving to a new machine](#moving-to-a-new-machine) with that `b` (leave out its `b=` line).
|
||||
|
||||
### VM backups
|
||||
|
||||
Superusers back a VM up from its **Backups** tab into a backup target: a `dir` or `netfs` storage pool made on each host that sees it, added on **Backups → Backup targets** (another host's pool is accepted only when it is the same directory). A running VM keeps running: its disks are copied from one instant, with its file systems frozen for it when the guest agent answers; a shut-off VM's disks are copied as they are. A backup holds the disks, the VM's definition, its UEFI variables and a manifest. It is restored as a new VM, with its network disconnected unless asked, on a host that has the target's pool. After the panel's database is lost, add the target again and use **Read backups from target**.
|
||||
|
||||
VMs with TPM state, host devices, shared host directories, or encrypted or non-file disks are not backed up; CD-ROMs are left out.
|
||||
|
||||
The target must be:
|
||||
|
||||
- on storage apart from the VMs' disks: a target on the same storage is lost with it;
|
||||
- writable by QEMU;
|
||||
- with NFS on SELinux hosts, allowed: `setsebool -P virt_use_nfs 1`.
|
||||
|
||||
An NFS target, on each host:
|
||||
|
||||
```bash
|
||||
virsh pool-define-as vmbackups netfs --source-host nfs.example.com --source-path /export/vmbackups --target /var/lib/libvirt/vmbackups
|
||||
virsh pool-build vmbackups && virsh pool-start vmbackups && virsh pool-autostart vmbackups
|
||||
```
|
||||
|
||||
The panel does not copy VM backups off site: the target's storage does.
|
||||
|
||||
## Updating
|
||||
|
||||
Every update starts with a backup in its own directory (mode 700, named by date) that holds the database, the commit it was taken from, for Docker the TLS client certificates and, for installer and manual installations, `settings.py`, the nginx config, `/etc/default/webvirtcloud` if there is one and migrations an old installer generated (`local-migrations.tar`). The database is copied with SQLite's backup API, which also finishes a write interrupted by a crash. This covers sqlite only; with PostgreSQL (`WEBVIRTCLOUD_DB_HOST`), back up that database yourself before updating.
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ WebVirtCloud combines three kinds of access rights:
|
|||
| Delete the VM | ✅ | ✅ | `is_delete` | ❌ |
|
||||
| Disks and media (add, attach, edit, detach, delete volumes; CD-ROM/ISO) | ✅ | ❌ | — | ❌ |
|
||||
| Network interfaces, boot options, vCPU hotplug, autostart, guest agent, suspend/resume, migrate, raw XML, owners | ✅ | ❌ | — | ❌ |
|
||||
| Backups: back up, restore, delete; backup targets | ✅ | ❌ | — | ❌ |
|
||||
|
||||
Notes:
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -542,7 +542,7 @@ msgstr "Kullanıcıya anahtar ekleme formu"
|
|||
#: instances/templates/create_flavors.html:20
|
||||
#: instances/templates/instances/boot_device.html:17
|
||||
#: networks/templates/network.html:134 nwfilters/templates/nwfilter.html:45
|
||||
#: vmbackups/templates/vmbackups/target.html:49
|
||||
#: vmbackups/templates/vmbackups/target.html:59
|
||||
#: vmbackups/templates/vmbackups/targets.html:40
|
||||
msgid "Add"
|
||||
msgstr "Ekle"
|
||||
|
|
@ -3266,7 +3266,7 @@ msgstr ""
|
|||
msgid "The name of the virtual machine must not contain any special characters"
|
||||
msgstr "Sanal makine adı özel karakterler içeremez"
|
||||
|
||||
#: instances/jobs.py:73 vmbackups/jobs.py:83
|
||||
#: instances/jobs.py:73 vmbackups/jobs.py:84
|
||||
msgid "The VM moved to another compute after the job was queued"
|
||||
msgstr "İş kuyruğa alındıktan sonra sanal makine başka bir sunucuya taşındı"
|
||||
|
||||
|
|
@ -3287,17 +3287,17 @@ msgstr "Klonun adını boş adlar listesinden seçin"
|
|||
msgid "%(quota)s: cannot create '%(clone_name)s'."
|
||||
msgstr "%(quota)s: '%(clone_name)s' oluşturulamıyor."
|
||||
|
||||
#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:499
|
||||
#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:502
|
||||
#, python-format
|
||||
msgid "Instance '%(clone_name)s' already exists!"
|
||||
msgstr "'%(clone_name)s' sanal makinesi zaten mevcut!"
|
||||
|
||||
#: instances/jobs.py:208 vmbackups/jobs.py:501
|
||||
#: instances/jobs.py:208 vmbackups/jobs.py:504
|
||||
#, python-format
|
||||
msgid "Instance name '%(clone_name)s' is longer than 64 characters"
|
||||
msgstr "'%(clone_name)s' sanal makine adı 64 karakterden uzun"
|
||||
|
||||
#: instances/jobs.py:211 vmbackups/jobs.py:503
|
||||
#: instances/jobs.py:211 vmbackups/jobs.py:506
|
||||
#, python-format
|
||||
msgid "Instance name '%(clone_name)s' contains invalid characters!"
|
||||
msgstr "Sanal makine adı '%(clone_name)s' geçersiz karakterler içermektedir!"
|
||||
|
|
@ -3454,11 +3454,11 @@ msgid "Clone VM"
|
|||
msgstr "Sanal makineyi klonla"
|
||||
|
||||
#: instances/jobs.py:656 instances/jobs.py:663 instances/jobs.py:1005
|
||||
#: vmbackups/jobs.py:220 vmbackups/jobs.py:603
|
||||
#: vmbackups/jobs.py:221 vmbackups/jobs.py:606
|
||||
msgid "Copying disks"
|
||||
msgstr "Diskler kopyalanıyor"
|
||||
|
||||
#: instances/jobs.py:715 vmbackups/jobs.py:296
|
||||
#: instances/jobs.py:715 vmbackups/jobs.py:297
|
||||
msgid "libvirt has no result of the copy"
|
||||
msgstr "libvirt'te kopyanın sonucu yok"
|
||||
|
||||
|
|
@ -3471,7 +3471,7 @@ msgstr ""
|
|||
"Kopyalama başarısız oldu: %(error)s. Konuğun dosya sistemleri çözülemedi "
|
||||
"(%(thaw)s); şununla çözün: virsh domfsthaw %(vm)s"
|
||||
|
||||
#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:302
|
||||
#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:303
|
||||
msgid "The copy failed"
|
||||
msgstr "Kopyalama başarısız oldu"
|
||||
|
||||
|
|
@ -3493,11 +3493,11 @@ msgstr ""
|
|||
"Klonun bir birimi oluşturuluyordu; şu birimleri kontrol edin, sonra bu işi "
|
||||
"çözün: %(volumes)s"
|
||||
|
||||
#: instances/jobs.py:801 vmbackups/jobs.py:339
|
||||
#: instances/jobs.py:801 vmbackups/jobs.py:340
|
||||
msgid "The job stopped before the copy started"
|
||||
msgstr "İş, kopyalama başlamadan durdu"
|
||||
|
||||
#: instances/jobs.py:808 vmbackups/jobs.py:387
|
||||
#: instances/jobs.py:808 vmbackups/jobs.py:388
|
||||
msgid "libvirt is still copying the disks"
|
||||
msgstr "libvirt diskleri hâlâ kopyalıyor"
|
||||
|
||||
|
|
@ -4359,7 +4359,7 @@ msgstr "Aygıt"
|
|||
#: instances/templates/instances/boot_device.html:14
|
||||
#: instances/templates/instances/settings_tab.html:685
|
||||
#: networks/templates/network.html:304
|
||||
#: vmbackups/templates/vmbackups/target.html:23
|
||||
#: vmbackups/templates/vmbackups/target.html:33
|
||||
msgid "Remove"
|
||||
msgstr "Kaldır"
|
||||
|
||||
|
|
@ -9752,17 +9752,17 @@ msgstr ""
|
|||
msgid "Start after restore"
|
||||
msgstr "Geri yüklendikten sonra başlat"
|
||||
|
||||
#: vmbackups/jobs.py:56
|
||||
#: vmbackups/jobs.py:57
|
||||
#, python-format
|
||||
msgid "Backup target %(target)s has no storage pool on %(compute)s"
|
||||
msgstr "%(target)s yedek hedefinin %(compute)s üzerinde depolama havuzu yok"
|
||||
|
||||
#: vmbackups/jobs.py:66
|
||||
#: vmbackups/jobs.py:67
|
||||
msgid "The VM must be running, paused or shut off to be backed up"
|
||||
msgstr ""
|
||||
"Yedeklenmek için sanal makine çalışıyor, duraklatılmış ya da kapalı olmalı"
|
||||
|
||||
#: vmbackups/jobs.py:70
|
||||
#: vmbackups/jobs.py:71
|
||||
msgid ""
|
||||
"A running VM's backup needs libvirt 11.10 or later; shut the VM down to back "
|
||||
"it up"
|
||||
|
|
@ -9770,35 +9770,35 @@ msgstr ""
|
|||
"Çalışan bir sanal makinenin yedeği libvirt 11.10 veya sonrasını gerektirir; "
|
||||
"yedeklemek için sanal makineyi kapatın"
|
||||
|
||||
#: vmbackups/jobs.py:72
|
||||
#: vmbackups/jobs.py:73
|
||||
msgid "A paused VM's file systems cannot be frozen"
|
||||
msgstr "Duraklatılmış bir sanal makinenin dosya sistemleri dondurulamaz"
|
||||
|
||||
#: vmbackups/jobs.py:74
|
||||
#: vmbackups/jobs.py:75
|
||||
msgid "The guest agent does not answer: the file systems cannot be frozen"
|
||||
msgstr "Konuk ajanı yanıt vermiyor: dosya sistemleri dondurulamaz"
|
||||
|
||||
#: vmbackups/jobs.py:124
|
||||
#: vmbackups/jobs.py:125
|
||||
msgid ""
|
||||
"The VM's NVRAM file changed while it was backed up; back the VM up again"
|
||||
msgstr ""
|
||||
"Sanal makinenin NVRAM dosyası yedeklenirken değişti; sanal makineyi yeniden "
|
||||
"yedekleyin"
|
||||
|
||||
#: vmbackups/jobs.py:185
|
||||
#: vmbackups/jobs.py:186
|
||||
msgid "Back up VM"
|
||||
msgstr "Sanal makineyi yedekle"
|
||||
|
||||
#: vmbackups/jobs.py:236 vmbackups/jobs.py:303
|
||||
#: vmbackups/jobs.py:237 vmbackups/jobs.py:304
|
||||
msgid "Writing the backup's files"
|
||||
msgstr "Yedeğin dosyaları yazılıyor"
|
||||
|
||||
#: vmbackups/jobs.py:315
|
||||
#: vmbackups/jobs.py:316
|
||||
msgid "The guest's file systems could not be thawed; trying again"
|
||||
msgstr ""
|
||||
"Konuğun dosya sistemlerinin dondurulması kaldırılamadı; yeniden deneniyor"
|
||||
|
||||
#: vmbackups/jobs.py:364
|
||||
#: vmbackups/jobs.py:365
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The VM is no longer on the compute the job ran on; check these volumes of the"
|
||||
|
|
@ -9807,7 +9807,7 @@ msgstr ""
|
|||
"Sanal makine artık işin çalıştığı sunucuda değil; yedek hedefindeki şu "
|
||||
"birimleri kontrol edin, sonra bu işi çözün: %(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:381
|
||||
#: vmbackups/jobs.py:382
|
||||
#, python-format
|
||||
msgid ""
|
||||
"A disk was being copied when the job stopped; check these volumes of the "
|
||||
|
|
@ -9816,7 +9816,7 @@ msgstr ""
|
|||
"İş durduğunda bir disk kopyalanıyordu; yedek hedefindeki şu birimleri kontrol"
|
||||
" edin, sonra bu işi çözün: %(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:391
|
||||
#: vmbackups/jobs.py:392
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Another backup runs on the VM; check these volumes of the backup target, then"
|
||||
|
|
@ -9825,7 +9825,7 @@ msgstr ""
|
|||
"Sanal makinede başka bir yedekleme çalışıyor; yedek hedefindeki şu birimleri "
|
||||
"kontrol edin, sonra bu işi çözün: %(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:397
|
||||
#: vmbackups/jobs.py:398
|
||||
#, python-format
|
||||
msgid ""
|
||||
"libvirt has no result of the copy; check these volumes of the backup target, "
|
||||
|
|
@ -9834,68 +9834,68 @@ msgstr ""
|
|||
"libvirt'te kopyanın sonucu yok; yedek hedefindeki şu birimleri kontrol edin, "
|
||||
"sonra bu işi çözün: %(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:405
|
||||
#: vmbackups/jobs.py:406
|
||||
msgid "The job stopped before the copy ended"
|
||||
msgstr "İş, kopyalama bitmeden durdu"
|
||||
|
||||
#: vmbackups/jobs.py:412
|
||||
#: vmbackups/jobs.py:413
|
||||
#, python-format
|
||||
msgid "The backup's files could not be written: %(error)s"
|
||||
msgstr "Yedeğin dosyaları yazılamadı: %(error)s"
|
||||
|
||||
#: vmbackups/jobs.py:430
|
||||
#: vmbackups/jobs.py:433
|
||||
#, python-format
|
||||
msgid "No compute of backup target %(target)s reaches its storage pool"
|
||||
msgstr ""
|
||||
"%(target)s yedek hedefinin hiçbir sunucusu depolama havuzuna erişemiyor"
|
||||
|
||||
#: vmbackups/jobs.py:443
|
||||
#: vmbackups/jobs.py:446
|
||||
msgid "Delete backup"
|
||||
msgstr "Yedeği sil"
|
||||
|
||||
#: vmbackups/jobs.py:452
|
||||
#: vmbackups/jobs.py:455
|
||||
msgid "This backup is being made; cancel its job to stop it"
|
||||
msgstr "Bu yedek alınıyor; durdurmak için işini iptal edin"
|
||||
|
||||
#: vmbackups/jobs.py:516
|
||||
#: vmbackups/jobs.py:519
|
||||
#, python-format
|
||||
msgid "The backup's file %(name)s is missing from the target"
|
||||
msgstr "Yedeğin %(name)s dosyası hedefte yok"
|
||||
|
||||
#: vmbackups/jobs.py:519 vmbackups/jobs.py:521
|
||||
#: vmbackups/jobs.py:522 vmbackups/jobs.py:524
|
||||
#, python-format
|
||||
msgid "The backup's file %(name)s differs from the one written"
|
||||
msgstr "Yedeğin %(name)s dosyası yazılandan farklı"
|
||||
|
||||
#: vmbackups/jobs.py:531 vmbackups/templates/vmbackups/restore.html:7
|
||||
#: vmbackups/jobs.py:534 vmbackups/templates/vmbackups/restore.html:7
|
||||
msgid "Restore backup"
|
||||
msgstr "Yedeği geri yükle"
|
||||
|
||||
#: vmbackups/jobs.py:544
|
||||
#: vmbackups/jobs.py:547
|
||||
msgid "Only a ready backup is restored"
|
||||
msgstr "Yalnızca hazır bir yedek geri yüklenir"
|
||||
|
||||
#: vmbackups/jobs.py:574
|
||||
#: vmbackups/jobs.py:577
|
||||
#, python-format
|
||||
msgid "A VM named %(name)s exists on %(compute)s"
|
||||
msgstr "%(compute)s üzerinde %(name)s adlı bir sanal makine var"
|
||||
|
||||
#: vmbackups/jobs.py:582
|
||||
#: vmbackups/jobs.py:585
|
||||
#, python-format
|
||||
msgid "This host has no active directory storage pool %(pool)s"
|
||||
msgstr "Bu sunucuda %(pool)s adlı etkin bir dizin depolama havuzu yok"
|
||||
|
||||
#: vmbackups/jobs.py:599
|
||||
#: vmbackups/jobs.py:602
|
||||
#, python-format
|
||||
msgid "The NVRAM file %(path)s exists already"
|
||||
msgstr "%(path)s NVRAM dosyası zaten var"
|
||||
|
||||
#: vmbackups/jobs.py:630
|
||||
#: vmbackups/jobs.py:633
|
||||
#, python-format
|
||||
msgid "The VM was restored; it did not start: %(error)s"
|
||||
msgstr "Sanal makine geri yüklendi; başlamadı: %(error)s"
|
||||
|
||||
#: vmbackups/jobs.py:652
|
||||
#: vmbackups/jobs.py:655
|
||||
#, python-format
|
||||
msgid ""
|
||||
"A disk was being copied when the job stopped; check this volume, then resolve"
|
||||
|
|
@ -9904,7 +9904,7 @@ msgstr ""
|
|||
"İş durduğunda bir disk kopyalanıyordu; bu birimi kontrol edin, sonra bu işi "
|
||||
"çözün: %(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:657
|
||||
#: vmbackups/jobs.py:660
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s is not active; the restore's copies in it are removed "
|
||||
|
|
@ -9913,10 +9913,23 @@ msgstr ""
|
|||
"%(pool)s depolama havuzu etkin değil; geri yüklemenin içindeki kopyaları "
|
||||
"havuz etkin olunca kaldırılır"
|
||||
|
||||
#: vmbackups/jobs.py:666
|
||||
#: vmbackups/jobs.py:669
|
||||
msgid "The VM was not defined; its copies were removed"
|
||||
msgstr "Sanal makine tanımlanmadı; kopyaları kaldırıldı"
|
||||
|
||||
#: vmbackups/jobs.py:688 vmbackups/templates/vmbackups/target.html:18
|
||||
msgid "Read backups from target"
|
||||
msgstr "Yedekleri hedeften oku"
|
||||
|
||||
#: vmbackups/jobs.py:736
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Not read, as a file of the backup is missing, changed or unreadable: "
|
||||
"%(names)s"
|
||||
msgstr ""
|
||||
"Yedeğin bir dosyası eksik, değişmiş ya da okunamaz olduğu için okunmadı: "
|
||||
"%(names)s"
|
||||
|
||||
#: vmbackups/templates/vmbackups/consistency.html:1
|
||||
msgid "Shut off"
|
||||
msgstr "Kapalı"
|
||||
|
|
@ -9945,8 +9958,8 @@ msgstr ""
|
|||
"hedeften kaldırılır."
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:10
|
||||
#: vmbackups/templates/vmbackups/target.html:6
|
||||
#: vmbackups/templates/vmbackups/target.html:8
|
||||
#: vmbackups/templates/vmbackups/target.html:7
|
||||
#: vmbackups/templates/vmbackups/target.html:9
|
||||
#: vmbackups/templates/vmbackups/targets.html:6
|
||||
#: vmbackups/templates/vmbackups/targets.html:8
|
||||
msgid "Backup targets"
|
||||
|
|
@ -10012,21 +10025,29 @@ msgstr ""
|
|||
"%(vm)s sanal makinesinin %(time)s tarihli, %(target)s hedefindeki yedeği "
|
||||
"kendi UUID'si ve MAC adresleriyle yeni bir sanal makine olarak geri yüklenir."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:11
|
||||
#: vmbackups/templates/vmbackups/target.html:13
|
||||
#, python-format
|
||||
msgid "%(counter)s backup."
|
||||
msgid_plural "%(counter)s backups."
|
||||
msgstr[0] "%(counter)s yedek."
|
||||
msgstr[1] "%(counter)s yedek."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:23
|
||||
#: vmbackups/templates/vmbackups/target.html:18
|
||||
msgid ""
|
||||
"Adds the backups whose manifest is in the target and that the panel does not "
|
||||
"list, as after its database was lost."
|
||||
msgstr ""
|
||||
"Manifestosu hedefte olup panelin listelemediği yedekleri ekler; örneğin "
|
||||
"panelin veritabanı kaybolduktan sonra."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:33
|
||||
msgid ""
|
||||
"Remove this storage pool from the target? The pool and its files stay on the "
|
||||
"host."
|
||||
msgstr ""
|
||||
"Bu depolama havuzu hedeften çıkarılsın mı? Havuz ve dosyaları sunucuda kalır."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:33
|
||||
#: vmbackups/templates/vmbackups/target.html:43
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The target is inside storage pool %(pool)s: its backups are lost with that "
|
||||
|
|
@ -10035,11 +10056,11 @@ msgstr ""
|
|||
"Hedef %(pool)s depolama havuzunun içinde: o depolama kaybolursa yedekler de "
|
||||
"kaybolur."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:43
|
||||
#: vmbackups/templates/vmbackups/target.html:53
|
||||
msgid "Add a compute's storage pool"
|
||||
msgstr "Bir sunucunun depolama havuzunu ekle"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:45
|
||||
#: vmbackups/templates/vmbackups/target.html:55
|
||||
msgid ""
|
||||
"The pool must be the same directory as the target's other pools, as an NFS "
|
||||
"share mounted on each host."
|
||||
|
|
@ -10047,11 +10068,11 @@ msgstr ""
|
|||
"Havuz, hedefin diğer havuzlarıyla aynı dizin olmalıdır; örneğin her sunucuya "
|
||||
"bağlanmış bir NFS paylaşımı."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:58
|
||||
#: vmbackups/templates/vmbackups/target.html:68
|
||||
msgid "Delete this backup target? Its storage pools stay on the hosts."
|
||||
msgstr "Bu yedek hedefi silinsin mi? Depolama havuzları sunucularda kalır."
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:58
|
||||
#: vmbackups/templates/vmbackups/target.html:68
|
||||
msgid "Delete target"
|
||||
msgstr "Hedefi sil"
|
||||
|
||||
|
|
@ -10125,12 +10146,12 @@ msgid "No backup target has a storage pool on this VM's host."
|
|||
msgstr ""
|
||||
"Hiçbir yedek hedefinin bu sanal makinenin sunucusunda depolama havuzu yok."
|
||||
|
||||
#: vmbackups/views.py:67 vmbackups/views.py:75
|
||||
#: vmbackups/views.py:67 vmbackups/views.py:85
|
||||
#, python-format
|
||||
msgid "Backup target %(target)s has backups; delete them first"
|
||||
msgstr "%(target)s yedek hedefinde yedekler var; önce onları silin"
|
||||
|
||||
#: vmbackups/views.py:92
|
||||
#: vmbackups/views.py:102
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s of %(compute)s is not the same directory as storage "
|
||||
|
|
@ -10139,7 +10160,7 @@ msgstr ""
|
|||
"%(compute)s sunucusunun %(pool)s depolama havuzu, %(other_compute)s "
|
||||
"sunucusunun %(other)s depolama havuzuyla aynı dizin değil"
|
||||
|
||||
#: vmbackups/views.py:124
|
||||
#: vmbackups/views.py:134
|
||||
msgid "Choose a backup target"
|
||||
msgstr "Bir yedek hedefi seçin"
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -534,7 +534,7 @@ msgstr "为用户添加密钥表单"
|
|||
#: instances/templates/create_flavors.html:20
|
||||
#: instances/templates/instances/boot_device.html:17
|
||||
#: networks/templates/network.html:134 nwfilters/templates/nwfilter.html:45
|
||||
#: vmbackups/templates/vmbackups/target.html:49
|
||||
#: vmbackups/templates/vmbackups/target.html:59
|
||||
#: vmbackups/templates/vmbackups/targets.html:40
|
||||
msgid "Add"
|
||||
msgstr "添加"
|
||||
|
|
@ -3111,7 +3111,7 @@ msgstr "控制台监听的不只是 localhost;只有管理员可以移除其
|
|||
msgid "The name of the virtual machine must not contain any special characters"
|
||||
msgstr "虚拟机名称不能包含任何特殊字符"
|
||||
|
||||
#: instances/jobs.py:73 vmbackups/jobs.py:83
|
||||
#: instances/jobs.py:73 vmbackups/jobs.py:84
|
||||
msgid "The VM moved to another compute after the job was queued"
|
||||
msgstr "任务排队后,虚拟机已移到另一个计算节点"
|
||||
|
||||
|
|
@ -3132,17 +3132,17 @@ msgstr "请从可用名称列表中选择克隆的名称"
|
|||
msgid "%(quota)s: cannot create '%(clone_name)s'."
|
||||
msgstr "%(quota)s:无法创建“%(clone_name)s”。"
|
||||
|
||||
#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:499
|
||||
#: instances/jobs.py:206 instances/jobs.py:646 vmbackups/jobs.py:502
|
||||
#, python-format
|
||||
msgid "Instance '%(clone_name)s' already exists!"
|
||||
msgstr "虚拟机 '%(clone_name)s' 已存在!"
|
||||
|
||||
#: instances/jobs.py:208 vmbackups/jobs.py:501
|
||||
#: instances/jobs.py:208 vmbackups/jobs.py:504
|
||||
#, python-format
|
||||
msgid "Instance name '%(clone_name)s' is longer than 64 characters"
|
||||
msgstr "虚拟机名称“%(clone_name)s”超过 64 个字符"
|
||||
|
||||
#: instances/jobs.py:211 vmbackups/jobs.py:503
|
||||
#: instances/jobs.py:211 vmbackups/jobs.py:506
|
||||
#, python-format
|
||||
msgid "Instance name '%(clone_name)s' contains invalid characters!"
|
||||
msgstr "虚拟机名称 '%(clone_name)s' 包含无效字符!"
|
||||
|
|
@ -3284,11 +3284,11 @@ msgid "Clone VM"
|
|||
msgstr "克隆虚拟机"
|
||||
|
||||
#: instances/jobs.py:656 instances/jobs.py:663 instances/jobs.py:1005
|
||||
#: vmbackups/jobs.py:220 vmbackups/jobs.py:603
|
||||
#: vmbackups/jobs.py:221 vmbackups/jobs.py:606
|
||||
msgid "Copying disks"
|
||||
msgstr "正在复制磁盘"
|
||||
|
||||
#: instances/jobs.py:715 vmbackups/jobs.py:296
|
||||
#: instances/jobs.py:715 vmbackups/jobs.py:297
|
||||
msgid "libvirt has no result of the copy"
|
||||
msgstr "libvirt 没有复制的结果"
|
||||
|
||||
|
|
@ -3299,7 +3299,7 @@ msgid ""
|
|||
"(%(thaw)s); thaw them with: virsh domfsthaw %(vm)s"
|
||||
msgstr "复制失败:%(error)s。无法解冻客户机的文件系统(%(thaw)s);请用以下命令解冻:virsh domfsthaw %(vm)s"
|
||||
|
||||
#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:302
|
||||
#: instances/jobs.py:729 instances/jobs.py:821 vmbackups/jobs.py:303
|
||||
msgid "The copy failed"
|
||||
msgstr "复制失败"
|
||||
|
||||
|
|
@ -3317,11 +3317,11 @@ msgid ""
|
|||
"this job: %(volumes)s"
|
||||
msgstr "克隆的一个卷正在创建中;请检查这些卷,然后处理此任务:%(volumes)s"
|
||||
|
||||
#: instances/jobs.py:801 vmbackups/jobs.py:339
|
||||
#: instances/jobs.py:801 vmbackups/jobs.py:340
|
||||
msgid "The job stopped before the copy started"
|
||||
msgstr "任务在复制开始前停止"
|
||||
|
||||
#: instances/jobs.py:808 vmbackups/jobs.py:387
|
||||
#: instances/jobs.py:808 vmbackups/jobs.py:388
|
||||
msgid "libvirt is still copying the disks"
|
||||
msgstr "libvirt 仍在复制磁盘"
|
||||
|
||||
|
|
@ -4148,7 +4148,7 @@ msgstr "设备"
|
|||
#: instances/templates/instances/boot_device.html:14
|
||||
#: instances/templates/instances/settings_tab.html:685
|
||||
#: networks/templates/network.html:304
|
||||
#: vmbackups/templates/vmbackups/target.html:23
|
||||
#: vmbackups/templates/vmbackups/target.html:33
|
||||
msgid "Remove"
|
||||
msgstr "移除"
|
||||
|
||||
|
|
@ -9195,152 +9195,163 @@ msgstr "恢复的客户机保留虚拟机的地址和主机名:与原虚拟机
|
|||
msgid "Start after restore"
|
||||
msgstr "恢复后启动"
|
||||
|
||||
#: vmbackups/jobs.py:56
|
||||
#: vmbackups/jobs.py:57
|
||||
#, python-format
|
||||
msgid "Backup target %(target)s has no storage pool on %(compute)s"
|
||||
msgstr "备份目标 %(target)s 在 %(compute)s 上没有存储池"
|
||||
|
||||
#: vmbackups/jobs.py:66
|
||||
#: vmbackups/jobs.py:67
|
||||
msgid "The VM must be running, paused or shut off to be backed up"
|
||||
msgstr "虚拟机必须处于运行、暂停或关闭状态才能备份"
|
||||
|
||||
#: vmbackups/jobs.py:70
|
||||
#: vmbackups/jobs.py:71
|
||||
msgid ""
|
||||
"A running VM's backup needs libvirt 11.10 or later; shut the VM down to back "
|
||||
"it up"
|
||||
msgstr "运行中虚拟机的备份需要 libvirt 11.10 或更高版本;请关闭虚拟机后再备份"
|
||||
|
||||
#: vmbackups/jobs.py:72
|
||||
#: vmbackups/jobs.py:73
|
||||
msgid "A paused VM's file systems cannot be frozen"
|
||||
msgstr "无法冻结已暂停虚拟机的文件系统"
|
||||
|
||||
#: vmbackups/jobs.py:74
|
||||
#: vmbackups/jobs.py:75
|
||||
msgid "The guest agent does not answer: the file systems cannot be frozen"
|
||||
msgstr "客户机代理没有响应:无法冻结文件系统"
|
||||
|
||||
#: vmbackups/jobs.py:124
|
||||
#: vmbackups/jobs.py:125
|
||||
msgid ""
|
||||
"The VM's NVRAM file changed while it was backed up; back the VM up again"
|
||||
msgstr "虚拟机的 NVRAM 文件在备份期间发生了变化;请重新备份该虚拟机"
|
||||
|
||||
#: vmbackups/jobs.py:185
|
||||
#: vmbackups/jobs.py:186
|
||||
msgid "Back up VM"
|
||||
msgstr "备份虚拟机"
|
||||
|
||||
#: vmbackups/jobs.py:236 vmbackups/jobs.py:303
|
||||
#: vmbackups/jobs.py:237 vmbackups/jobs.py:304
|
||||
msgid "Writing the backup's files"
|
||||
msgstr "正在写入备份文件"
|
||||
|
||||
#: vmbackups/jobs.py:315
|
||||
#: vmbackups/jobs.py:316
|
||||
msgid "The guest's file systems could not be thawed; trying again"
|
||||
msgstr "无法解冻客户机的文件系统;正在重试"
|
||||
|
||||
#: vmbackups/jobs.py:364
|
||||
#: vmbackups/jobs.py:365
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The VM is no longer on the compute the job ran on; check these volumes of the"
|
||||
" backup target, then resolve this job: %(volumes)s"
|
||||
msgstr "虚拟机已不在作业运行的计算节点上;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:381
|
||||
#: vmbackups/jobs.py:382
|
||||
#, python-format
|
||||
msgid ""
|
||||
"A disk was being copied when the job stopped; check these volumes of the "
|
||||
"backup target, then resolve this job: %(volumes)s"
|
||||
msgstr "作业停止时正在复制磁盘;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:391
|
||||
#: vmbackups/jobs.py:392
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Another backup runs on the VM; check these volumes of the backup target, then"
|
||||
" resolve this job: %(volumes)s"
|
||||
msgstr "虚拟机上正在运行另一个备份;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:397
|
||||
#: vmbackups/jobs.py:398
|
||||
#, python-format
|
||||
msgid ""
|
||||
"libvirt has no result of the copy; check these volumes of the backup target, "
|
||||
"then resolve this job: %(volumes)s"
|
||||
msgstr "libvirt 没有复制的结果;请检查备份目标中的这些卷,然后解决此作业:%(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:405
|
||||
#: vmbackups/jobs.py:406
|
||||
msgid "The job stopped before the copy ended"
|
||||
msgstr "作业在复制结束前停止"
|
||||
|
||||
#: vmbackups/jobs.py:412
|
||||
#: vmbackups/jobs.py:413
|
||||
#, python-format
|
||||
msgid "The backup's files could not be written: %(error)s"
|
||||
msgstr "无法写入备份文件:%(error)s"
|
||||
|
||||
#: vmbackups/jobs.py:430
|
||||
#: vmbackups/jobs.py:433
|
||||
#, python-format
|
||||
msgid "No compute of backup target %(target)s reaches its storage pool"
|
||||
msgstr "备份目标 %(target)s 的计算节点都无法访问其存储池"
|
||||
|
||||
#: vmbackups/jobs.py:443
|
||||
#: vmbackups/jobs.py:446
|
||||
msgid "Delete backup"
|
||||
msgstr "删除备份"
|
||||
|
||||
#: vmbackups/jobs.py:452
|
||||
#: vmbackups/jobs.py:455
|
||||
msgid "This backup is being made; cancel its job to stop it"
|
||||
msgstr "此备份正在创建;要停止它,请取消其作业"
|
||||
|
||||
#: vmbackups/jobs.py:516
|
||||
#: vmbackups/jobs.py:519
|
||||
#, python-format
|
||||
msgid "The backup's file %(name)s is missing from the target"
|
||||
msgstr "目标中缺少备份文件 %(name)s"
|
||||
|
||||
#: vmbackups/jobs.py:519 vmbackups/jobs.py:521
|
||||
#: vmbackups/jobs.py:522 vmbackups/jobs.py:524
|
||||
#, python-format
|
||||
msgid "The backup's file %(name)s differs from the one written"
|
||||
msgstr "备份文件 %(name)s 与写入的不同"
|
||||
|
||||
#: vmbackups/jobs.py:531 vmbackups/templates/vmbackups/restore.html:7
|
||||
#: vmbackups/jobs.py:534 vmbackups/templates/vmbackups/restore.html:7
|
||||
msgid "Restore backup"
|
||||
msgstr "恢复备份"
|
||||
|
||||
#: vmbackups/jobs.py:544
|
||||
#: vmbackups/jobs.py:547
|
||||
msgid "Only a ready backup is restored"
|
||||
msgstr "只能恢复就绪的备份"
|
||||
|
||||
#: vmbackups/jobs.py:574
|
||||
#: vmbackups/jobs.py:577
|
||||
#, python-format
|
||||
msgid "A VM named %(name)s exists on %(compute)s"
|
||||
msgstr "%(compute)s 上已存在名为 %(name)s 的虚拟机"
|
||||
|
||||
#: vmbackups/jobs.py:582
|
||||
#: vmbackups/jobs.py:585
|
||||
#, python-format
|
||||
msgid "This host has no active directory storage pool %(pool)s"
|
||||
msgstr "此主机没有名为 %(pool)s 的活动目录存储池"
|
||||
|
||||
#: vmbackups/jobs.py:599
|
||||
#: vmbackups/jobs.py:602
|
||||
#, python-format
|
||||
msgid "The NVRAM file %(path)s exists already"
|
||||
msgstr "NVRAM 文件 %(path)s 已存在"
|
||||
|
||||
#: vmbackups/jobs.py:630
|
||||
#: vmbackups/jobs.py:633
|
||||
#, python-format
|
||||
msgid "The VM was restored; it did not start: %(error)s"
|
||||
msgstr "虚拟机已恢复;但未能启动:%(error)s"
|
||||
|
||||
#: vmbackups/jobs.py:652
|
||||
#: vmbackups/jobs.py:655
|
||||
#, python-format
|
||||
msgid ""
|
||||
"A disk was being copied when the job stopped; check this volume, then resolve"
|
||||
" this job: %(volumes)s"
|
||||
msgstr "作业停止时正在复制磁盘;请检查此卷,然后解决此作业:%(volumes)s"
|
||||
|
||||
#: vmbackups/jobs.py:657
|
||||
#: vmbackups/jobs.py:660
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s is not active; the restore's copies in it are removed "
|
||||
"when it is"
|
||||
msgstr "存储池 %(pool)s 未激活;其中恢复的副本将在其激活后删除"
|
||||
|
||||
#: vmbackups/jobs.py:666
|
||||
#: vmbackups/jobs.py:669
|
||||
msgid "The VM was not defined; its copies were removed"
|
||||
msgstr "虚拟机未定义;其副本已删除"
|
||||
|
||||
#: vmbackups/jobs.py:688 vmbackups/templates/vmbackups/target.html:18
|
||||
msgid "Read backups from target"
|
||||
msgstr "从目标读取备份"
|
||||
|
||||
#: vmbackups/jobs.py:736
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Not read, as a file of the backup is missing, changed or unreadable: "
|
||||
"%(names)s"
|
||||
msgstr "由于备份的某个文件缺失、已更改或无法读取,未读取:%(names)s"
|
||||
|
||||
#: vmbackups/templates/vmbackups/consistency.html:1
|
||||
msgid "Shut off"
|
||||
msgstr "已关闭"
|
||||
|
|
@ -9367,8 +9378,8 @@ msgid ""
|
|||
msgstr "要删除 %(vm)s 在 %(time)s 的备份吗?其文件将从目标中移除。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/index.html:10
|
||||
#: vmbackups/templates/vmbackups/target.html:6
|
||||
#: vmbackups/templates/vmbackups/target.html:8
|
||||
#: vmbackups/templates/vmbackups/target.html:7
|
||||
#: vmbackups/templates/vmbackups/target.html:9
|
||||
#: vmbackups/templates/vmbackups/targets.html:6
|
||||
#: vmbackups/templates/vmbackups/targets.html:8
|
||||
msgid "Backup targets"
|
||||
|
|
@ -9432,40 +9443,46 @@ msgid ""
|
|||
"with its own UUID and MAC addresses."
|
||||
msgstr "%(vm)s 在 %(time)s 的备份(位于 %(target)s)将恢复为一台拥有自己 UUID 和 MAC 地址的新虚拟机。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:11
|
||||
#: vmbackups/templates/vmbackups/target.html:13
|
||||
#, python-format
|
||||
msgid "%(counter)s backup."
|
||||
msgid_plural "%(counter)s backups."
|
||||
msgstr[0] "%(counter)s 个备份。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:23
|
||||
#: vmbackups/templates/vmbackups/target.html:18
|
||||
msgid ""
|
||||
"Adds the backups whose manifest is in the target and that the panel does not "
|
||||
"list, as after its database was lost."
|
||||
msgstr "添加清单位于目标中、但面板未列出的备份,例如在面板数据库丢失之后。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:33
|
||||
msgid ""
|
||||
"Remove this storage pool from the target? The pool and its files stay on the "
|
||||
"host."
|
||||
msgstr "要从目标中移除此存储池吗?存储池及其文件仍保留在主机上。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:33
|
||||
#: vmbackups/templates/vmbackups/target.html:43
|
||||
#, python-format
|
||||
msgid ""
|
||||
"The target is inside storage pool %(pool)s: its backups are lost with that "
|
||||
"storage."
|
||||
msgstr "目标位于存储池 %(pool)s 内:该存储丢失时其备份也会丢失。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:43
|
||||
#: vmbackups/templates/vmbackups/target.html:53
|
||||
msgid "Add a compute's storage pool"
|
||||
msgstr "添加计算节点的存储池"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:45
|
||||
#: vmbackups/templates/vmbackups/target.html:55
|
||||
msgid ""
|
||||
"The pool must be the same directory as the target's other pools, as an NFS "
|
||||
"share mounted on each host."
|
||||
msgstr "该存储池必须与目标的其他存储池是同一目录,例如挂载在每台主机上的 NFS 共享。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:58
|
||||
#: vmbackups/templates/vmbackups/target.html:68
|
||||
msgid "Delete this backup target? Its storage pools stay on the hosts."
|
||||
msgstr "要删除此备份目标吗?其存储池仍保留在主机上。"
|
||||
|
||||
#: vmbackups/templates/vmbackups/target.html:58
|
||||
#: vmbackups/templates/vmbackups/target.html:68
|
||||
msgid "Delete target"
|
||||
msgstr "删除目标"
|
||||
|
||||
|
|
@ -9530,19 +9547,19 @@ msgstr "存储池 %(pool)s 是备份目标 %(target)s;请先将其从目标中
|
|||
msgid "No backup target has a storage pool on this VM's host."
|
||||
msgstr "没有备份目标在此虚拟机的主机上有存储池。"
|
||||
|
||||
#: vmbackups/views.py:67 vmbackups/views.py:75
|
||||
#: vmbackups/views.py:67 vmbackups/views.py:85
|
||||
#, python-format
|
||||
msgid "Backup target %(target)s has backups; delete them first"
|
||||
msgstr "备份目标 %(target)s 中有备份;请先删除它们"
|
||||
|
||||
#: vmbackups/views.py:92
|
||||
#: vmbackups/views.py:102
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Storage pool %(pool)s of %(compute)s is not the same directory as storage "
|
||||
"pool %(other)s of %(other_compute)s"
|
||||
msgstr "%(compute)s 的存储池 %(pool)s 与 %(other_compute)s 的存储池 %(other)s 不是同一目录"
|
||||
|
||||
#: vmbackups/views.py:124
|
||||
#: vmbackups/views.py:134
|
||||
msgid "Choose a backup target"
|
||||
msgstr "请选择备份目标"
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ from django.core.exceptions import PermissionDenied
|
|||
from django.urls import reverse
|
||||
from django.db import transaction
|
||||
from django.utils import timezone
|
||||
from django.utils.dateparse import parse_datetime
|
||||
from django.utils.translation import gettext_noop as _
|
||||
from lxml import etree
|
||||
from libvirt import VIR_DOMAIN_PAUSED, VIR_DOMAIN_RUNNING, VIR_DOMAIN_SHUTOFF, VIR_ERR_NO_DOMAIN, VIR_ERR_NO_STORAGE_VOL, libvirtError
|
||||
|
|
@ -25,8 +26,8 @@ from operations.jobs import Cancelled, Kind, Outcome, Plan, register
|
|||
from operations.models import Claim, Operation
|
||||
from operations.utils import safe_text, say
|
||||
from vrtManager import util
|
||||
from vrtManager.backup import (backup_file_names, check_restore_host, check_target_space, get_file, put_file, remove_files,
|
||||
restore_definition, target_pool, volume_exists, wvmBackup)
|
||||
from vrtManager.backup import (backup_file_names, check_restore_host, check_target_space, get_file, manifest_names, put_file,
|
||||
remove_files, restore_definition, target_pool, volume_exists, wvmBackup)
|
||||
from vrtManager.connection import NVRAM_DIR, wvmConnect
|
||||
from vrtManager.instance import wvmInstance
|
||||
from vrtManager.storage import wvmStorage
|
||||
|
|
@ -420,11 +421,13 @@ class CreateBackup(Kind):
|
|||
|
||||
|
||||
def _target_pool(target):
|
||||
"""The target's pool through the first of its computes that reaches it."""
|
||||
"""(connection, pool) of the target through the first of its computes
|
||||
that reaches its pool."""
|
||||
for row in target.pools.select_related("compute").order_by("compute__name"):
|
||||
c = row.compute
|
||||
try:
|
||||
return target_pool(wvmConnect(c.hostname, c.login, c.password, c.type), row.pool, row.pool_uuid)
|
||||
conn = wvmConnect(c.hostname, c.login, c.password, c.type)
|
||||
return conn, target_pool(conn, row.pool, row.pool_uuid)
|
||||
except libvirtError:
|
||||
continue
|
||||
raise util.OperationError(_("No compute of backup target %(target)s reaches its storage pool"), target=target.name)
|
||||
|
|
@ -462,7 +465,7 @@ class DeleteBackup(Kind):
|
|||
def run(self, op, ctx):
|
||||
_superuser(op.user)
|
||||
backup = _backup(op.params)
|
||||
pool = _target_pool(backup.target)
|
||||
_conn, pool = _target_pool(backup.target)
|
||||
ctx.record_intent(deleting=True)
|
||||
return self._delete(backup, pool)
|
||||
|
||||
|
|
@ -481,7 +484,7 @@ class DeleteBackup(Kind):
|
|||
backup = Backup.objects.select_related("target").filter(uuid=op.params["backup"]).first()
|
||||
if backup is None:
|
||||
return Outcome(Operation.SUCCEEDED)
|
||||
return Outcome(Operation.SUCCEEDED, result=self._delete(backup, _target_pool(backup.target)))
|
||||
return Outcome(Operation.SUCCEEDED, result=self._delete(backup, _target_pool(backup.target)[1]))
|
||||
|
||||
def log_entry(self, op, state):
|
||||
backup = f"Backup {op.intent['time']} of {op.intent['vm']}"
|
||||
|
|
@ -503,22 +506,22 @@ def _check_name(name):
|
|||
raise util.OperationError(_("Instance name '%(clone_name)s' contains invalid characters!"), clone_name=name)
|
||||
|
||||
|
||||
def _check_files(conn, pool, backup):
|
||||
"""Each file of the backup is in the target: disks at their size, the
|
||||
small files with their SHA-256."""
|
||||
def _check_files(conn, pool, files):
|
||||
"""Each file of a backup ({role, volume, capacity, sha256}) is in the
|
||||
target: disks at their size, the small files with their SHA-256."""
|
||||
pool.refresh(0)
|
||||
for f in backup.files.all():
|
||||
for f in files:
|
||||
try:
|
||||
vol = pool.storageVolLookupByName(f.volume)
|
||||
vol = pool.storageVolLookupByName(f["volume"])
|
||||
except libvirtError as err:
|
||||
if err.get_error_code() != VIR_ERR_NO_STORAGE_VOL:
|
||||
raise
|
||||
raise util.OperationError(_("The backup's file %(name)s is missing from the target"), name=f.volume) from err
|
||||
if f.role == BackupFile.DISK:
|
||||
if vol.info()[1] != f.capacity:
|
||||
raise util.OperationError(_("The backup's file %(name)s differs from the one written"), name=f.volume)
|
||||
elif hashlib.sha256(get_file(conn, pool, f.volume)).hexdigest() != f.sha256:
|
||||
raise util.OperationError(_("The backup's file %(name)s differs from the one written"), name=f.volume)
|
||||
raise util.OperationError(_("The backup's file %(name)s is missing from the target"), name=f["volume"]) from err
|
||||
if f["role"] == BackupFile.DISK:
|
||||
if vol.info()[1] != f["capacity"]:
|
||||
raise util.OperationError(_("The backup's file %(name)s differs from the one written"), name=f["volume"])
|
||||
elif hashlib.sha256(get_file(conn, pool, f["volume"])).hexdigest() != f["sha256"]:
|
||||
raise util.OperationError(_("The backup's file %(name)s differs from the one written"), name=f["volume"])
|
||||
|
||||
|
||||
@register
|
||||
|
|
@ -574,7 +577,7 @@ class RestoreBackup(Kind):
|
|||
raise util.OperationError(_("A VM named %(name)s exists on %(compute)s"), name=p["name"], compute=compute.name)
|
||||
row = _target_row(backup.target, compute)
|
||||
tpool = target_pool(conn, row.pool, row.pool_uuid)
|
||||
_check_files(conn, tpool, backup)
|
||||
_check_files(conn, tpool, backup.files.values("role", "volume", "capacity", "sha256"))
|
||||
definition = get_file(conn, tpool, backup.files.get(role=BackupFile.DOMAIN).volume).decode()
|
||||
check_restore_host(conn, definition)
|
||||
pools = conn.file_pools()
|
||||
|
|
@ -672,3 +675,68 @@ class RestoreBackup(Kind):
|
|||
def _vm_page(op):
|
||||
vm = Instance.objects.get(compute_id=op.intent["compute"], uuid=op.intent["uuid"])
|
||||
return reverse("instances:instance", args=[vm.pk])
|
||||
|
||||
|
||||
@register
|
||||
class ImportBackups(Kind):
|
||||
"""The backups of a target read into the panel, as after the panel's
|
||||
database was lost: each manifest whose backup the panel does not list
|
||||
is checked as a restore checks it, then added with its files. Nothing
|
||||
on the target changes."""
|
||||
|
||||
name = "backup.import"
|
||||
label = _("Read backups from target")
|
||||
|
||||
def normalize(self, raw):
|
||||
return {"target": int(raw["target"])}
|
||||
|
||||
def plan(self, user, params):
|
||||
_superuser(user)
|
||||
target = BackupTarget.objects.get(pk=params["target"])
|
||||
return Plan(claims={claims.backup_target_key(target.pk): Claim.EXCLUSIVE},
|
||||
resource=claims.backup_target_key(target.pk), label=target.name, intent={"target": target.name})
|
||||
|
||||
def run(self, op, ctx):
|
||||
_superuser(op.user)
|
||||
target = BackupTarget.objects.get(pk=op.params["target"])
|
||||
conn, pool = _target_pool(target)
|
||||
added, incomplete = 0, []
|
||||
for name in manifest_names(pool):
|
||||
data = get_file(conn, pool, name)
|
||||
try:
|
||||
manifest = json.loads(data)
|
||||
if manifest["format"] != MANIFEST_FORMAT:
|
||||
raise ValueError(manifest["format"])
|
||||
if Backup.objects.filter(uuid=manifest["backup"]).exists():
|
||||
continue
|
||||
_check_files(conn, pool, manifest["files"])
|
||||
files = [{k: f[k] for k in ("role", "dev", "volume", "format", "capacity", "size", "sha256")}
|
||||
for f in manifest["files"]]
|
||||
vm, created_at = manifest["vm"], parse_datetime(manifest["created_at"])
|
||||
if created_at is None:
|
||||
raise ValueError(manifest["created_at"])
|
||||
fields = {"vm_uuid": vm["uuid"], "vm_name": vm["name"], "compute_name": manifest["compute"],
|
||||
"consistency": manifest["consistency"]}
|
||||
except (ValueError, KeyError, TypeError, util.OperationError):
|
||||
# cut short, not a manifest of the panel, or a file missing or changed: the others are still read
|
||||
incomplete.append(name)
|
||||
continue
|
||||
with transaction.atomic():
|
||||
backup = Backup.objects.create(
|
||||
uuid=manifest["backup"], target=target, state=Backup.READY, **fields,
|
||||
instance=Instance.objects.filter(uuid=fields["vm_uuid"]).first(),
|
||||
manifest=manifest, finished_at=timezone.now(), size=sum(f["size"] for f in files) + len(data),
|
||||
)
|
||||
# the time it was taken, not read
|
||||
Backup.objects.filter(pk=backup.pk).update(created_at=created_at)
|
||||
BackupFile.objects.bulk_create(BackupFile(backup=backup, **f) for f in files)
|
||||
added += 1
|
||||
result = {"added": added}
|
||||
if incomplete:
|
||||
result["warning"] = say(_("Not read, as a file of the backup is missing, changed or unreadable: %(names)s"),
|
||||
names=", ".join(incomplete))
|
||||
return result
|
||||
|
||||
def log_entry(self, op, state):
|
||||
message = f"Backup target {op.intent['target']}: backups read"
|
||||
return "-", "", "", message if state == Operation.SUCCEEDED else f"{message} ({state})"
|
||||
|
|
|
|||
|
|
@ -2,13 +2,23 @@
|
|||
{% load i18n %}
|
||||
{% load bootstrap_icons %}
|
||||
{% load django_bootstrap5 %}
|
||||
{% load operations %}
|
||||
|
||||
{% block title %}{{ target.name }} - {% trans "Backup targets" %}{% endblock %}
|
||||
|
||||
{% block page_heading %}<a href="{% url 'vmbackups:targets' %}">{% trans "Backup targets" %}</a> / {{ target.name }}{% endblock page_heading %}
|
||||
|
||||
{% block content %}
|
||||
<p class="text-body-secondary">{% blocktrans count counter=backup_count %}{{ counter }} backup.{% plural %}{{ counter }} backups.{% endblocktrans %}</p>
|
||||
<div class="d-flex flex-wrap align-items-center gap-2 mb-3">
|
||||
<span class="text-body-secondary me-auto">{% blocktrans count counter=backup_count %}{{ counter }} backup.{% plural %}{{ counter }} backups.{% endblocktrans %}</span>
|
||||
{% if pools %}
|
||||
<form method="post">
|
||||
{% csrf_token %}{% submission_key %}
|
||||
<button type="submit" name="import" value="1" class="btn btn-sm btn-outline-primary"
|
||||
title="{% trans "Adds the backups whose manifest is in the target and that the panel does not list, as after its database was lost." %}">{% bs_icon 'download' %} {% trans "Read backups from target" %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="row row-cols-1 row-cols-md-2 g-3 mb-4">
|
||||
{% for item in pools %}
|
||||
|
|
|
|||
153
vmbackups/tests/test_import.py
Normal file
153
vmbackups/tests/test_import.py
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
"""backup.import: a target's manifests read into the panel, each checked as
|
||||
a restore checks it."""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock, patch
|
||||
from uuid import uuid4
|
||||
|
||||
import libvirt
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.test import TransactionTestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from appsettings.settings import get_settings
|
||||
from computes.models import Compute
|
||||
from instances.models import Instance
|
||||
from operations import jobs
|
||||
from operations.jobs import Context
|
||||
from operations.models import Operation, acquire
|
||||
from vmbackups.jobs import ImportBackups
|
||||
from vmbackups.models import Backup, BackupTarget, BackupTargetPool
|
||||
|
||||
GIB = 1024**3
|
||||
WORKER = "wvc-test:1:a"
|
||||
DOMAIN = b"<domain><name>vm1</name></domain>"
|
||||
|
||||
|
||||
def manifest(uuid, vm_uuid="51515151-0000-4000-8000-000000000001"):
|
||||
return {
|
||||
"format": 1, "backup": uuid, "vm": {"name": "vm1", "uuid": vm_uuid}, "compute": "h0",
|
||||
"created_at": "2026-11-01T10:00:00+00:00", "consistency": "frozen", "nvram": "none", "left_out": [],
|
||||
"libvirt": 11010000, "hypervisor": 10001000,
|
||||
"files": [
|
||||
{"role": "disk", "dev": "vda", "volume": f"wvc-{uuid}-vda.qcow2", "format": "qcow2", "capacity": GIB,
|
||||
"size": GIB // 2, "sha256": ""},
|
||||
{"role": "domain", "dev": "", "volume": f"wvc-{uuid}-domain.xml", "format": "", "capacity": len(DOMAIN),
|
||||
"size": len(DOMAIN), "sha256": hashlib.sha256(DOMAIN).hexdigest()},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def error(code):
|
||||
err = libvirt.libvirtError("x")
|
||||
err.err = (code,)
|
||||
return err
|
||||
|
||||
|
||||
class ImportTests(TransactionTestCase):
|
||||
def setUp(self):
|
||||
get_settings()
|
||||
self.admin = get_user_model().objects.create_superuser("im_admin", "a@example.com", "pw")
|
||||
self.compute = Compute.objects.create(name="h1", hostname="192.0.2.51", login="u", password="p", type=1)
|
||||
self.vm = Instance.objects.create(compute=self.compute, name="vm1", uuid="51515151-0000-4000-8000-000000000001")
|
||||
self.target = BackupTarget.objects.create(name="nfs1")
|
||||
BackupTargetPool.objects.create(target=self.target, compute=self.compute, pool="b1", pool_uuid="u")
|
||||
self.a, self.b = str(uuid4()), str(uuid4())
|
||||
self.files = {}
|
||||
for uuid in (self.a, self.b):
|
||||
self.files[f"wvc-{uuid}-manifest.json"] = json.dumps(manifest(uuid)).encode()
|
||||
self.files[f"wvc-{uuid}-domain.xml"] = DOMAIN
|
||||
self.files[f"wvc-{uuid}-vda.qcow2"] = None
|
||||
self.pool = MagicMock()
|
||||
|
||||
def volume(name):
|
||||
if name not in self.files:
|
||||
raise error(libvirt.VIR_ERR_NO_STORAGE_VOL)
|
||||
vol = MagicMock()
|
||||
vol.info.return_value = [0, GIB, GIB // 2]
|
||||
return vol
|
||||
|
||||
self.pool.storageVolLookupByName.side_effect = volume
|
||||
for name, value in (
|
||||
("vmbackups.jobs.wvmConnect", MagicMock()),
|
||||
("vmbackups.jobs.target_pool", MagicMock(return_value=self.pool)),
|
||||
("vmbackups.jobs.manifest_names", MagicMock(side_effect=lambda pool: sorted(
|
||||
n for n in self.files if n.endswith("-manifest.json")))),
|
||||
("vmbackups.jobs.get_file", MagicMock(side_effect=lambda conn, pool, name: self.files[name])),
|
||||
):
|
||||
patcher = patch(name, value)
|
||||
patcher.start()
|
||||
self.addCleanup(patcher.stop)
|
||||
|
||||
def read(self):
|
||||
op = jobs.submit("backup.import", self.admin, {"target": self.target.pk}, f"key-{uuid4().hex[:12]}")
|
||||
acquire(WORKER, "wvc-test")
|
||||
Operation.objects.filter(pk=op.pk).update(state=Operation.RUNNING, worker=WORKER)
|
||||
op.refresh_from_db()
|
||||
result = ImportBackups().run(op, Context(op, SimpleNamespace(identity=WORKER)))
|
||||
jobs.finish(op, jobs.Outcome(Operation.SUCCEEDED, result=result))
|
||||
return result
|
||||
|
||||
def test_new_manifests_are_added_once(self):
|
||||
self.assertEqual(self.read(), {"added": 2})
|
||||
backup = Backup.objects.get(uuid=self.a)
|
||||
self.assertEqual((backup.state, backup.target, backup.instance, backup.vm_name, backup.consistency),
|
||||
(Backup.READY, self.target, self.vm, "vm1", "frozen"))
|
||||
self.assertEqual(backup.created_at.isoformat(), "2026-11-01T10:00:00+00:00")
|
||||
self.assertEqual(sorted(backup.files.values_list("role", flat=True)), ["disk", "domain"])
|
||||
self.assertEqual(self.read(), {"added": 0})
|
||||
self.assertEqual(Backup.objects.count(), 2)
|
||||
|
||||
def test_a_manifest_with_a_missing_file_is_incomplete(self):
|
||||
del self.files[f"wvc-{self.b}-vda.qcow2"]
|
||||
self.files[f"wvc-{self.a}-domain.xml"] = b"<domain/>" # changed since it was written
|
||||
result = self.read()
|
||||
self.assertEqual(result["added"], 0)
|
||||
# the job page shows a warning
|
||||
self.assertEqual(result["warning"][0]["values"]["names"],
|
||||
", ".join(sorted([f"wvc-{self.a}-manifest.json", f"wvc-{self.b}-manifest.json"])))
|
||||
self.assertFalse(Backup.objects.exists())
|
||||
|
||||
def test_a_damaged_manifest_is_passed_over(self):
|
||||
self.files[f"wvc-{self.a}-manifest.json"] = b'{"format": 1, "backup' # cut short as it was written
|
||||
result = self.read()
|
||||
self.assertEqual(result["added"], 1)
|
||||
self.assertEqual(result["warning"][0]["values"]["names"], f"wvc-{self.a}-manifest.json")
|
||||
self.assertTrue(Backup.objects.filter(uuid=self.b).exists())
|
||||
|
||||
def test_a_manifest_of_another_format_or_without_its_fields_is_passed_over(self):
|
||||
other = manifest(self.a)
|
||||
other["format"] = 2
|
||||
self.files[f"wvc-{self.a}-manifest.json"] = json.dumps(other).encode()
|
||||
broken = manifest(self.b)
|
||||
broken["created_at"] = "yesterday" # parse_datetime gives None
|
||||
self.files[f"wvc-{self.b}-manifest.json"] = json.dumps(broken).encode()
|
||||
result = self.read()
|
||||
self.assertEqual(result["added"], 0)
|
||||
self.assertIn(f"wvc-{self.b}-manifest.json", result["warning"][0]["values"]["names"])
|
||||
self.assertIn(f"wvc-{self.a}-manifest.json", result["warning"][0]["values"]["names"])
|
||||
|
||||
def test_a_known_backup_is_left_alone(self):
|
||||
Backup.objects.create(uuid=self.a, target=self.target, vm_uuid="x", vm_name="kept", compute_name="h1",
|
||||
state=Backup.READY)
|
||||
self.assertEqual(self.read()["added"], 1)
|
||||
self.assertEqual(Backup.objects.get(uuid=self.a).vm_name, "kept")
|
||||
|
||||
def test_a_backup_of_a_removed_vm_has_no_vm(self):
|
||||
self.vm.delete()
|
||||
self.read()
|
||||
self.assertIsNone(Backup.objects.get(uuid=self.a).instance)
|
||||
|
||||
def test_the_target_page_reads_the_target(self):
|
||||
self.client.force_login(self.admin)
|
||||
url = reverse("vmbackups:target", args=[self.target.pk])
|
||||
with patch("vmbackups.views.wvmConnect"), patch("vmbackups.views.target_pool") as page_pool, \
|
||||
patch("vmbackups.views.inside_vm_pool", return_value=None):
|
||||
page_pool.return_value.info.return_value = [2, 100 * GIB, 40 * GIB, 60 * GIB]
|
||||
self.assertContains(self.client.get(url), 'name="import"')
|
||||
response = self.client.post(url, {"import": "1", "submission_key": "key-page-imp1"})
|
||||
op = Operation.objects.get()
|
||||
self.assertEqual(op.kind, "backup.import")
|
||||
self.assertRedirects(response, reverse("operations:job", args=[op.pk]), fetch_redirect_response=False)
|
||||
|
|
@ -69,6 +69,16 @@ def target(request, target_id):
|
|||
with audit(request, None, subject, "delete"):
|
||||
target.delete()
|
||||
return redirect("vmbackups:targets")
|
||||
if request.method == "POST" and "import" in request.POST:
|
||||
try:
|
||||
op = jobs.submit("backup.import", request.user, {"target": target.pk}, request.POST.get("submission_key", ""))
|
||||
except claims.Busy as busy:
|
||||
messages.error(request, busy_message(busy, request.user))
|
||||
except (jobs.SubmissionConflict, libvirtError) as err:
|
||||
messages.error(request, error_text(request, err))
|
||||
else:
|
||||
return redirect("operations:job", op.pk)
|
||||
return redirect("vmbackups:target", target.id)
|
||||
if request.method == "POST" and "remove_pool" in request.POST:
|
||||
row = get_object_or_404(target.pools.select_related("compute"), pk=request.POST["remove_pool"])
|
||||
if target.backups.exists():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue