docs.coopcloud.tech/docs/abra/cheat-sheet.md

149 lines
3.2 KiB
Markdown

---
title: Cheat sheet
---
# Abra cheat sheet
!!! info
not all flags are listed here.
### Abra Autocomplete
Definitely set up autocomplete or you'll be sad :sob: `abra` supports `bash`,
`zsh`, and `fizsh` just run
```
$ abra autocomplete bash
```
### Create & deploy an app
```
$ abra app new $RECIPE`
```
Optional flags: `-s/--server`, `-D/--domain`, `-S/--secrets`, `-p/--pass`
```
$ abra app config $APPNAME
$ abra app secret generate $APPNAME -a
```
Optional flags: `-p/--pass`, `-a/--all`
```
$ abra app deploy $APPNAME
```
Optional flags: `-f/--force`, `-C/--chaos`
### Restarting an app
To run `restart` you need to specify the `<service>` name with the default being `app`
```
$ abra app restart <domain> app
```
### Undeploy & remove an app
Back up any data you don't want to lose
```
$ abra app undeploy $APPNAME
$ abra app rm --volumes $APPNAME
```
Optional flags: `-f/--force`, `-V/--volumes`
### Upgrade abra
To upgrade `abra` itself, run the following:
```
$ abra upgrade
```
Option flags: `--rc`
### Upgrade a recipe
```
$ abra recipe upgrade $RECIPE`
```
Option flags: `-x,y,z/--major,minor,patch`
```
$ abra recipe sync $RECIPE
```
Optional flags: `-x,y,z`
```
$ abra recipe release $RECIPE [$VERSION]
```
Optional flags: `-p/--publish`, `-r/--dry-run`, `-x,y,z`
### Manually restoring app data
To manually restore app data or configurations, you can use the `cp` command as:
```
$ abra app cp <domain> path/to/.app.conf app:/home/app/
$ abra app cp <domain> path/to/data app:/home/app/
```
*Note: the destination must be a directory and not a filename*
### Make changes to a recipe
Edit the files in `~/.abra/recipe/$RECIPENAME`
Deploy the changed version to your test instance
Determine how serious your change is (semver.org for reference)
```
$ abra recipe release $RECIPE [$VERSION]
```
### Advanced Listing using `jq`
Several `abra` commands can output JSON formatted tables, and can thus be queried and filtered with the tool [jq](https://stedolan.github.io/jq/ "jq JSON Query tool"). We can also format these outputs with [tv](https://github.com/uzimaru0000/tv "tv Table Viewer") into a pretty table.
Currently, `abra recipe ls`, `abra server ls`, and `abra app ls` support the `-m` machine readable output flag which outputs JSON.
#### Filter recipes by "category"
```
$ abra recipe ls -m | jq '[.[] | select(.category == "Utilities") ]' | tv
```
As you can see we, we're selecting all recipes where category is "Utilities".
#### Filter apps by state `deployed`
!!! info
`abra app ls -S` queries each server in your added server list, where as without the `-S` it only lists from your local copy of the sever files (thus providing no information about actual state of the apps)
!!! info
`abra app ls` lists apps grouped into a server object, with statistics about the server. In `jq` we can select the entire apps list with `.[].apps[]`.
```
$ abra app ls -m -S |jq '[.[].apps[] | select(.status == "deployed") | del(.upgrade)]' |tv
```
The `del(.upgrade)` filter filters out available versions for the recipe in question for that row. It could be useful to leave in if you want a list of deployed apps that need an upgrade.