1 Star 1 Fork 0

範輝 / BTM

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

GitHub top language Latest Version Rust Documentation GitHub Workflow Status Minimum rustc version

BTM

Blockchain Time Machine.

BTM is an incremental data backup mechanism that does not require downtime.

Why would you need this?

btm will give you the following abilities or advantages:

  • rollback to the state of a desired block height
  • hot backup during operation, no downtime is needed
  • based on OS-level infrastructure, stable and reliable
  • very small resource usage, almost no performance damage
  • ...

Library Usages

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();

Binary Usages

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

Install as a 'systemd service'

Steps:

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

Outputs of 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

Usage of 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
MIT License Copyright (c) 2021 Findora Foundation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Blockchain time machine. 展开 收起
Rust 等 3 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Rust
1
https://gitee.com/kt10/btm.git
git@gitee.com:kt10/btm.git
kt10
btm
BTM
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891