Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of fast online backup and recovery with Snapshot command

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

What is the method of Snapshot command to quickly carry out online backup and recovery? in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Why use Snapshot

Why use snapshot instead of the tar or copy utility? When using snapshot, the file system is frozen, ensuring that you can get a complete copy, and avoiding problems such as "open files,"running processes," or "files not found." In addition, there is usually no need to close the application, although I usually put the application into a static state before taking a snapshot; then cancel the static state.

You can have up to 15 consecutive external snapshots of the JFS2 file system. When upgrading an application in a test environment, it is common practice to take a snapshot each time you update the environment contained in the file system.

Doing an online backup of JFS2 is a very good thing, but you also need to be able to recover content in the event of an error. Using the rollback utility, you can roll back an external snapshot to the point where the snapshot was taken by specifying the device on which the snapshot resides. There is nothing better than this function. To roll back the backup snapshot, use the restore command.

Personal first item

Which method you use to create a snapshot depends on which method you like best. So let's introduce the various snapshot types:

External snapshot

Create on an existing JFS2 file system

Its storage space is located on different logical volumes.

Can be mounted as a separate file system

There is a read-only data area

Backup snapshot

Mainly an interface for snapshot commands

Perform all snapshot work

Save the resulting file system backup on an archived file or tape

If a snapshot runs out of space, all snapshots of the file system become invalid-in other words, unavailable. In my own work, I prefer external snapshots, mainly because they can be mounted as needed for better viewing.

External snapshot

The file system is named / opt/portal. Its size is 512m and the data file is more than 281m.

# lsfs | grep-w portal / dev/fslv02-/ opt/portal jfs2 1048576 rw yes no # df-m | grep portal / dev/fslv02 512.00 231.60 55% 7.1% / opt/portal # pwd / opt/portal # ls app_be app_fr app_nl lost+found

To create an external snapshot, as a rule, I create the snapshot with about half the size of the original file system. The recommended snapshot size for the IBM document is 10% to 15% of the source file system. However, I like to provide plenty of space for snapshots, and it's also good from a security point of view. In this case, 50% of the space is equivalent to 250m. The common format for creating snapshots is:

Snapshot-o snapfrom=-o size=

Now create an external snapshot:

# snapshot-o snapfrom=/opt/portal-o size=250M Snapshot for file system / opt/portal created on / dev/fslv04

Automatically creates a logical volume to save the snapshot. To confirm that snapshots have been created, use the snapshot command to query snapshots of related file systems, such as:

# snapshot-Q / opt/portal Snapshots for / opt/portal Current Location 512-blocks Free Time * / dev/fslv04 524288 523520 Sun Nov 4 10:57:46 GMT 2012

Now I can mount the snapshot and view the replicated data, but first I need to create the directory needed to mount the snapshot:

# mkdir / snap_portal # mount-v jfs2-o snapshot / dev/fslv04 / snap_portal # df-m | grep portal / dev/fslv02 512.00 231.60 55% 7.1% / opt/portal / dev/fslv04 256.00 255.62 1%-/ snap_portal

Now, I can use the cd command to enter the snapshot (/ snap_portal) folder and view the copied files; note that the file system is read-only and data writing is not allowed:

# cd / snap_portal # ls app_be app_fr app_nl lost+found # ls > file1

File1:The file system has read permission only.

Now I can further back up the snapshot file system to tape or SAN. Assuming that I have performed some data maintenance operations on / opt/portal and deleted a file by mistake, then simply copy the deleted file from the mounted snapshot to / opt/portal. But now let's create another snapshot of / opt/portal:

# snapshot-o snapfrom=/opt/portal-o size=250M Snapshot for file system / opt/portal created on / dev/fslv05

Similar to the previous, query a snapshot of / opt/portal:

# snapshot-Q / opt/portal Snapshots for / opt/portal Current Location 512-blocks Free Time / dev/fslv04 524288 523520 Sun Nov 4 10:57:46 GMT 2012 * / dev/fslv05 524288 523520 Sun Nov 4 11:00:53 GMT 2012

