项目作者: weirane

项目描述 :
Automatically manage Btrfs snapshots.
高级语言: Rust
项目地址: git://github.com/weirane/dosnap.git
创建时间: 2020-12-16T13:16:58Z
项目社区:https://github.com/weirane/dosnap

开源协议:GNU General Public License v3.0

下载


dosnap

Automatically manage btrfs snapshots. Inspired by snapper and lilydjwg’s
btrfs-autosnapshot.

DISCLAIMER: This software is in a very early stage. Use it at your own
discretion. I am not responsible for any data loss caused by dosnap.

Installation

Get the dosnap binary from releases, chmod it and put it in your $PATH.

For Arch Linux users, install the binary along with shell completion and systemd
units from the AUR:

  1. paru -S dosnap-git

Install the binary manually:

  1. git clone --depth 1 https://github.com/weirane/dosnap
  2. cd dosnap
  3. cargo install --path .

Configuration

The default path of the configuration file is /etc/dosnap.toml. It can be
overwritten by the -c option.

Global options

  1. # The device to snapshot
  2. device = "/dev/sda2"
  3. # Mount options for the device. Generally, it should include "subvol=/" if the
  4. # default subvolume is not the top-level subvolume
  5. mount_option = ["subvol=/"]
  6. # Parent directory for all snapshots (relative to top-level)
  7. snapshot_root = "_snapshots"

Subvolume options

  1. [[subvolumes]]
  2. # Mount point of this subvolume
  3. filesystem = "/home"
  4. # Relative path of this subvolume to the top-level
  5. path = "@home"
  6. # Limits for auto snapshots. Default to usize::MAX
  7. hourly_limit = 10
  8. daily_limit = 10
  9. weekly_limit = 0
  10. monthly_limit = 10
  11. yearly_limit = 10
  12. # Include this filesystem in `dosnap create -a`. Defaults to false
  13. create = true
  14. # Include this filesystem in `dosnap autoclean -a`. Defaults to false
  15. autoclean = true

Usage

For every filesystem, dosnap stores their snapshots under
<snapshot_root>/<escaped_fs_path>/. The snapshot name is the current datetime
followed by a suffix. Snapshots with the suffix -auto are “auto snapshots”,
which can be cleaned with the autoclean sub-command according to the limits
specified in the config. The concept is similar to snapper’s.

To automatically create and clean auto snapshots, set the subvolume’s create
and autoclean option to true, then start dosnap-create.timer and
dosnap-autoclean.timer. The default is to create snapshots every two hours and
clean every day.

  1. sudo systemctl enable --now dosnap-create.timer dosnap-autoclean.timer

Below are some of the frequently-used commands. For more detail please refer to
the -h flag of the sub-commands or shell completion hints.

list

List the snapshots created for /home.

  1. sudo dosnap list /home

create

Create a snapshot for /home with the default suffix -manual.

  1. sudo dosnap create /home

Create an auto snapshot for /. (--auto is a short hand for --suffix=-auto)

  1. sudo dosnap create --auto /

autoclean

Clean the auto snapshots for /home according to the limits.

  1. sudo dosnap autoclean /home

Clean the auto snapshots for all enabled filesystems.

  1. sudo dosnap autoclean -a

There is a dry-run flag -d.

License

GPL v3. See LICENSE.