In this post will show you the data backup and recovery mechanism in Oracle Solaris 11. For backing up the data, you create snapshots, as well as use ZFS send/receive commands. The send/receive commands can be used to save the backed up data (snapshots) on the local or remote machine. You use rollback commands to recover the backed up or lost data.
Step 1: Verify that Solaris11 server is running. If the server is not running, start it now and log in to the Solaris11 server as a root user.
Step 2: Execute the zpool list command to display the ZFS pools that are currently configured in the system.
Step 3: Run the zpool create command to create a pool with two top-level virtual devices. Check the pool information by using zpool list and zpool status.
Confirm that the new pool has been created.
Step 4: Create a file system named oracledb/oradata with a mount point of /oradata. Check the file system creation and the mount point by running the zfslist command.
Note that the mount point was specified to be /oradata for oracledb/oradata to be able to access the oradata file system directly.
Step 5: Create new ZFS file systems named oracledb/oradata/cust, oracledb/oradata/mktg, and oracledb/oradata/om. List the descendants of the oracledb file system.
Note: These file systems are created to demonstrate individual file systems for each business application, as you will experience on the job.
Here, you create file systems to store data for the CRM application. The file systems are cust, mktg, and om. Note the used column and the refer column for the new file systems. The file systems are consuming an initial storage space of 31 KB.
Step 6: Using the tar command, create a tar bundle that will serve as an example of the business application data. Copy custarchive.tar to each oradata file system and the /opt/ora/data directory for future use. Note the amount of data used and referenced by these file systems.
Now you are saving the data in /opt/ora/data so that it will be available to you in the subsequent steps.
root@solaris11:~# cp /oradata/cust/custarchive.tar /opt/ora/data/custarchive.tar
To test you are creating application data and placing it in the oradata file systems.
Note: After placing application data in each file system, you see that all the file systems indicate 929 KB worth of storage. Your numbers may be different.
Step 7: Create a recursive snapshot of oracledb/oradata named oracledb/oradata@monday. List the file systems below oracledb. Note the amount of space used and referenced by oracledb/oradata@monday.
root@solaris11:~# zfs snapshot -r oracledb/oradata@monday
Recursively create snapshots of every file system in oradata. The purpose is to create a backup of each file system—that is, cust, mktg, and om data.
Now, when you try to display the children file systems of oracledb recursively, the snapshots are not displayed. Take a look at this
As displayed here, the listsnapshots property is off by default. You now enable it.
root@solaris11:~# zpool set listsnapshots=on oracledb
Now, when you display the descendant file systems of oracledb, they are displayed.
Note that there is one snapshot for each file system and they are all suffixed with @monday. As you can see, this is a very easy way to create multiple data backups and identify all of them with the same identifier.
Note that the newly created snapshots do not use any space (initially) but they do indicate 929 KB worth of storage, which includes the data that you placed in each file system. The snapshots initially do not take up any space because they are using the existing file system data pointers.
Step 8: Create a file named /oradata/cust/company. Confirm that the file exists.
root@solaris11:~# touch /oradata/cust/company
You create a file to store data on a customer company
root@solaris11:~# ls /oradata/cust/company
/oradata/cust/company
Success! You confirmed that it exists. Note that this file was created after taking a backup on Monday.
Step 9: Create another recursive snapshot named oracledb/oradata@tuesday
root@solaris11:~# zfs snapshot -r oracledb/oradata@tuesday
Note that the company file will be included in the Tuesday snapshot but not in the Monday snapshot.
Step 10: Attempt to roll back the oracledb/oradata snapshot by using the oracledb/oradata@Monday snapshot. What happens?
root@solaris11:~# zfs rollback oracledb/oradata@monday
cannot rollback to ‘oracledb/oradata@monday’: more recent snapshots exist
use ‘-r’ to force deletion of the following snapshots: oracledb/oradata@tuesday
Notice that more recent snapshots (oradata@tuesday) exist; therefore, you cannot roll back to an earlier snapshot unless you use the -r option that deletes the more recent snapshots till the oradata@monday snapshot becomes the most recent. Do not roll back yet.
Question: If the oracledb/oradata snapshot is rolled back to the Monday snapshot, what data will be lost?
Answer: The file named /oradata/cust/company will be lost.
Step 11: Delete the file named /oradata/cust/company.
root@solaris11:~# rm /oradata/cust/company
Note: Remove the customer company to see if you can recover it.
Step 12: List the descendant oracledb file systems. Roll back the oracledb/oradata/cust@tuesday snapshot.
root@solaris11:~# zfs rollback oracledb/oradata/cust@tuesday
Now you rolled back (recovered) to the cust@tuesday backup. Does it include the company customer file? You will find out in the next step.
Step 13: Confirm that /oradata/cust/company is restored.
root@solaris11:~# ls /oradata/cust/company
/oradata/cust/company
Yes, your customer company is restored. Because the Tuesday backup was taken after you created this customer, it was in your cust@tuesday backup.
Step 14: Create a directory named /backup.
root@solaris11:~# mkdir /backup
Note: Create a separate directory to store your Monday backups. Your company wants to save these backups offsite because this is the end of the quarter for your company
Step 15: Use the zfs send command to recursively send the oracledb/oradata@monday snapshot. Save the copy in a file named /backup/oracledb.oradata.monday.
root@solaris11:~# zfs send -Rv oracledb/oradata@monday > /backup/oracledb.oradata.monday
sending from @ to oracledb/oradata@monday
sending from @ to oracledb/oradata/om@monday
sending from @ to oracledb/oradata/mktg@monday
sending from @ to oracledb/oradata/cust@monday
Note: Now you have only one /backup directory, which contains all the Monday backups. This directory can be archived on tape or sent to another machine on the network. See how simple the command is. Use -R to send all the snapshots in oradata@monday. The backed up snapshot naming convention has changed slightly to enable differentiation between the snapshots and the backed up data.
Step 16: Use the ls-lh command to list the size of the file in /backup. Verify that it approximately matches the size of the space used by the oracledb/oradata file systems.
Yes. It does match approximately.
Step 17: Use the zfs send command to send the oracledb/oradata/cust@monday snapshot to the /backup directory. Then list the size of the snapshot stream.
root@solaris11:~# zfs send oracledb/oradata/cust@monday > /backup/oracledb.oradata.cust.monday
Note: As you can see, the Monday snapshot for the cust file system and its Monday backup file consume approximately the same amount of storage space.
Step 18: Destroy the oracledb/oradata/cust file system. Confirm whether it is deleted.
root@solaris11:~# zfs destroy -r oracledb/oradata/cust
root@solaris11:~# zfs list /oradata/cust
/oradata/cust: No such file or directory
Now you have destroyed the cust file system so that you can test the recover (receive) function.
Step 19: Use the zfs receive command to re-create the oracledb/oradata/cust file system. Confirm the file system recovery by using the zfs list command.
root@solaris11:~# zfs receive oracledb/oradata/cust < /backup/oracledb.oradata.cust.monday
This shows you that the recovery was successful.
Step 20: Use the zfs list command to confirm the recovery of the full /oradata/cust file system.
Now you have learned in detailed about using zfssnapshots for backup and recovery in Oracle Solaris.
If you find this post is useful/helpful, please follow, like and share. Thank you for visiting my blog!!!
Leave a Reply