cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

backup: simple NAS backup plugin for KVM (experimental)

Open rohityadavcloud opened this issue 1 year ago • 30 comments

This is an experimental simple NAS backup plugin for KVM which may be later expanded for other hypervisors. This backup plugin aims to use shared NAS storage on KVM hosts such as NFS or CephFS, which is used to backup fully cloned VMs for backup & restore operations. This may not be as efficient and performant as some of the other B&R providers, but maybe useful for some KVM environments.

Design & Implementation follows the networker B&R plugin, which is simply:

  • Implement B&R plugin interfaces
  • Use cmd-answer pattern to execute backup and restore operations on KVM host when VM is running (or needs to be restored) - instead of a B&R API client, relies on answers from KVM agent which executes the operations
  • Backups are full VM domain snapshots, copied to a VM-specific folders on a NAS target (NFS or CephFS WIP) along with a domain XML
  • Backup uses libvirt feature: https://libvirt.org/kbase/live_full_disk_backup.html orchestrated via virsh/bash script (nasbackup.sh) as libvirt-java lacks the bindings

Doc PR https://github.com/apache/cloudstack-documentation/pull/429

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] Enhancement (improves an existing feature and functionality)
  • [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
  • [ ] build/CI
  • [ ] test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [x] Major
  • [ ] Minor

Screenshots

Each backup offering map to a Backup repository that takes in backup storage details (address/url, credentials/mount options): Screenshot 2024-08-02 at 5 32 41 PM

Rest is same as B&R feature works; we assign such offering to a VM and backup once completed shows up in the list: Screenshot 2024-08-02 at 5 58 49 PM Screenshot 2024-08-02 at 5 59 07 PM

rohityadavcloud avatar Jul 26 '24 06:07 rohityadavcloud

Codecov Report

Attention: Patch coverage is 0.62696% with 951 lines in your changes missing coverage. Please review.

Project coverage is 15.61%. Comparing base (605534b) to head (9efdb57). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...rg/apache/cloudstack/backup/NASBackupProvider.java 0.00% 218 Missing :warning:
...ce/wrapper/LibvirtRestoreBackupCommandWrapper.java 0.81% 121 Missing :warning:
...apache/cloudstack/backup/RestoreBackupCommand.java 0.00% 66 Missing :warning:
...udstack/api/response/BackupRepositoryResponse.java 0.00% 63 Missing :warning:
...g/apache/cloudstack/backup/BackupRepositoryVO.java 0.00% 56 Missing :warning:
...cloudstack/backup/BackupRepositoryServiceImpl.java 0.00% 46 Missing :warning:
...rg/apache/cloudstack/backup/TakeBackupCommand.java 0.00% 44 Missing :warning:
...rg/apache/cloudstack/backup/BackupManagerImpl.java 4.34% 44 Missing :warning:
...user/backup/repository/AddBackupRepositoryCmd.java 0.00% 43 Missing :warning:
.../apache/cloudstack/backup/DeleteBackupCommand.java 0.00% 34 Missing :warning:
... and 18 more
Additional details and impacted files
@@             Coverage Diff              @@
##              main    #9451       +/-   ##
============================================
+ Coverage     4.12%   15.61%   +11.49%     
- Complexity       0    12118    +12118     
============================================
  Files          383     5555     +5172     
  Lines        31354   486283   +454929     
  Branches      5551    61315    +55764     
============================================
+ Hits          1293    75945    +74652     
- Misses       29915   401966   +372051     
- Partials       146     8372     +8226     
Flag Coverage Δ
uitests 4.12% <ø> (+<0.01%) :arrow_up:
unittests 16.40% <0.62%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 26 '24 06:07 codecov[bot]

Update: take backup & delete backup implemented for NFS; TBD/TODO more operations.

rohityadavcloud avatar Aug 01 '24 12:08 rohityadavcloud

@blueorangutan package

rohityadavcloud avatar Aug 02 '24 10:08 rohityadavcloud

@rohityadavcloud a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 02 '24 10:08 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10548

blueorangutan avatar Aug 02 '24 11:08 blueorangutan

Tested NFS, CephFS & samba, works when configuration is correctly configured; for example;

mysql> select * from backup_repository\G;
*************************** 1. row ***************************
            id: 1
          uuid: d3b911d4-50a6-11ef-bc8b-525400f93984
          name: NFS-backup
       zone_id: 1
      provider: nas
          type: nfs
       address: 172.20.0.1:/export/testing/qa1-cs420-kvm-1cdf7971-kvm/backup
    mount_opts:
    used_bytes: NULL
capacity_bytes: NULL
       created: 2024-08-02 08:11:31
       removed: NULL
*************************** 2. row ***************************
            id: 2
          uuid: 09c2efd1-50c4-11ef-bc8b-525400f93984
          name: Ceph-backup
       zone_id: 1
      provider: nas
          type: ceph
       address: 10.10.1.10,10.10.1.11,10.10.1.12:/backup
    mount_opts: name=rohit,secret=XXXX==
    used_bytes: NULL
capacity_bytes: NULL
       created: 2024-08-02 11:40:37
       removed: NULL
*************************** 3. row ***************************
            id: 3
          uuid: 876b1da4-50c6-11ef-bc8b-525400f93984
          name: Samba-backup
       zone_id: 1
      provider: nas
          type: cifs
       address: //192.168.1.10/backup
    mount_opts: vers=3.0,username=rohit,password=XXXX
    used_bytes: NULL
capacity_bytes: NULL
       created: 2024-08-02 11:58:27
       removed: NULL
3 rows in set (0.00 sec)

rohityadavcloud avatar Aug 02 '24 12:08 rohityadavcloud

Shared storage mount/umount tested:

  • EL8 & EL9: NFS & CephFS works (ceph would require rbd utils, otherwise uses Linux kernel's cephfs driver)
  • Ubuntu: NFS, CephFS & CIFS/SMB3 works (the latter two need cifs-utils & ceph utils)

rohityadavcloud avatar Aug 06 '24 09:08 rohityadavcloud

@blueorangutan package

Pearl1594 avatar Aug 06 '24 15:08 Pearl1594

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 06 '24 15:08 blueorangutan

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 10579

blueorangutan avatar Aug 06 '24 16:08 blueorangutan

@blueorangutan package

Pearl1594 avatar Aug 06 '24 17:08 Pearl1594

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 06 '24 17:08 blueorangutan

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 10580

blueorangutan avatar Aug 06 '24 18:08 blueorangutan

@blueorangutan package

Pearl1594 avatar Aug 06 '24 21:08 Pearl1594

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 06 '24 21:08 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10583

blueorangutan avatar Aug 06 '24 23:08 blueorangutan

nice feature idea @rohityadavcloud :+1:

DaanHoogland avatar Aug 12 '24 12:08 DaanHoogland

@blueorangutan package

Pearl1594 avatar Aug 12 '24 17:08 Pearl1594

@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 12 '24 17:08 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10621

blueorangutan avatar Aug 12 '24 18:08 blueorangutan

@blueorangutan package

DaanHoogland avatar Aug 12 '24 19:08 DaanHoogland

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 12 '24 19:08 blueorangutan

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10624

blueorangutan avatar Aug 12 '24 20:08 blueorangutan

@blueorangutan package

Pearl1594 avatar Aug 15 '24 16:08 Pearl1594

Update cc @DaanHoogland @sureshanaparti @shwstppr @rajujith @NuxRo the experimental plugin is ready for review & testing, pending a bit of cleanup, maybe tests & doc work. Tested following cases:

  • Backup of VM with root disk & VM with root & data disks
  • Restore of backup of VM with root disk & VM with root & data disks
  • Deleting backups of VM with root disk & VM with root & data disks
  • Restore a volume of a backup of VM

Case WIP: restoring VM using backup for a VM which is expunged

@blueorangutan package

rohityadavcloud avatar Aug 28 '24 12:08 rohityadavcloud

@rohityadavcloud a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

blueorangutan avatar Aug 28 '24 12:08 blueorangutan

@Pearl1594 do we have more (internal?) details on the design of this one? Looks really interesting.

andrijapanicsb avatar Aug 28 '24 13:08 andrijapanicsb

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10847

blueorangutan avatar Aug 28 '24 13:08 blueorangutan

There isn't a design doc or spec, I'll submit a doc PR which can be used for notes. The plugin simply uses existing B&R framework and follows on the footsteps of networker plugin, so its well isolated as yet another plugin - all supported B&R functionality work as-is, doc PR will make it further clear.

@blueorangutan test

rohityadavcloud avatar Aug 29 '24 07:08 rohityadavcloud

@rohityadavcloud a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

blueorangutan avatar Aug 29 '24 07:08 blueorangutan