Periodic Snapshot Tasks

From Freenas
Jump to: navigation, search

A periodic snapshot task allows you to schedule the creation of read-only versions of ZFS volumes and datasets at a given point in time. Snapshots can be created quickly and, if little data changes, new snapshots take up very little space. For example, a snapshot where no files have changed takes 0 MB of storage, but as you make changes to files, the snapshot size changes to reflect the size of the changes.

Snapshots provide a clever way of keeping a history of files, should you need to recover an older copy or even a deleted file. For this reason, many administrators take snapshots often (e.g. every 15 minutes), store them for a period of time (e.g. for a month), and store them on another system (e.g. using Replication Tasks). Such a strategy allows the administrator to roll the system back to a specific time or, if there is a catastrophic loss, an off-site snapshot can restore the system up to the last snapshot interval.

Before you can create a snapshot, you need to have an existing ZFS volume. These can be created in Storage → Volumes → ZFS Volume Manager.

Creating a Periodic Snapshot Task

To create a periodic snapshot task, click Storage → Periodic Snapshot Tasks → Add Periodic Snapshot which will open the screen shown in Figure 6.1a.

NOTE: if you just need a one-time snapshot, instead use Storage → Volumes → View Volumes and click the Create Snapshot button for the volume or dataset that you wish to snapshot.

Figure 6.1a: Creating a ZFS Periodic Snapshot


Table 6.1a summarizes the fields in this screen:

Table 6.1a: Options When Creating a Periodic Snapshot

Setting Value Description
Enabled checkbox uncheck to disable the scheduled replication task without deleting it
Volume / Dataset drop down menu select an existing ZFS volume, dataset, or zvol; if you select a volume, separate snapshots will also be created for each of its datasets
Recursive checkbox select this box to take separate snapshots of the volume/dataset and each of its child datasets; if unchecked, only one snapshot is taken of the volume/dataset specified in Filesystem / Volume
Lifetime integer and drop down menu how long to keep the snapshot on this system; if the snapshot is replicated, it is not removed from the receiving system when the lifetime expires
Begin drop down menu do not create snapshots before this time of day
End drop down menu do not create snapshots after this time of day
Interval drop down menu how often to take snapshot between Begin and End times
Weekday checkboxes which days of the week to take snapshots

If the Recursive box is checked, you do not need to create snapshots for every dataset individually as they are included in the snapshot. The downside is that there is no way to exclude certain datasets from being included in a recursive snapshot.

Once you click the OK button, a snapshot will be taken and this task will be repeated according to your settings.

Managing Periodic Snapshot Tasks

After creating a periodic snapshot task, an entry for the snapshot task will be added to View Periodic Snapshot Tasks, as seen in the example in Figure 6.1b. Click an entry to access its Modify and Delete buttons.

Figure 6.1b: View Periodic Snapshot Tasks


If you click the ZFS Snapshots tab (above the Add Periodic Snapshot button), you can review the listing of available snapshots. An example is shown in Figure 6.1c.

NOTE: if snapshots do not appear, check that the current time does not conflict with the begin, end, and interval settings. If the snapshot was attempted but failed, an entry will be added to /var/log/messages. This log file can be viewed in Shell.

Figure 6.1c: Viewing Available Snapshots


The most recent snapshot for a volume or dataset will be listed last and will have 3 icons. The icons associated with a snapshot allow you to:

Clone Snapshot: will prompt for the name of the clone to create. The clone will be a writable copy of the snapshot. Since a clone is really a dataset which can be mounted, the clone will appear in the Active Volumes tab, instead of the Periodic Snapshots tab, and will have the word clone in its name.

Destroy Snapshot: a pop-up message will ask you to confirm this action. Child clones must be destroyed before their parent snapshot can be destroyed. While creating a snapshot is instantaneous, deleting a snapshot can be I/O intensive and can take a long time, especially when deduplication is enabled. In order to delete a block in a snapshot, ZFS has to walk all the allocated blocks to see if that block is used anywhere else; if it is not, it can be freed.

Rollback Snapshot: a pop-up message will ask if you are sure that you want to rollback to this snapshot state. If you click Yes, any files that have changed since the snapshot was taken will be reverted back to their state at the time of the snapshot.

NOTE: rollback is a potentially dangerous operation that will cause existing replication tasks to fail as the replication system refers to the existing snapshot when performing an incremental backup. If you do need to restore the data within a snapshot, the recommended steps are:

1. Clone the desired snapshot.

2. Share the clone with the share type or service running on the FreeNAS® system.

3. Once users have recovered the needed data, destroy the clone in the Active Volumes tab.

This approach will never destroy any on-disk data and has no impact on replication.

Periodic snapshots can be configured to appear as shadow copies in newer versions of Windows Explorer. Users can access the files in the shadow copy using Explorer without requiring any interaction with the FreeNAS® graphical administrative interface.

The ZFS Snapshots screen allows you to create filters to view snapshots by selected criteria. To create a filter, click the Define filter icon (near the text “No filter applied”). When creating a filter:

  • select the column or leave the default of Any Column.
  • select the condition. Possible conditions are: contains (default), is, starts with, ends with, does not contain, is not, does not start with, does not end with, and is empty.
  • input a value that meets your view criteria.
  • click the Filter button to save your filter and exit the define filter screen. Alternately, click the + button to add another filter.

If you create multiple filters, select the filter you wish to use before leaving the define filter screen. Once a filter is selected, the “No filter applied” text will change to “Clear filter”. If you click “Clear filter”, a pop-up message will indicate that this will remove the filter and all available snapshots will be listed.

Recovering Missing or Deleted Files Using Snapshots

If a user is missing or has accidentally deleted files, you can use the "Clone Snapshot" feature to create a temporary share that the user can use to retrieve the missing files. First, find out the last time that the user had a known available file and create a filter to search through snapshots.

 Filter 1 -> Volume/Dataset, contains, [Name_of_dataset]
 Filter 2 -> Snapshot Name, contains, [Date_and_time]; entered exactly as in the filename, ie. 20130412.0900 for 2013, Apr 12, 9:00am

You can use just the date in your filter or add to your filter as needed to suit your needs.

When you find the snapshot your are going to use, click the create Clone Icon on the right side of the table to create the Cloned Snapshot as described above in the previous section. If you use the path under the users Share, it will be immediately available to him/her under their Share with the name you have given it. The default name is Cloned_[snapshot_name] unless you change it.

After your user has claimed and copied the files they need, have them notify you when they are done. When it comes time to destroy the clone, go through the menu and select Storage -> Active Volumes and find the Clone Name you have created and click the Destroy Dataset Icon for the Clone.

Personal tools