Search code examples
neo4jgoogle-compute-enginekubernetespersistent-storage

How to download Google Compute Engine disk content?


I have linked a Persistent Volume to my Kubernetes Neo4j Replication Controller to store the DB data. Now I would like to download that data locally to run the production DB on my system. I can't find the way to download the Disk content. Can someone point me in the right direction?

Updates (Persistent Volume Creation with Kubernetes):

persistent-volume-db.json
{
  "kind": "PersistentVolume",
  "apiVersion": "v1",
  "metadata": {
    "name": "pv-db"
  },
  "spec": {
    "capacity": {
      "storage": "500Gi"
    },
    "accessModes": [
      "ReadWriteMany"
    ],
    "gcePersistentDisk": {
      "pdName": "tuwa-db-data-disk",
      "fsType": "ext4"
    }
  }
}

persistent-volume-claim-db.json
{
  "kind": "PersistentVolumeClaim",
  "apiVersion": "v1",
  "metadata": {
    "name": "pvc"
  },
  "spec": {
    "accessModes": [
      "ReadWriteMany"
    ],
    "resources": {
      "requests": {
        "storage": "500Gi"
      }
    }
  }
}

And then the usage:

neo4j-controller.json
{
  "kind": "ReplicationController",
  "apiVersion": "v1",
  "metadata": {
    "name": "neo4j-controller",
    "labels": {
      "name": "neo4j"
    }
  },
  "spec": {
    "replicas": 1,
    "template": {
      "metadata": {
        "labels": {
          "name": "neo4j"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "neo4j",
            "image": "neo4j/neo4j",
            "ports": [
              {
                "name": "neo4j-server",
                "containerPort": 7474
              }
            ],
            "volumeMounts": [
              {
                "mountPath": "/data/databases",
                "name": "pv-db"
              }
            ]
          }
        ],
        "volumes": [
          {
            "name": "pv-db",
            "persistentVolumeClaim": {
              "claimName": "pvc-db"
            }
          }
        ]
      }
    }
  }
}

Solution

  • GCE's admin panel doesn't have a "download" button for persistent disks, but gcloud makes it easy to copy files from an instance to your local machine:

    gcloud compute copy-files example-instance:~/REMOTE-DIR ~/LOCAL-DIR --zone us-central1-a

    This will copy ~/REMOTE-DIR from a remote instance into ~/LOCAL-DIR on your machine. Just replace the directory names, example-instance with your instances name, and adjust your zone if necessary. More info here in the docs.