The following procedures can be used to back up files in zones. Remember to also back up the zones' configuration files.
You can perform full or incremental backups using the ufsdump command. This procedure backs up the zone /export/my-zone to /backup/my-zone.ufsdump, where my-zone is replaced with the name of a zone on your system. You might want to have a separate file system, for example, a file system mounted on /backup, to hold the backups.
Become superuser, or assume the Primary Administrator role.
To create the role and assign the role to a user, see Using the Solaris Management Tools With RBAC (Task Map) in System Administration Guide: Basic Administration.
(Optional) Shut down the zone to put the zone in a quiescent state and to avoid creating backups of shared file systems.
global# zlogin -S my-zone init 0 |
Check the zone's status.
global# zoneadm list -cv |
You will see a display similar to the following:
ID NAME STATUS PATH BRAND IP 0 global running / native shared - my-zone installed /export/home/my-zone native shared |
Perform the backup.
global# ufsdump 0f /backup/my-zone.ufsdump /export/my-zone |
You will see a display similar to the following:
DUMP: Date of this level 0 dump: Wed Aug 10 16:13:52 2005 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rdsk/c0t0d0s0 (bird:/) to /backup/my-zone.ufsdump. DUMP: Mapping (Pass I) [regular files] DUMP: Mapping (Pass II) [directories] DUMP: Writing 63 Kilobyte records DUMP: Estimated 363468 blocks (174.47MB). DUMP: Dumping (Pass III) [directories] DUMP: Dumping (Pass IV) [regular files] DUMP: 369934 blocks (180.63MB) on 1 volume at 432 KB/sec DUMP: DUMP IS DONE |
Boot the zone.
global# zoneadm -z my-zone boot |
This approach uses the fssnap command, which creates a temporary image of a file system intended for backup operations.
This method can be used to provide a clean, consistent backup of the zone files only, and it can be executed while zones are running. However, it is a good idea to suspend or checkpoint active applications that are updating files when the snapshot is created. An application updating files when the snapshot is created might leave these files in an internally inconsistent, truncated, or otherwise unusable state.
In the example procedure below, note the following:
There is a zone named my-zone under /export/home.
/export/home is a separate file system.
The destination backup is /backup/my-zone.ufsdump. You must create the directory backup under /.
Become superuser, or assume the Primary Administrator role.
To create the role and assign the role to a user, see Using the Solaris Management Tools With RBAC (Task Map) in System Administration Guide: Basic Administration.
Create the snapshot.
global# fssnap -o bs=/export /export/home |
You will see a display similar to the following:
dev/fssnap/0 |
Mount the snapshot.
global# mount -o ro /dev/fssnap/0 /mnt |
Back up my-zone from the snapshot.
global# ufsdump 0f /backup/my-zone.ufsdump /mnt/my-zone |
You will see a display similar to the following:
DUMP: Date of this level 0 dump: Thu Oct 06 15:13:07 2005 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping /dev/rfssnap/0 (pc2:/mnt) to /backup/my-zone.ufsdump. DUMP: Mapping (Pass I) [regular files] DUMP: Mapping (Pass II) [directories] DUMP: Writing 32 Kilobyte records DUMP: Estimated 176028 blocks (85.95MB). DUMP: Dumping (Pass III) [directories] DUMP: Dumping (Pass IV) [regular files] DUMP: 175614 blocks (85.75MB) on 1 volume at 2731 KB/sec DUMP: DUMP IS DONE |
Unmount the snapshot.
global# umount /mnt |
Delete the snapshot.
global# fssnap -d /dev/fssnap/0 |
Note that the snapshot is also removed from the system when the system is rebooted.
Become superuser, or assume the Primary Administrator role.
To create the role and assign the role to a user, see Using the Solaris Management Tools With RBAC (Task Map) in System Administration Guide: Basic Administration.
Change directories to the root directory.
global# cd / |
Back up my-zone files that are not loopback mounted to /backup/my-zone.cpio.
global# find export/my-zone -fstype lofs -prune -o -local | cpio -oc -O /backup/my-zone.cpio type as one line |
Verify the results.
global# ls -l backup/my-zone.cpio |
You will see a display similar to the following:
-rwxr-xr-x 1 root root 99680256 Aug 10 16:13 backup/my-zone.cpio |
You should create backup files of your non-global zone configurations. You can use the backups to recreate the zones later, if necessary. Create the copy of the zone's configuration after you have logged in to the zone for the first time and have responded to the sysidtool questions. This procedure uses a zone named my-zone and a backup file named my-zone.config to illustrate the process.
Become superuser, or assume the Primary Administrator role.
To create the role and assign the role to a user, see Using the Solaris Management Tools With RBAC (Task Map) in System Administration Guide: Basic Administration.
Print the configuration for the zone my-zone to a file named my-zone.config.
global# zonecfg -z my-zone export > my-zone.config |