# # #btrfs-snapper Application
----------
# # #环境介绍
The > Btrfs file system is a transition from EXT4 to the "Next Generation File system". The file system has high extensibility (b-tree), data Consistency (COW), multi-device management (Snapshot, clone), and other features (deferred distribution, small file optimization, indexing).
> Therefore the file system requires a higher version of the Linux system, which is currently supported by CentOS 7, Ubuntu14.10, SUSE13.2, and Fedora17 (kernel 3.*).
> can be used to determine whether support is supported by the Mkfs.btrfs command.
######
> Snapper is a snapshot management tool based on Btrfs and Ext4 file system (mainly Btrfs), using Snapper for easy snapshot creation, viewing, modification, deletion, comparison, rollback recovery, and even pre-and post-snapshot creation for an instruction.
######
> This test system is CentOS 7 kernel version 3.10.0. Btrfs version is 3.16.2
# # #安装
**btrfs**
-Create a new system
> Create a new CentOS 7 system, modify the format when creating the disk, because the/boot directory can only be in the XFS format can not be modified, so only the root directory/created as Btrfs format, after the installation of the system, directly into the Btrfs file system
-Original System conversion format
> Btrfs can be converted directly by Ext2, 3, 4, using the Btrfs-convert command, to convert the corresponding disk, it is important to note that this situation cannot be converted to the root directory (because it has been used).
-Add Btrfs partition locally
> Using the DD tool
>: Create an empty file of size 100M
> \# dd if=/dev/vda2 of=/tmp/file bs=1024 count=100000
> Formatting with Btrfs
> \# mkfs.btrfs/tmp/file
> Mount as Partition
> \# mkdir newdisk
> \# mount-o loop/tmp/file/mnt/newdisk
> You can now view the newly added partition by Df-h.
> If you want to automatically mount the boot, you can join the/etc/fstab
> \# Vi/etc/fstab
> Add/tmp/file/newdisk btrfs defaults 1 2
The test uses the first method.
**snapper Installation * *
> Install directly with yum
> \# yum-y Install Snapper
> can see that it relies on snapper-libs, Boost-system, Boost-thread
----------
# # #使用
Only the use of snapper is given here, and the following commands are tested and available
**snapper's Related documents * *
>/etc/sysconfig/snapper
> Global configuration file.
The directory that contains the configuration file.
/etc/snapper/config-templates
The directory that contains the profile template.
/etc/snapper/filters
The directory that contains the filter rule files.
/var/log/snapper.log
Log files. The error report is included in this file.
* * Configuration * *
>snapper List-configs
> List all configurations (that is, backup scenarios)
Configuration file in/etc/snapper/configs/allfs
Snapper Delete-config Allfs
Delete the corresponding snapshot configuration
Snapper-c Allfs Get-config
List parameters for Allfs configuration
Snapper-c allfs set-config ' Timeline_create=no '
Set the Timeline_create parameter value in the Allfs configuration to No
* * Configuration parameters and meaning * *
> subvolume= "/" corresponding backup directory
Fstype= "Btrfs" file type
Allow_users= "" Allows users to use this configuration
Allow_groups= "" Allows groups to use this configuration
Background_comparison= "Yes" creates a background comparison before and after the snapshot is created
Number_cleanup= "yes" to run daily number cleanup
Number_min_age= "1800" pre-cleanup snapshot minimum lifetime (s)
number_limit= "50" maximum number of snapshots
Timeline_create= "No" creates a snapshot per hour
Timeline_cleanup= "yes" to clean up every hour after a certain time
Timeline_min_age= "1800" Timing cleanup parameters: Minimum time to Live (s)
timeline_limit_hourly= "10" maximum number of snapshots per hour
timeline_limit_daily= "10" maximum number of snapshots per day
timeline_limit_monthly= "10" maximum number of snapshots per month
timeline_limit_yearly= "10" No year maximum number of snapshots
empty_pre_post_cleanup= "Yes" clean-up before and after snapshot empty_pre_post_min_age= "1800" the minimum lifetime of the snapshot before and after the non-discrimination
* * View * *
The > Snapshot category has four classes, the latter two of which belong to single
> Pre/post/timeline (Single)/user_defined (single)
\ #snapper-C allfs List
Lists the existing backup snapshots in Allfs-C for the backup configuration--configs
The number 0 in the list indicates the current status.
\ #snapper-C allfs list-t single (pre-post)
List Allfs Summary of existing single (front and rear) snapshots-T--type
* * Create * *
> \ #snapper-C allfs create-t single
Create a single-type snapshot
\ #snapper-C allfs Create--command "yum install Redis"
Execute the command "Yum install Redis" and create a pre-and post-snapshot for it
* * Comparison * *
> \ #snapper-C allfs Status 31..32
Compare snapshots of 31 and 32nd, listing the list of changed files,
Generally small in front, + represents more than 32:31 content, c for modification,-Indicates deleted content
\ #snapper-C allfs diff 31..32
Compare snapshots of 31 and 32nd, listing changes and content lists,
Generally small in front, + represents more than 32:31 content, c for modification,-Indicates deleted content
After a comparison command echoes more results
Rollback recovery
> \ #snapper-C allfs undochange 32..0
Replace the Allfs 32nd number with the current status
* * Modify * *
> \ #snapper-C allfs modify-d ' yum install Redis ' 32
Modify the description of snapshot 32nd to (add) "Yum install Redis"
* * Delete * *
> \ #snapper-C Allfs Delete 3
Delete the Allfs 3rd snapshot, and if the 3rd snapshot is pre-post then another snapshot associated with it will be deleted.
Btrfs-snapper applications