In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use Btrfs snapshots for incremental backup", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use Btrfs snapshots for incremental backup" this article.
Use snapshots for backup
The snapshot resides on the same disk as the subvolume. You can browse it like a normal directory and restore a copy of the file as it was when the snapshot was taken. By the way, generating a snapshot on the same disk of a snapshot subvolume is not an ideal backup strategy: if the hard disk is broken, the snapshot will be lost. An interesting feature of snapshots is the ability to send snapshots to another location. Snapshots can be sent to an external hard disk or to a remote system via SSH (the destination file system also needs to be formatted as Btrfs). To do this, use the commands btrfs send and btrfs receive.
Generate a snapshot
To use the btrfs send and btrfs receive commands, it is important to create a snapshot as read-only, and the snapshot is writable by default.
The following command takes a snapshot of the / home subvolume. Please note that the-r flag stands for read-only.
Sudo btrfs subvolume snapshot-r / home / .snapshots/home-day1
The name of the snapshot can be the current date instead of day1, such as home-$ (date +% Y%m%d). The snapshot looks like a normal subdirectory. You can put them anywhere you like. The directory / .snapshots may be a good choice to keep them clean and avoid confusion.
Editor's note: snapshots do not take recursive snapshots of themselves. If you create a snapshot of a subvolume, each subvolume or snapshot contained in the subvolume will be mapped to an empty directory with the same name in the snapshot.
Use btrfs send for backup
In this example, the target Btrfs volume on the U disk is mounted as / run/media/user/mydisk/bk. The command to send a snapshot to the target volume is:
Sudo btrfs send / .snapshots/home-day1 | sudo btrfs receive / run/media/user/mydisk/bk
This is called initial startup, and it is equivalent to a full backup. This task takes some time, depending on the size of the / home directory. Obviously, subsequent incremental transmissions only take a shorter time.
Incremental backup
Another useful feature of snapshots is the ability to perform sending tasks incrementally. Let's generate another snapshot.
Sudo btrfs subvolume snapshot-r / home / .snapshots/home-day2
In order to perform the incremental send task, you need to specify the previous snapshot as the basis, and this snapshot must exist in the source and destination files. Note the-p option.
Sudo btrfs send-p / .snapshot/home-day1 / .snapshot/home-day2 | sudo btrfs receive / run/media/user/mydisk/bk
Do it again (a day later):
Sudo btrfs subvolume snapshot-r / home / .snapshots/home-day3 sudo btrfs send-p / .snapshot/home-day2 / .snapshot/home-day3 | sudo btrfs receive / run/media/user/mydisk/bk cleanup
After the operation is complete, you can keep the snapshot. But if you perform these operations every day, you may end up with a lot of snapshots. This can lead to confusion and may use a lot of space on your disk. Therefore, if you think you no longer need some snapshots, deleting them is a good suggestion.
Remember, in order to perform an incremental send, you need at least one last snapshot. This snapshot must exist in both the source and target files.
Sudo btrfs subvolume delete /. Snapshot/home-day1sudo btrfs subvolume delete /. Snapshot/home-day2sudo btrfs subvolume delete / run/media/user/mydisk/bk/home-day1sudo btrfs subvolume delete / run/media/user/mydisk/bk/home-day2
Note: the snapshot of day 3 is saved in the source and destination files. In this way, tomorrow (day 4), you can execute the new incremental btrfs send.
The final suggestion is that if the U disk has a lot of space, consider keeping multiple snapshots on the target disk and only the last snapshot on the source disk.
The above is all the contents of the article "how to use Btrfs Snapshots for incremental backups". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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: 260
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.