Deleting Oracle ZFS Appliance Snapshots

The Oracle ZFS Storage Appliance features a snapshot data service, Snapshots are read-only copies of a filesystem at a given point-in-time. You can think of ZFS snapshots as a restore point of data set for project and shares, which can be used to rollback state of data set to point-in-time just like Oracle database restore points conceptually. ZFS Snapshots are only logical entities, so you can create virtually unlimited number of snapshots without taking up any space. Snapshots can be scheduled or taken manually, depending on usage and policies. We can manage snapshots using Oracle ZFS Appliance graphical interface BUI or through scripts. There are times when you want to manage snapshot using scripts especially when you want to integrate them with Oracle backups. SSH user equivalence might be required if you are looking to execute the following script without providing the root passwords. Following is an example, how to delete project snapshots using a shell script on both ZFS controllers (in case you are using active/active ZFS cluster).

Delete Project Snapshots

 

> cat delete_snap_project.sh

echo "Head 1"

cat <<eof |ssh -T -i ~/.ssh/id_rsa root@zfscontroller-1

script

{

 run('cd /');

 run('shares');

 run('set pool=pool1');

 run('select H1-dbname');

 run('snapshots select snap_20170924_1938');

 run('confirm destroy');

 printf("snapshot of the project has been delete..\n");

}

eof

echo "Head 2"

cat <<eof |ssh -T -i ~/.ssh/id_rsa root@zfscontroller-2

script

{

 run('cd /');

 run('shares');

 run('set pool=pool2');

 run('select H2-dbname');

 run('snapshots select snap_20170924_1938');

 run('confirm destroy');

 printf("snapshot of the project has been delete..\n");

}

eof

Script Output :

> ./delete_snap_project.sh

Head 1

snapshot of the project has been delete..

Head 2

snapshot of the project has been delete..

oracle@exa2node:/home/oracle