# Restoring Cloudsnaps to same OR different namespace

**URL:** <https://forums.portworx.com/t/restoring-cloudsnaps-to-same-or-different-namespace/815>\
**Category:** Portworx Volumes\
**Created:** [February 22, 2021, 8:35am UTC](https://forums.portworx.com/t/restoring-cloudsnaps-to-same-or-different-namespace/815 "2021-02-22T08:35:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![varunjain](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.portworx.com/varunjain/32/108_2.png) [@varunjain](https://forums.portworx.com/u/varunjain)\
**Post date:** [February 22, 2021, 8:35am UTC](https://forums.portworx.com/t/restoring-cloudsnaps-to-same-or-different-namespace/815/1 "2021-02-22T08:35:12Z")

</div>

To restore your cloudsnap to a different namespace, you may use the following PVC object and create it under the different namespace while applying.

When you install Stork, it also creates a storage class called _stork-snapshot-sc_ . This storage class can be used to create PVCs from snapshots.

To create a PVC from a snapshot, you would add the `snapshot.alpha.kubernetes.io/snapshot` annotation to refer to the snapshot name.

– **Restoring to same namespace:**

_ **Pre-requisites:** _

1. `Name of the snapshot object` - You can get this with `kubectl get volume snapshot -n test-namespace`

**Use the annotation:**  
`snapshot.alpha.kubernetes.io/snapshot:`

`kubectl apply -f restore_pvc.yaml`

```auto
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-snap-clone
  annotations:
    snapshot.alpha.kubernetes.io/snapshot: mysql-snapshot //This is exact snapshot name 
spec:
  accessModes:
     - ReadWriteOnce
  storageClassName: stork-snapshot-sc
  resources:
    requests:
      storage: 2Gi

```

– **Restoring to different namespace:**

_ **Pre-requisites:** _

1. `Name of the snapshot object` - You can get this with `kubectl get volumesnapshot -n test-namespace`
2. `NameSpace of the snapshot object currently`

Lets say, you are trying to restore a PVC into a new namespace, other than the original namespace,

If the snapshot exists in another namespace, the snapshot namespace should be specified with the annotation in the restored PVC as follows:

`stork.libopenstorage.org/snapshot-source-namespace: <EXISTING-NAMESPACE>`

**Note that the storageClassName needs to be the Stork StorageClass `stork-snapshot-sc` as in the example below.**

The following spec restores a PVC from the snapshot in the example above:

`kubectl apply -f restore_pvc.yaml -n <NEW-NAMESPACE> `

```auto
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-snap-clone
  annotations:
    snapshot.alpha.kubernetes.io/snapshot: mysql-snapshot //This is exact snapshot name 
     stork.libopenstorage.org/snapshot-source-namespace: <Namespace of mysql-snapshot>
spec:
  accessModes:
     - ReadWriteOnce
  storageClassName: stork-snapshot-sc
  resources:
    requests:
      storage: 2Gi

```

---

<div class="post-metadata">

**Author:** ![sensre](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.portworx.com/sensre/32/299_2.png) [@sensre](https://forums.portworx.com/u/sensre)\
**Post date:** [February 27, 2021, 9:43pm UTC](https://forums.portworx.com/t/restoring-cloudsnaps-to-same-or-different-namespace/815/2 "2021-02-27T21:43:47Z")

</div>

Nice Post, Will it work in px 2.5.x versions as well? Can i also use the schedule policy during my restore ?

---

<div class="post-metadata">

**Author:** ![varunjain](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.portworx.com/varunjain/32/108_2.png) [@varunjain](https://forums.portworx.com/u/varunjain)\
**Post date:** [March 12, 2021, 4:58pm UTC](https://forums.portworx.com/t/restoring-cloudsnaps-to-same-or-different-namespace/815/3 "2021-03-12T16:58:31Z")

</div>

Yes it will work with PX 2.5.  
After the volume is restored, you need to create the Kubernetes objects (PVC, PV) first to schedule that restored volume using VolumeSnapshot object.  
OR  
it can be done using the pxctl CLI without creating the objects.
