Skip to content

Commit a3bf3b8

Browse files
committed
Initial commit
1 parent 99baad8 commit a3bf3b8

File tree

14 files changed

+869
-3
lines changed

14 files changed

+869
-3
lines changed

.github/workflows/aur.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish to AUR
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'aur/PKGBUILD'
8+
- 'aur/.SRCINFO'
9+
10+
jobs:
11+
aur:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up SSH key for AUR
19+
run: |
20+
mkdir -p ~/.ssh
21+
echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
22+
chmod 600 ~/.ssh/id_ed25519
23+
cat >> ~/.ssh/config <<EOF
24+
Host aur.archlinux.org
25+
User aur
26+
IdentityFile ~/.ssh/id_ed25519
27+
IdentitiesOnly yes
28+
StrictHostKeyChecking no
29+
UserKnownHostsFile=/dev/null
30+
EOF
31+
32+
- name: Push to AUR
33+
run: |
34+
git config --global user.name "github-actions[bot]"
35+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
36+
37+
git clone --depth=1 ssh://aur@aur.archlinux.org/btrfs-rollback.git aur-repo
38+
cp aur/PKGBUILD aur/.SRCINFO aur-repo/
39+
cd aur-repo
40+
git add PKGBUILD .SRCINFO
41+
git commit -m "Update from GitHub Actions" || true
42+
git push

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@ go.work.sum
2828
.env
2929

3030
# Editor/IDE
31-
# .idea/
32-
# .vscode/
31+
.idea/
32+
.vscode/
33+
34+
# Build
35+
btrfs-rollback

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,53 @@
11
# btrfs-rollback
2-
Btrfs rollback tool written in Go for Arch-based distributions
2+
3+
Btrfs rollback tool written in Go for Arch-based distributions.
4+
5+
> [!WARNING]
6+
> This tool is designed to be used in a live environment, such as a live USB or a booted snapshot. **Do not use this tool on your primary system without understanding the consequences.** Running it on the wrong system or environment may result in critical data loss or system instability.
7+
8+
## ⚙️ Configuration
9+
10+
By default, the config file is located at `/etc/btrfs-rollback.toml`:
11+
12+
```toml
13+
# Name of your root subvolume (usually "@")
14+
subvol_main = "@"
15+
16+
# Name of the subvolume where snapshots are stored
17+
subvol_snapshots = "@snapshots"
18+
19+
# Temporary directory where the Btrfs root will be mounted
20+
mountpoint = "/btrfs"
21+
22+
# Path to the Btrfs device. Required only if auto-mounting is needed
23+
dev = "/dev/sda2"
24+
```
25+
26+
Make sure to adjust the configuration to reflect your system's Btrfs setup and the live environment you are working in.
27+
28+
## 🛠️ Installation
29+
30+
### Install via `yay` (AUR):
31+
```bash
32+
yay -S btrfs-rollback
33+
```
34+
This will install the tool from the AUR. Alternatively, you can manually build and install it by cloning the repository and running the following commands:
35+
```bash
36+
git clone https://github.com/xeyossr/btrfs-rollback.git
37+
cd btrfs-rollback
38+
go build .
39+
sudo install -Dm755 btrfs-rollback /usr/bin/btrfs-rollback
40+
```
41+
42+
## 🚀 Usage
43+
1. **Run the tool:** Once installed, you can run the btrfs-rollback tool directly from the command line.
44+
```bash
45+
btrfs-rollback
46+
```
47+
2. **Follow the prompts:** The tool will show a list of available snapshots and allow you to select one for rollback.
48+
49+
## 📜 License
50+
51+
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).
52+
53+
For more details, see the [LICENSE](LICENSE) file.

aur/.SRCINFO

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pkgbase = btrfs-rollback
2+
pkgdesc = Btrfs rollback tool written in Go for Arch-based distributions
3+
pkgver = 1.0.0
4+
pkgrel = 1
5+
url = https://github.com/xeyossr/btrfs-rollback
6+
arch = any
7+
license = GPL3
8+
makedepends = go
9+
depends = btrfs-progs
10+
source = btrfs-rollback-1.0.0.tar.gz::https://github.com/xeyossr/btrfs-rollback/archive/refs/tags/v1.0.0.tar.gz
11+
sha256sums = SKIP
12+
13+
pkgname = btrfs-rollback

