Skip to content

Commit 9946f52

Browse files
committed
docs: ✨ update docs
1 parent d72b5e3 commit 9946f52

File tree

5 files changed

+66
-12
lines changed

5 files changed

+66
-12
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ clap = { version = "4.5.1", features = ["derive"] }
1717
humansize = { version = "2.1.3", features = ["impl_style"] }
1818
opendal = { version = "0.45.0", features = ["layers-tracing"] }
1919
serde = { version = "1.0.197", features = ["derive"] }
20-
tempfile = "3.10.0"
20+
tempfile = "3.10.1"
2121
tokio = { version = "1.36.0", features = [
2222
"macros",
2323
"process",

README.md

+48-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,48 @@
1-
# SelfhostBackup
1+
# SelfhostBackup
2+
3+
![GitHub Release](https://img.shields.io/github/v/release/Koro33/s-backup) ![GitHub License](https://img.shields.io/github/license/Koro33/s-backup) ![GitHub Repo stars](https://img.shields.io/github/stars/Koro33/s-backup)
4+
5+
Use S3 (or compatible) storage service to backup your selfhosted service configurations.
6+
7+
## Motivation
8+
9+
Some of the cloud storage services(e.g. Backblaze, Cloudflare R2) provided free tier. Our individual users can use it free of charge, to backup small amount of data, e.g. selfhosted service configurations or data. This project aims to make it happen(and easy).
10+
11+
## Usage
12+
13+
### docker (recommend)
14+
15+
```sh
16+
docker run -d \
17+
-v /path/to/config.toml:/app/config.toml \
18+
-v /path/to/backup:/backup_path_in_config:ro \
19+
ghcr.io/koro33/s-backup:latest \
20+
run
21+
```
22+
23+
or docker compose, see [docker-compose.yml](./docker-compose.yml)
24+
25+
**A config file should be provided**. see [config.example.toml](./config.example.toml)
26+
27+
to test the config
28+
29+
```sh
30+
docker run \
31+
-v /path/to/config.toml:/app/config.toml \
32+
ghcr.io/koro33/s-backup:latest \
33+
test
34+
```
35+
36+
### Cli
37+
38+
```sh
39+
# run according to config
40+
s-backup run --config /path/to/config.toml
41+
42+
# test config
43+
s-backup test --config /path/to/config.toml
44+
```
45+
46+
## warning
47+
48+
- **For backblaze(b2) user** since versioning is enabled, the delete opration will not really delete the files. it will create a new file with the same fileanme and set it to hidden. If you really want to delete the old backup(to avoid beyond free tier storage capacity), go backet `Lifecycle Settings`, and set it to `Keep only the last version`. As the docs say, "This rule keeps only the most current version of a file. The previous version of the file is “hidden” for **one day** and then deleted"

config.example.toml

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1+
# provide s3 configuration
12
[s3]
23
access_key_id = "0000000000000000000000000"
34
bucket = "bucket_name"
45
endpoint = "endpoint_name"
56
region = "region_name"
67
secret_access_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
78

9+
# backup task configuration
810
[[backup]]
9-
exclude = ["exclude", "data"]
10-
name = "test"
11-
path = "../test-rust"
12-
interval = 86400
13-
keep = 5
11+
exclude = ["./some_path", "./another/path"] # exclude path (relative path to the `path` in this section)
12+
interval = 86400 # run backup every n seconds
13+
keep = 5 # keep n backups (default: 5)
14+
name = "backup_task_1" # backup name (should be unique between tasks)
15+
path = "/backup/path" # location (see volume in docker-compose.yml)
1416

17+
# another task
1518
[[backup]]
16-
exclude = ["exclude", "data"]
17-
name = "test2"
18-
path = "../test-rust"
19+
exclude = ["path", "to", "exclude"]
1920
interval = 43200
21+
name = "backup_task_2"
22+
path = "/backup/path"
23+
24+
# ...

docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ version: '3'
22

33
services:
44
s-backup:
5-
image: s-backup:latest
5+
image: ghcr.io/koro33/s-backup:latest
66
restart: unless-stopped
77
environment:
88
- TZ=Etc/UTC
99
volumes:
10-
- ./config.toml:/app/config.toml
10+
- /path/to/config.toml:/app/config.toml # config.toml
1111
- /path/to/backup:/backup_path_in_config:ro
1212
command: [run, --config, ./config.toml]

src/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ async fn period_backup(b: &Backup, s3_oprator: &Operator) -> Result<()> {
9393
}
9494

9595
async fn backup(b: &Backup, s3_oprator: &Operator) -> Result<()> {
96+
tracing::info!("[{}] Start backup", b.name);
97+
9698
let entries = s3_oprator.list("/").await.map_err(|e| {
9799
tracing::error!("connect to s3 failed: {}", e);
98100
e

0 commit comments

Comments
 (0)