Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

To Backup and Restore Your System

This product was previously named Anypoint Platform On-Premises Edition. Beginning with the 1.5.1 release, it is named Anypoint Platform Private Cloud Edition.

Creating a Backup

To preserve your data in case of system failure, you must ensure that you system is automatically backed up. You should configure your backup to run at least once per day, although MuleSoft recommends that you back up your system hourly.

Your backup archive must be stored on external storage outside the Anypoint cluster.

You must perform backups from a master node of your installation. If you installed the platform with a six server configuration, only three of the servers are master nodes. If you are running 1 or 3 node installation, all nodes are master nodes.

  1. Determine which node is registered as a master node:

    kubectl get nodes -o yaml|grep master -A 5|grep hostname

    You can run this command on any node in the cluster to determine which nodes are master nodes.

    To create a backup, you must run the following commands on a master node in the cluster.

  2. Enter the gravity utility:

    sudo gravity enter
  3. Create a backup archive:

    gravity system backup gravitational.io/anypoint:0.0.0+latest /ext/share/backup.tar.gz

    This command creates an archive of the current system state in: /var/lib/gravity/planet/share/backup.tar.gz.

After running the backup command, you may see the following error message:

Error from server: container "anypoint-backup" in pod "anypoint-backup-<pod-id>" is waiting to start: PodInitializing

This indicates that the Kubernetes pod running the backup job is not currently running.

Performing a System Restore

To restore a system from your backup, use the existing cluster or create a new cluster containing the same number of servers as the cluster being restored.

  1. Log in to one of the nodes in your cluster.

  2. Move the compressed archive file to: /var/lib/gravity/planet/share. You can transfer this file securely via the following command:

    scp /backup-path/to-restore.tar.gz your_username@remotehost.edu:/var/lib/gravity/planet/share
  3. Enter the gravity utility:

    sudo gravity enter
  4. Restore the cluster from the backup archive:

    gravity system restore gravitational.io/anypoint:0.0.0+latest /ext/share/to-restore.tar.gz
  5. Run the following script after the restore is complete. This script recreates each pod to ensure that it uses the restored secrets.

    deployments=$(kubectl get deployments | awk 'NR>1 {print $1}')
    now=$(date "+%Y-%m-%d-%H-%M-%S")
    
        #Recreate stolon-keeper pods to update database's certificate
        kubectl delete pods --selector stolon-keeper=yes
    
        # Wait for database pods to restart
        while kubectl get pods | grep stolon-keeper | grep -q ContainerCreating; do
            echo "Waiting for database pods..."
            sleep 5s
        done
    
        # Patching deployment's metadata will trigger redeploy of pods automatically
        for deployment in $deployments; do
            kubectl patch deployment $deployment -p '{"spec":{"template":{"metadata":{"labels":{"restore": "'"$now"'"}}}}}'
            sleep 5s
            while kubectl get pods | grep -q -e ContainerCreating -e Pending; do
                echo "Waiting for service pods..."
                sleep 5s
            done
    done