Skip to content

Commit 0dee2fe

Browse files
committed
feat: initial commit
0 parents  commit 0dee2fe

File tree

7 files changed

+597
-0
lines changed

7 files changed

+597
-0
lines changed

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
README.md export-ignore

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
### Go ###
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
# Test binary, built with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool, specifically when used with LiteIDE
13+
*.out
14+
15+
# Dependency directories (remove the comment below to include it)
16+
# vendor/
17+
18+
### Go Patch ###
19+
/vendor/
20+
/Godeps/
21+
22+
# IntelliJ paths
23+
.idea
24+
25+
/backmeup
26+
27+
# Exclude actual config - we got the config.sample.yml for this
28+
config.yml

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# backmeup - a lightweight backup utility for the CLI
2+
When managing several servers, you often come across ... I searched for backup tools online but never found an easy-to-use, leightweight, portable, CLI tool which is easy to configure and does not need a remote server for backups.
3+
That's why I created backmeup.
4+
5+
### Key features
6+
- Easy to use
7+
- Define multiple backups in a single config file
8+
- **Portable** - you can copy the **single executable** with a configuration file on all your machines
9+
- **Lightweight** - the executables are ~1 mb
10+
- Exclude files and paths with .gitignore-like syntax
11+
- Group together multiple source paths into one backup
12+
- Config files written in yaml
13+
- Usable from the CLI
14+
- Multi-platform support
15+
16+
# Installation
17+
18+
## Download precompiled executable
19+
Under the releases page you'll always find the most recent builds of backmeup as executables for linux, windows and macos (amd64).
20+
These executables are built with `go build -ldflags="-s -w" .` shrinked with [upx](https://github.com/upx/upx/).
21+
22+
In case that's not suitable for you, you can always build the executable from source.
23+
24+
## Compile from source
25+
This tool is written in Go (golang), so you need to have Go installed on your system first. You can find [installation instructions here](https://golang.org/doc/install).
26+
27+
Then you need to clone the git repository.
28+
Afterwards select the operating system you want to compile for, and the corresponding architecture (Go allows for easy cross compilation) from [this](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63) list.
29+
Set the environment variables `GOOS` and `GOARCH` with those values and eventually use `go build .` to generate an executable.
30+
```bash
31+
$ git clone https://github.com/d-Rickyy-b/backmeup
32+
$ cd backmeup
33+
$ GOOS="linux" && GOARCH="amd64"
34+
$ go build -ldflags="-s -w" .
35+
```
36+
After that you have an executable named `backmeup` in your current working directory.
37+
38+
## Making it persistent
39+
While backmeup is meant to be portable and can be executed from everywhere, you might want to permanently install it on your system.
40+
On linux you can simply move the file into the `/bin/` directory.
41+
```bash
42+
$ mv backmeup /bin/backmeup
43+
```
44+
45+
On Windows, you can create a new directory in the `Program Files` directory and move the binary there.
46+
```
47+
> mkdir C:\Program Files\backmeup\
48+
> mv backmeup.exe C:\Program Files\backmeup\backmeup.exe
49+
```
50+
51+
# Usage
52+
All you need for this tool to work is a `config.yml` file. Simply pass the path to that file via the `-c`/`--config` switch.
53+
```
54+
usage: backmeup [-h|--help] -c|--config "<value>" [-v|--verbose]
55+
56+
The lightweight backup tool for the CLI
57+
58+
Arguments:
59+
60+
-h --help Print help information
61+
-c --config Path to the config.yml file
62+
-v --verbose Enable verbose logging. Default: false
63+
```
64+
65+
Starting your backups is as simple as this
66+
```
67+
$ backmeup -c config.yml
68+
```
69+
70+
# How to create a config?
71+
Configuring your backups is easy. Just create a `config.yml` file that contains the information about the sources and destination paths for your backups.
72+
73+
```yaml
74+
backup_unit_name:
75+
sources:
76+
- C:\Users\admin\Documents\
77+
- 'C:\Users\admin\Dropbox'
78+
- "C:\\Users\\admin\\AppData\\Roaming\\.minecraft"
79+
destination: 'C:\backups'
80+
excludes:
81+
- "*.zip"
82+
- "*.rar"
83+
archive_type: "tar.gz"
84+
add_subfolder: false
85+
enabled: true
86+
```
87+
The minimal configuration consists only of the unit's name (obviously), at least one source and the destination path:
88+
89+
```yaml
90+
backup_unit_name:
91+
sources:
92+
- C:\Users\admin\Documents\
93+
destination: 'C:\backups'
94+
```
95+
96+
The name of your backup is the key at root level. Starting from there you can configure the following parameters.
97+
98+
| Parameter | Type | Required | Default | Description |
99+
|---|---|---|---|---|
100+
| sources | list[strings] | Yes | | All paths to the directories you want to include in your backup |
101+
| destination | string | Yes | | The destination directory, where the backup of this unit will be stored at |
102+
| excludes | list[strings] | No | `[]` | .gitignore like filters for excluding files or dirs from the backup |
103+
| archive_type | string | No | `tar.gz` | The type of archive to be used (`tar.gz` or `zip` are valid options) |
104+
| add_subfolder | boolean | No | `false` | Creates a new subfolder in <destination> for this unit if set to true |
105+
| enabled | boolean | No | `true` | Switch to disable each unit individually |
106+
107+
Take care when using quotes in paths. For most strings you don't even need to use quotes at all. When using double quotes (`"`), you must escape backslashes (`\`) when you want to use them as literal characters (such as in Windows paths).
108+
Check [this handy article](https://www.yaml.info/learn/quote.html) for learning more about quotes in yaml.

config.sample.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
backup_unit_name:
2+
sources:
3+
- C:\Users\admin\Documents\
4+
- 'C:\Users\admin\Dropbox'
5+
- "C:\\Users\\admin\\AppData\\Roaming\\.minecraft"
6+
destination: 'C:\backups'
7+
excludes:
8+
- "*.zip"
9+
- "*.rar"
10+
archive_type: "tar.gz"
11+
add_subfolder: false
12+
enabled: true
13+
14+
other_unit:
15+
sources:
16+
- C:\Users\admin\Documents\
17+
destination: 'C:\backups'

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module backmeup
2+
3+
go 1.13
4+
5+
require (
6+
github.com/akamensky/argparse v1.2.2
7+
github.com/cheggaaa/pb/v3 v3.0.5
8+
github.com/klauspost/compress v1.11.3
9+
gopkg.in/yaml.v2 v2.3.0
10+
)

go.sum

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
2+
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
3+
github.com/akamensky/argparse v1.2.2 h1:P17T0ZjlUNJuWTPPJ2A5dM1wxarHgHqfYH+AZTo2xQA=
4+
github.com/akamensky/argparse v1.2.2/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
5+
github.com/cheggaaa/pb/v3 v3.0.5 h1:lmZOti7CraK9RSjzExsY53+WWfub9Qv13B5m4ptEoPE=
6+
github.com/cheggaaa/pb/v3 v3.0.5/go.mod h1:X1L61/+36nz9bjIsrDU52qHKOQukUQe2Ge+YvGuquCw=
7+
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
8+
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
9+
github.com/klauspost/compress v1.11.3 h1:dB4Bn0tN3wdCzQxnS8r06kV74qN/TAfaIS0bVE8h3jc=
10+
github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
11+
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
12+
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
13+
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
14+
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
15+
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
16+
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
17+
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
18+
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
19+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
20+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
21+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
22+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
23+
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
24+
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

0 commit comments

Comments
 (0)