In the above output, * represents a snapshot of *. If you no longer need to use a snapshot in the future, you can use the snapshot command to delete it. The common format for deleting snapshots is:

Snapshot-d

For example, to delete a fslv04, I can use the following command:

# snapshot-d / dev/fslv04

Suppose you need to restore the entire file system because some updates cause errors on / opt/portal. I can choose which snapshot to roll back. For me, this is one of the main selling points of snapshots. If multiple snapshots have been taken, there are multiple recovery points. In our demonstration, I will roll back the snapshot I took at 10:57, / dev/fslv04. First I will unmount all snapshots (if they have been mounted), then unmount / opt/portal, and then execute the rollback command. In this example, the time is 10:57 at Sunday, Nov. 4. The common format of the rollback command is:

Rollback-v

"when you roll back, all snapshots of the file system are deleted." To roll back and restore to the original file system / opt/portal, I can use:

# umount / opt/portal # rollback-v / opt/portal / dev/fslv04 Restoring block 1 Restoring block 1000 Restoring block 2000... Restoring block 12000 Total blocks restored = 12809 rmlv:Logical volume fslv04 is removed. Rmlv:Logical volume fslv05 is removed. Rollback complete

To confirm that no snapshots are left, list snapshots:

# snapshot-Q / opt/portal / opt/portal has no snapshots.

Now I can mount / opt/portal again and have restored the original contents of the file system!

# mount / opt/portal

Backup snapshot

Backsnap does most of the work for you in the background. It creates logical volumes to hold snapshots and then copies the contents to an archive file or to a tape device. You can then use the restore command to restore the backed up files. Create a backup snapshot using the / opt/portal file system and let's see how it works. The common format of the backsnap command is:

Backsnap-m-s size-f

In this example, I will use the following values: / backsnap_portal is the temporary mount point; 250m is the size; / opt/dump/backup_portal is the archived document; / opt/portal is the source file system.

# backsnap-m / backsnap_portal-s size=250M-f / opt/dump/backup_portal / opt/portal Snapshot for file system / opt/portal created on / dev/fslv05 backup:Backing up / dev/rfslv05 to / opt/dump/backup_portal. Backup:There are an estimated 286768 1k blocks. Backup:There are 287321 1k blocks on 1 volumes. Backup:The backup is complete.

Now we have an archive file, backup_portal, which is located in the directory / opt/dump. Look at the size of the archive. It is 280m:

# du-ms / opt/dump/backup_portal 280.56 backup_portal

To verify that the files are in the archive, I can use the restore command to list each file:

# restore-tvf / opt/dump/backup_portal

To restore the file app_be to / opt/portal from the archive file, I can use:

# cd / opt/portal # restore-xvf / opt/dump/backup_portal app_be. Extracting directories from media. Initializing the symbol table. Extracting requested files.. Specify the next volume number:1 Extracting file. / app_be.

To take a snapshot and put the file on tape rmt0, while using the properties of the previous backup snapshot, I can use:

# backsnap-m / backsnap_portal-s size=250M-f / dev/rmt0 / opt/portal

If you have taken a snapshot and sent the contents to the tape, you can use the restore command to list the tapes, such as:

# restore-tvf / dev/rmt0

You can also use the following command to list snapshots that have been taken:

# snapshot-Q / opt/portal Snapshots for / opt/portal Current Location 512-blocks Free Time * / dev/fslv08 524288 522496 Sun Nov 4 11:30:25 GMT 2012

If you decide to delete a snapshot, the archived files that have been sent to the tape will not change, unlike deleting an external snapshot. That is, unless you previously sent other backups of the snapshot to some media.

Pay attention to space

As a system administrator, I believe that snapshots are an excellent way to do online backups and can restore content if an error occurs. But remember, be sure to pay attention to the space used in the file system; you don't want to end up with an invalid snapshot because you don't have enough space.

This is the answer to the question about the method of Snapshot command for fast online backup and recovery. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report