Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README for a proper v1 release, minor touches to code to match contents of README #8

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 51 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,61 @@
# Snapvault
A PostgreSQL backup tool that effortlessly captures and restores precise snapshots of your database
# Snapvault
![snapvault](snapvault.webp)
A PostgreSQL backup tool that effortlessly captures and restores precise snapshots of your database.
___
**⚠️ Note:** This tool is designed for use during development and should not be used in production.
## 📸 Why Snapvault?
The snapvault CLI tool is intended to be used during local development as an easy way to capture and restore snapshots of the database, making it possible to quickly restore the database to a previous state. It supports basic commands such as `save`, `restore`, `list` and `delete`:


## Usage
```shell
$ snapvault save <snapshot_name>
$ snapvault restore <snapshot_name>
$ snapvault list
$ snapvault delete <snapshot_name>
```

Snapvault is similar to projects like [DLSR](https://github.com/mixxorz/DSLR) and [Stellar](https://github.com/fastmonkeys/stellar). However, unlike those projects snapvault is written in Go and delivered as a standalone binary, making it possible to use the tool without having to rely on Python or managing any other dependencies.

## ⚙️ Installation
Binaries are available in both Intel and ARM versions for OSX/Darwin, Linux and Windows and can be found under the [Releases](https://github.com/cotramarko/snapvault/releases) section.

### Manual Download
```shell
$ snapvault restore <snapshot_name>
# Change binary depending on your platform
$ TARGET=snapvault_Darwin_x86_64
$ sudo curl -fsSL -o /usr/local/bin/snapvault https://github.com/cotramarko/snapvault/releases/latest/download/$TARGET
$ sudo chmod +x /usr/local/bin/snapvault
```
### Using `brew`
```shell
$ snapvault list
$ brew tap cotramarko/tools
$ brew install snapvault
```

## 🔧 How to Use Snapvault

### Specifying Database
The database URL can be specified in multiple ways. Either by a `snapvault.toml` file
(containing `url=<connection-string>`), or by setting the environment variable
`$DATABASE_URL=<connection-string>`, or by passing it as a flag via `--url=<connection-string>`.

The `--url` flag will always override any of the other ways of specifying the URL. If both a
`snapvault.toml` file is present and `$DATABASE_URL` is set, then the `snapvault.toml` file will be prioritised.

### Basic Commands
```shell
$ snapvault delete <snapshot_name>
$ snapvault save fix/foobar
Created snapshot fix/foobar

$ snapvault restore fix/foobar
Restored snapshot fix/foobar

$ snapvault list
╭────────────┬──────────────────────┬─────────╮
│ NAME │ CREATED │ SIZE │
├────────────┼──────────────────────┼─────────┤
│ fix/foobar │ 2024-06-23T15:37:39Z │ 7561 kB │
╰────────────┴──────────────────────┴─────────╯

$ snapvault delete fix/foobar
Deleted snapshot fix/foobar
```
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The database URL can be specified in multiple ways. Either by a snapvault.toml f
$DATABASE_URL=<connection-string>, or by passing it as a flag via --url=<connection-string>.

The --url flag will always override any of the other ways of specifying the URL. If both a
snapvault.toml file is present and $DATABASE_URL is set, then the sv.toml file will be prioritised.
snapvault.toml file is present and $DATABASE_URL is set, then the snapvault.toml file will be prioritised.
`,
// Uncomment the following line if your bare application
// has an action associated with it:
Expand Down
3 changes: 1 addition & 2 deletions cmd/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ var saveCmd = &cobra.Command{
Long: ``,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Creating snapshot", args[0])
e := Engine(cmd)
snapName := engine.SnapName(args[0])
err := commands.Save(*e, snapName)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("snapshot created")
fmt.Println("Created snapshot", args[0])
},
}

Expand Down
Binary file added snapvault.webp
Binary file not shown.
Loading