Back Up and Restore MySQL Snapshots

Use the existing MySQL snapshot on your source Virtual Appliance to back up and restore on the destination Virtual Appliance.

Back Up a MySQL Snapshot

Back up the MySQL data on your source Virtual Appliance by creating a MySQL database snapshot.
  1. Log in to your source Virtual Appliance and create a MySQL snapshot.
    1. Create a new MySQL snapshot.
      Note: Use this command to create a new snapshot or if the source Virtual Appliance has no snapshots.
      dumpInstance
      CODE
      appdcli run mysql_backup create-snapshot <snapshot-name>
      xtrabackup
      CODE
      # Trigger a full backup
      appdcli backup mysql full [--pod appd-mysql-0]
      
      #incremental MySQL backups
      appdcli backup mysql incr [--pod <pod>]

      The backup job takes some time to complete.

    2. View the backup file:
      CODE
      # List XtraBackup CRs
      appdcli backup mysql list
      
      # List all backup chains with size and incremental
      appdcli backup mysql list-chains

      A default folder is created at /mnt/nfs_share on the NFS server.

  2. Log in to the NFS server and view the backup files.
    CODE
    /mnt/nfs_share# ls -ltr

    Sample Output:

    CODE
    drwx------ 5   27 sudo 4096 Oct  8 16:10 mysql-mysql-backup-pvc-pvc-545f88bb-62b4-4bc1-820c-eda07a3db15e
    To view the contents in the backup file, run this command:
    CODE
    ls -ltr <Backup-of-MySQL-Folder-VA>
    Sample Output:
    CODE
    total 84
    drwxr-x---. 2 27 27 61440 Oct 10 11:05 backup-20251017052203

Restore a MySQL Snapshot

When you restore a MySQL snapshot, all MySQL data on the destination Virtual Appliance is erased and replaced with data from the source Virtual Appliance. Restore the MySQL snapshot on the destination Virtual Appliance:
  1. Log in to your destination Virtual Appliance and create a MySQL snapshot.
    1. Create a new MySQL snapshot.
      dumpInstance
      CODE
      appdcli run mysql_backup create-snapshot <snapshot-name>

      Sample Output

      CODE
      create-snapshot started. Status='backup-20251017052203'
      xtrabackup
      CODE
      # Trigger a full backup
      appdcli backup mysql full [--pod appd-mysql-0]
      
      #incremental MySQL backups
      appdcli backup mysql incr [--pod <pod>]

      Sample Output:

      The backup job takes some time to complete.

    2. View the backup file using the following command:
      dumpInstance
      CODE
      appdcli backup mysql list
      xtrabackup
      CODE
      # List XtraBackup CRs
      appdcli backup mysql list
      
      # List all backup chains with size and incremental
      appdcli backup mysql list-chains

      A default folder is created at /mnt/nfs_share on the NFS server.

  2. Log in to NFS server to copy the backup file.
    1. View the backup files.
      CODE
      /mnt/nfs_share# ls -ltr
    2. Copy the source Virtual Appliance backup file contents to destination Virtual Appliance.
      CODE
      cp -r <Backup-of-MySQL-Folder-Source-VA>/* <Backup-of-MySQL-Folder-Destination-VA>
  3. For MySQL dumpInstance, log in to your destination Virtual Appliance server and clear the user-defined schema.
    CODE
    kubectl exec -it appd-mysqlsh-0 -n mysql bash
          cd /mysqlsh
          bash drop-user-schemas.sh 
          exit
  4. Restore the MySQL snapshot.
    dumpInstance
    CODE
    appdcli backup mysql restore-snapshot <repo-name>
    Example:
    CODE
    appdcli backup mysql restore-snapshot repo3 backup-20251017052203
    xtrabackup
    CODE
    # Latest chain and all incremental backups
    appdcli backup mysql restore 
    
    # Selected chain and all incremental backups
    appdcli backup mysql restore --from-chain <timestamp> 
    
    # Selected chain through an incremental backup, inclusively
    appdcli backup mysql restore --from-chain <timestamp> --from-incr <timestamp> 
    
    # Full backup only
    appdcli backup mysql restore --from-chain <timestamp> --from-incr full
    Note: You must manually restore the MySQL cluster.
  5. Verify the progress of MySQL restoration using the following command:
    CODE
    NAME                                 READY   STATUS      RESTARTS   AGE
    appd-mysql-0                         2/2     Running     0          5d12h
    appd-mysql-1                         2/2     Running     0          5d12h
    appd-mysql-2                         2/2     Running     0          5d12h
    appd-mysql-router-7b956f54c8-2xgpg   1/1     Running     0          5d12h
    appd-mysql-router-7b956f54c8-2zqdq   1/1     Running     0          5d12h
    appd-mysql-router-7b956f54c8-46wjh   1/1     Running     0          5d12h
    appd-mysqlsh-0                       1/1     Running     0          5d12h
    appd-mysqlsh-1                       1/1     Running     0          5d12h
    appd-mysqlsh-2                       1/1     Running     0          5d12h
    backup-20251017052203-2q8jn          0/1     Completed   0          7m24s
    restore-20251017052907-sncvm         1/1     Running     0          20s
    restore-dump-nh52z                   0/1     Completed   0          5d12h
Note: After restoring MySQL on the destination Virtual Appliance, the Controller UI will display the data from that Virtual Appliance. Log in to the Controller UI to verify that it displays the correct data.

Once the destination Virtual Appliance is ready, redirect the traffic from the source Virtual Appliance to this destination Virtual Appliance.