16 个版本 (9 个破坏性更新)
0.15.0 | 2024 年 6 月 28 日 |
---|---|
0.14.1 | 2023 年 7 月 24 日 |
0.14.0 | 2023 年 6 月 18 日 |
0.13.0 | 2023 年 3 月 15 日 |
0.1.6 |
|
#8 in #vcs
每月 144 次下载
39KB
821 代码行
BTM
区块链时间机器。
BTM 是一种无需停机时间的增量数据备份机制。
为什么你需要这个?
btm 将为您提供以下能力或优势
- 回滚到所需的区块高度状态
- 操作期间热备份,无需停机时间
- 基于操作系统级基础设施,稳定可靠
- 资源使用非常小,几乎无性能损害
- ...
库用法
use btm::{BtmCfg, SnapMode, SnapAlgo};
let cfg = BtmCfg {
itv: 10,
cap: 100,
mode: SnapMode::Zfs,
algo: SnapAlgo::Fade,
volume: "zroot/data".to_owned(),
};
// Generate snapshots in some threads.
cfg.snapshot(0).unwrap();
cfg.snapshot(1).unwrap();
cfg.snapshot(11).unwrap();
/// Print all existing snapshots.
cfg.list_snapshots();
/// Rollback to the state of the last snapshot.
cfg.rollback(None, false).unwrap();
/// Rollback to the state of a custom snapshot.
cfg.rollback(Some(11), true).unwrap();
二进制用法
Usage: btm <COMMAND>
Commands:
list List all existing snapshots
rollback Rollback to the state of an existing snapshot
clean Clean all or part of existing snapshots
daemon Run btm as a daemon process
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help information
-V, --version Print version information
Usage: btm list [OPTIONS]
Options:
-p, --volume <VOLUME> The target volume to operate on, if $BTM_VOLUME is specified, this option can be omitted
-h, --help Print help information
Usage: btm rollback [OPTIONS]
Options:
-p, --volume <VOLUME> The target volume to operate on, if $BTM_VOLUME is specified, this option can be omitted
-s, --snapshot-id <SNAPSHOT_ID> The target snapshot to rollback to, a negative value means the latest snapshot [default: -1]
-S, --strict In this mode, if `snapshot_id` cannot be matched exactly, an error will be returned
-h, --help Print help information
Usage: btm clean [OPTIONS]
Options:
-p, --volume <VOLUME> The target volume to operate on, if $BTM_VOLUME is specified, this option can be omitted
-k, --kept <KEPT> How many snapshots should be kept [default: 0]
-h, --help Print help information
Usage: btm daemon [OPTIONS]
Options:
-p, --volume <VOLUME> The target volume to operate on, if $BTM_VOLUME is specified, this option can be omitted
-i, --itv <ITV> The interval between two adjacent snapshots [default: 10]
-c, --cap <CAP> The maximum number of snapshots to keep, older snapshots will be cleaned up [default: 100]
-m, --mode <MODE> Optional, `zfs` or `btrfs`, case insensitive, will try to automatically identify if not specified
-a, --algo <ALGO> fair or fade, case insensitive [default: Fair]
-h, --help Print help information
作为 'systemd 服务' 安装
步骤
make
mv btm_package.tar.gz /tmp/
cd /tmp/
tar -xpf btm_package.tar.gz
cd btm_package
su # swith your user account to 'root'
./install.sh \
--snapshot-itv=4 \
--snapshot-cap=100 \
--snapshot-mode=zfs \
--snapshot-algo=fade \
--snapshot-volume=zfs/data
systemctl status btm-daemon.service
的输出
● btm-daemon.service - "btm daemon"
Loaded: loaded (/lib/systemd/system/btm-daemon.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-10-12 21:24:16 CST; 2min 27s ago
Main PID: 334 (btm)
Tasks: 1 (limit: 37805)
CPU: 1ms
CGroup: /system.slice/btm-daemon.service
└─334 /usr/local/bin/btm daemon -p=/data -i=4 -c=100 -m=btrfs -a=fade
tools/install.sh 的用法
# tools/install.sh -h
Usage
install.sh
--snapshot-itv=<ITV>
--snapshot-cap=<CAP>
--snapshot-mode=<MODE>
--snapshot-algo=<ALGO>
--snapshot-volume=<VOLUME>
Example
install.sh \
--snapshot-itv=4 \
--snapshot-cap=100 \
--snapshot-mode=zfs \
--snapshot-algo=fair \
--snapshot-volume=zfs/blockchain
Example, short style
install.sh -i=4 -c=100 -m=zfs -a=fair -p=zfs/blockchain
install.sh -i=4 -c=100 -m=btrfs -a=fair -p=/data/blockchain
依赖项
~3–4.5MB
~93K SLoC