Sun Microsystems
Products & Services
 
Support & Training
 
 

Previous Previous     Contents     Next Next

5.6.1 Setting Quotas

ZFS quotas can be set and displayed with the zfs set and zfs get commands. The following example sets a quota of 10 Gbytes on tank/home/bonwick.

# zfs set quota=10G tank/home/bonwick
# zfs get quota tank/home/bonwick
NAME              PROPERTY      VALUE                      SOURCE
tank/home/bonwick quota         10.0G                      local

ZFS quotas also impact the output of the zfs list and df commands.

# zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
tank/home             16.5K  33.5G  8.50K  /export/home
tank/home/bonwick     15.0K  10.0G  8.50K  /export/home/bonwick
tank/home/bonwick/ws  6.50K  10.0G  8.50K  /export/home/bonwick/ws
# df -h /export/home/bonwick
Filesystem             size   used  avail capacity  Mounted on
tank/home/bonwick       10G     8K    10G     1%    /export/home/bonwick

Note that although tank/home has 33.5 Gbytes of space available, tank/home/bonwick and tamk/home/bonwick/ws only have 10 Gbytes of space available, due to the quota on tank/home/bonwick.

It is not possible to set a quota to an amount less than is currently being used by a dataset.

# zfs set quota=10K tank/home/bonwick
cannot set quota for 'tank/home/bonwick': size is less than current used or 
reserved space

5.6.2 Setting Reservations

A ZFS reservation is an allocation of space from the pool that is guaranteed to be available to a dataset. As such, it is not possible to reserve space for a dataset if that space is not currently available in the pool. The total of all outstanding unconsumed reservations cannot exceed the amount of unused space in the pool. ZFS reservations can be set and displayed with the zfs set and zfs get commands.

# zfs set reservation=5G tank/home/moore
# zfs get reservation tank/home/moore
NAME             PROPERTY      VALUE                      SOURCE
tank/home/moore  reservation   5.00G                      local

ZFS reservations can influence the output of the zfs list command.

# zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
tank/home             5.00G  33.5G  8.50K  /export/home
tank/home/moore       15.0K  10.0G  8.50K  /export/home/moore

Note that tank/home shows that it is using 5 Gbytes of space, although the total space referred to by tank/home and its descendants is much less than 5 Gbytes. The used space reflects the space reserved for tank/home/moore. Reservations are accounted for in the used space of the parent dataset and do count against its quota and/or reservation.

# zfs set quota=5G pool/filesystem
# zfs set reservation=10G pool/filesysetm/user1
cannot set reservation for 'pool/filesystem/user1': size is greater than 
available space

A dataset can use more space than its reservation, so long as there is space available in the pool that is unreserved and it is below its quota. A dataset cannot consume space that has been reserved for another dataset.

Reservations are not cumulative. That is, a second invocation of zfs set to set a reservation does not add its reservation to the existing one, rather it replaces it.

# zfs set reservation=10G tank/home/moore
# zfs set reservation=5G tank/home/moore
# zfs get reservation tank/home/moore
NAME             PROPERTY      VALUE                      SOURCE
tank/home/moore  reservation   5.00G                      local

5.7 Backing Up and Restoring ZFS Data

You can backup and restore ZFS filesystem snapshots and the original filesystems by using the zfs backup and zfs restore commands.

The following ZFS backup and restore solutions are provided:

  • Creating ZFS snapshots and rolling back snapshots, if necessary.

  • Creating full and incremental backups of ZFS snapshots and restoring the snapshots, if necessary.

  • Remotely replicating ZFS file systems by backing up and restoring a ZFS snapshot and file system.

Consider the following when choosing a ZFS backup solution:

  • File system snapshots and rolling back snapshots - Use the zfs snapshot and zfs rollback commands if you want to easily create a copy of a file system and revert back to a previous file system version, if necessary. For example, if you want to restore a file or files from a previous version of a file system.

    For more information about creating and rolling back to a snapshot, see 6.1 ZFS Snapshots.

  • Backing up file system snapshots - Use the zfs backup and zfs restore commands to back up and restore a ZFS file system snapshot. You can backup incremental changes between snapshots, but you cannot restore files individually. You must restore the entire file system snapshot.

  • Remote replication - Use the zfs backup and zfs restore commands when you want to copy a file system from one system to another. This process is different from a traditional volume management product that might mirror devices across a WAN. There is no special configuration or hardware required. The advantage of replicating a ZFS file system is that you can recreate a file system on a storage pool on another system, and specify different levels of configuration for the newly created pool, such as RAID-Z, but with identical file system data.

5.7.1 Backing Up ZFS Filesystems With Other Backup Products

In addition to the zfs backup and zfs restore commands, you can also use backup utilities, such as the tar and cpio commands, to back up ZFS files. All of these utilities backup and restore ZFS file attributes and ACLs. Check the appropriate options for both the tar and cpio commands.

Keep the following issues in mind when using other backup products to back up ZFS files:

  • Veritas Backup software - You can use this product to back up ZFS files, but it silently ignores ACLs on ZFS files. (CR 6352899)

  • Legato NetWorker™ software - Currently, this product cannot be used to backup ZFS files. (CR 6349974)

5.7.2 Backing Up a ZFS Snapshot

The simplest form of the zfs backup command is to backup a snapshot. For example:

# zfs backup tank/dana@111505 > /dev/rmt/0

You can create an incremental backup by using the zfs backup -i option. For example:

# zfs backup -i tank/dana@111505 tank/dana@now > /dev/rmt/0

Note that the first argument is the earlier snapshot and the second argument is the later snapshot.

If you need to store many backups, you might consider compressing a ZFS backup with gzip. For example:

# zfs backup pool/fs@snap | gzip > backupfile.gz

5.7.3 Restoring a ZFS Snapshot

When you restore a file system snapshot, the file system is restored as well. The file system is unmounted and is inaccessible while it is being restored. In addition, the original file system to be restored must not exist while it is being restored. If there is a conflicting filesystem name, zfs rename can be used to rename it. For example:

# zfs backup tank/gozer@111105 > /dev/rmt/0

.
.
.
# zfs restore tank/gozer2@today < /dev/rmt/0
# zfs rename tank/gozer tank/gozer.old
# zfs rename tank/gozer2 tank/gozer

When you restore an incremental file system snapshot, the most recent snapshot must first be rolled back. In addition, the destination file system must exist. To restore the previous incremental backup for tank/dana, for example:

# zfs rollback tank/dana@111505
cannot rollback to 'tank/dana@111505': more recent snapshots exist
use '-r' to force deletion of the following snapshots:
tank/dana@now
# zfs rollback -r tank/dana@111505
# zfs restore tank/dana < /dev/rmt/0

During the incremental restore process, the filesystem is unmounted and cannot be accessed.

Previous Previous     Contents     Next Next