aur/PKGBUILD

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Maintainer: kamisaki
2+
# Description: Btrfs rollback tool written in Go for Arch-based distributions
3+
pkgname=btrfs-rollback
4+
pkgver=1.0.0
5+
pkgrel=1
6+
pkgdesc="Btrfs rollback tool written in Go for Arch-based distributions"
7+
arch=('any')
8+
url="https://github.com/xeyossr/btrfs-rollback"
9+
license=('GPL3')
10+
depends=('btrfs-progs')
11+
makedepends=('go')
12+
13+
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/xeyossr/btrfs-rollback/archive/refs/tags/v${pkgver}.tar.gz")
14+
sha256sums=('SKIP')
15+
16+
build() {
17+
cd "$srcdir/$pkgname-$pkgver"
18+
go build -o build/btrfs-rollback .
19+
}
20+
21+
package() {
22+
cd "$srcdir/$pkgname-$pkgver"
23+
install -Dm755 build/btrfs-rollback "${pkgdir}/usr/bin/${pkgname}"
24+
install -Dm644 btrfs-rollback.toml "$pkgdir/etc/btrfs-rollback.toml"
25+
}

btrfs-rollback.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Btrfs Rollback Configuration
2+
#
3+
# This configuration file defines the required paths and subvolume names
4+
# for performing a rollback to a previous Btrfs snapshot.
5+
#
6+
# ⚠️ WARNING:
7+
# This tool is intended to be used in a **live environment** (e.g., booted from
8+
# a Live ISO or from a snapshot itself). Running it directly on a mounted root
9+
# system can cause irreversible damage if not handled properly.
10+
#
11+
# System Requirements:
12+
# - A flat Btrfs subvolume layout as recommended here:
13+
# https://wiki.archlinux.org/title/Snapper#Suggested_filesystem_layout
14+
#
15+
# Terminology:
16+
# - `main`: Your currently active Linux root subvolume (mounted as `/`).
17+
# - `root`: The top-level Btrfs subvolume (`subvolid=5`), which contains all subvolumes.
18+
# Learn more at:
19+
# https://btrfs.readthedocs.io/en/latest/btrfs-subvolume.html#description
20+
#
21+
22+
# Name of your root subvolume (usually "@")
23+
subvol_main = "@"
24+
25+
# Name of the subvolume where snapshots are stored
26+
subvol_snapshots = "@snapshots"
27+
28+
# Temporary directory where the Btrfs root will be mounted
29+
mountpoint = "/btrfs"
30+
31+
# Path to the Btrfs device. Required only if auto-mounting is needed
32+
# dev = "/dev/sda2"

go.mod

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module github.com/xeyossr/btrfs-rollback
2+
3+
go 1.24.5
4+
5+
require (
6+
github.com/BurntSushi/toml v1.5.0
7+
github.com/charmbracelet/bubbles v0.21.0
8+
github.com/charmbracelet/bubbletea v1.3.6
9+
github.com/charmbracelet/lipgloss v1.1.0
10+
github.com/charmbracelet/x/term v0.2.1
11+
github.com/muesli/reflow v0.3.0
12+
github.com/spf13/cobra v1.9.1
13+
)
14+
15+
require (
16+
github.com/atotto/clipboard v0.1.4 // indirect
17+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
18+
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
19+
github.com/charmbracelet/x/ansi v0.9.3 // indirect
20+
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
21+
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
22+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
23+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
24+
github.com/mattn/go-isatty v0.0.20 // indirect
25+
github.com/mattn/go-localereader v0.0.1 // indirect
26+
github.com/mattn/go-runewidth v0.0.16 // indirect
27+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
28+
github.com/muesli/cancelreader v0.2.2 // indirect
29+
github.com/muesli/termenv v0.16.0 // indirect
30+
github.com/rivo/uniseg v0.4.7 // indirect
31+
github.com/sahilm/fuzzy v0.1.1 // indirect
32+
github.com/spf13/pflag v1.0.6 // indirect
33+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
34+
golang.org/x/sync v0.15.0 // indirect
35+
golang.org/x/sys v0.33.0 // indirect
36+
golang.org/x/text v0.3.8 // indirect
37+
)

go.sum

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
2+
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
3+
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
4+
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
5+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
6+
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
7+
github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8=
8+
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
9+
github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs=
10+
github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg=
11+
github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU=
12+
github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc=
13+
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
14+
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
15+
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
16+
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
17+
github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0=
18+
github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
19+
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
20+
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
21+
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
22+
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
23+
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
24+
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
25+
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
26+
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
27+
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
28+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
29+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
30+
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
31+
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
32+
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
33+
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
34+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
35+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
36+
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
37+
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
38+
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
39+
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
40+
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
41+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
42+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
43+
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
44+
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
45+
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
46+
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
47+
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
48+
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
49+
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
50+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
51+
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
52+
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
53+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
54+
github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
55+
github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
56+
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
57+
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
58+
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
59+
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
60+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
61+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
62+
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
63+
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
64+
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
65+
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
66+
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
67+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
68+
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
69+
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
70+
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
71+
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
72+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
73+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)