Backing Up a Solaris File System Dynamically

Joseph GanSystem Admin
CERTIFIED EXPERT
Published:
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility in the Solaris OS can do an online backup, it will fail if the file system can't be write-locked.
Solaris Volume Manager software, on the other hand, can be used as a "bridge" to transfer the data of a file system across to another partition on the fly. Then, the data can be backed up at any time.
Here's an example using the file system /test:
# df -k /test
                      Filesystem                  kbytes    used   avail capacity  Mounted on
                      /dev/dsk/c0t2d1s3    50700783 39746386 10530839    80%    /test

Open in new window

First, you'll create a metadevice named d101 on the /test file system when it's mounted.
# metainit -f d101 1 1 c0t2d1s3

Open in new window

Now it's time to initialize a one-way mirror metadevice named, for example, d100, with the submirror d101 that you've already created:
# metainit d100 -m d101
                      # metastat d100
                      d100: Mirror
                          Submirror 0: d101
                            State: Okay
                          Pass: 1
                          Read option: roundrobin (default)
                          Write option: parallel (default)
                          Size: 102961152 blocks
                      
                      d101: Submirror of d100
                          State: Okay
                          Size: 102961152 blocks
                          Stripe 0:
                              Device              Start Block  Dbase State        Hot Spare
                              c0t2d1s3                   0     No    Okay

Open in new window

And you'll create another metadevice d102 on the new location c0t2d1s7. The size of the new partition should be the same as d101:
 
# metainit d102 1 1 c0t2d1s7
                      d102: Concat/Stripe is setup
                      
                      # metastat d102
                      d102: Concat/Stripe
                          Size: 102975488 blocks
                          Stripe 0:
                              Device              Start Block  Dbase
                              c0t2d1s7                   0     No

Open in new window

When you add the metadevice d102 as the second submirror to d100, resynchronization will automatically take place:
# metattach d100 d102

Open in new window

After the resynchronization has completed successfully, you should get the following two-way mirrors that indicate that the file system is ready to be backed up:
# metastat d100
                      d100: Mirror
                          Submirror 0: d101
                            State: Okay
                          Submirror 1: d102
                            State: Okay
                          Pass: 1
                          Read option: roundrobin (default)
                          Write option: parallel (default)
                          Size: 102961152 blocks
                      
                      d101: Submirror of d100
                          State: Okay
                          Size: 102961152 blocks
                          Stripe 0:
                              Device              Start Block  Dbase State        Hot Spare
                              c0t2d1s3                   0     No    Okay
                      
                      d102: Submirror of d100
                          State: Okay
                          Size: 102961152 blocks
                          Stripe 0:
                              Device              Start Block  Dbase State        Hot Spare
                              c0t2d1s7                   0     No    Okay

Open in new window

You can schedule your file system backup to run any time you wish. Before you start, though, you have to detach the second metadevice d102 or bring it offline. To detach it, use:
# metadetach d100 d102 
                      Or, to bring it offline, use: 
                      # metaoffline d102

Open in new window

Remember, you're only backing up the data on the partition c0t2d1s7, which includes all the data at the point of detach.
After the backup is done, you can clean up all the metadevices, or you could leave them for later use. Before the next backup, you'll have to run either of the following commands:
# metattach d100 d102  
                      or
                      # metaonline d102

Open in new window

You'll need to wait until the resynchronization is done before the next backup.
The difference between the two preceding options is that the first option will take longer to sync after the metattach command than the second one. But for the second option, the file system will be read-only until you bring it online by using the metaonline command.
For file systems that need to be backed up consistently at the same point, all you have to do is detach all of the second metadevices at the same time. Then they can be backed up one by one.
0
3,584 Views
Joseph GanSystem Admin
CERTIFIED EXPERT

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.