Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sdelements/flan
A tasty tool that lets you save, load and share postgres snapshots with ease
https://github.com/sdelements/flan
cli command-line git postgres postgresql sql
Last synced: about 2 hours ago
JSON representation
A tasty tool that lets you save, load and share postgres snapshots with ease
- Host: GitHub
- URL: https://github.com/sdelements/flan
- Owner: sdelements
- License: mit
- Created: 2021-07-02T14:56:59.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-29T17:54:50.000Z (about 3 years ago)
- Last Synced: 2024-09-23T07:45:31.267Z (about 1 month ago)
- Topics: cli, command-line, git, postgres, postgresql, sql
- Language: TypeScript
- Homepage:
- Size: 348 KB
- Stars: 182
- Watchers: 11
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A tasty tool that lets you save, load and share postgres snapshots with ease.# Usage
```sh-session
$ npm install -g @sdelements/flan$ flan init
running setup...$ flan save [email protected]
saving...$ flan load [email protected]
loading...$ flan publish [email protected]
publishing...$ flan available
available snapshots...$ flan (-v|--version|version)
@sdelements/flan/0.1.0-alpha.0 darwin-x64 node-v14.16.1$ flan --help [COMMAND]
USAGE
$ flan COMMAND
...
```# How it works
Under the hood flan is a convenient wrapper for `pgdump` and `pgrestore`. It uses parallel jobs by default to ensure dumping/restoring your database is quick.
Sharing database dumps is achieved by leveraging `git`. Essentially you push a tag to a repository of your choosing (defined in `flan.config.js`) and others can then pull it with `flan fetch`. We chose to use git because it fits well with our internal tooling and process but we understand it may not be the best solution for you. Pull requests are welcome if you're interested in using S3/Azure/etc as a store 🙂
> :warning: **WARNING**: Please don't use flan in situations where you can't afford data loss.
# Commands
- [`flan autocomplete [SHELL]`](#flan-autocomplete-shell)
- [`flan available`](#flan-available)
- [`flan delete DELETEFILE`](#flan-delete-deletefile)
- [`flan fetch FILE`](#flan-fetch-file)
- [`flan help [COMMAND]`](#flan-help-command)
- [`flan init`](#flan-init)
- [`flan list`](#flan-list)
- [`flan load INPUT`](#flan-load-input)
- [`flan publish FILE`](#flan-publish-file)
- [`flan save OUTPUT`](#flan-save-output)
- [`flan unpublish FILE`](#flan-unpublish-file)## `flan autocomplete [SHELL]`
display autocomplete installation instructions
```
USAGE
$ flan autocomplete [SHELL]ARGUMENTS
SHELL shell typeOPTIONS
-r, --refresh-cache Refresh cache (ignores displaying instructions)EXAMPLES
$ flan autocomplete
$ flan autocomplete bash
$ flan autocomplete zsh
$ flan autocomplete --refresh-cache
```_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v0.3.0/src/commands/autocomplete/index.ts)_
## `flan available`
lists available dumps
```
USAGE
$ flan availableOPTIONS
-c, --config=config [default: ./flan.config.json] Path to configuration file
-x, --extended show extra columns
--columns=columns only show provided columns (comma-separated)
--csv output is csv format [alias: --output=csv]
--filter=filter filter property by partial string matching, ex: name=foo
--no-header hide table header from output
--no-truncate do not truncate output to fit screen
--output=csv|json|yaml output in a more machine friendly format
--sort=sort [default: tag] property to sort by (prepend '-' for descending)EXAMPLE
$ flan available
```_See code: [src/commands/available.ts](https://github.com/sdelements/flan/blob/v0.1.0-alpha.10/src/commands/available.ts)_
## `flan delete DELETEFILE`
delete a local database dump
```
USAGE
$ flan delete DELETEFILEARGUMENTS
DELETEFILE name of file to deleteOPTIONS
-c, --config=config [default: ./flan.config.json] Path to configuration fileEXAMPLES
$ flan delete myDB
$ flan delete [email protected]
```_See code: [src/commands/delete.ts](https://github.com/sdelements/flan/blob/v0.1.0-alpha.10/src/commands/delete.ts)_
## `flan fetch FILE`
fetch specified dump file from a remote repository
```
USAGE
$ flan fetch FILEARGUMENTS
FILE name of the fileOPTIONS
-c, --config=config [default: ./flan.config.json] Path to configuration fileEXAMPLE
$ flan fetch filename
```_See code: [src/commands/fetch.ts](https://github.com/sdelements/flan/blob/v0.1.0-alpha.10/src/commands/fetch.ts)_
## `flan help [COMMAND]`
display help for flan
```
USAGE
$ flan help [COMMAND]ARGUMENTS
COMMAND command to show help forOPTIONS
--all see all commands in CLI
```_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.2/src/commands/help.ts)_
## `flan init`
Initializes flan for this project
```
USAGE
$ flan initOPTIONS
-c, --config=config [default: ./flan.config.json] Path to configuration file
-y, --yes Auto confirm directory creating questionsEXAMPLES
$ flan init
Config file found at home/flan.config.js$ flan init
A config file will be created, continue? [y/n]$ flan init -c /some-folder/flan.config.json
Config file found at home/flan/some-folder/flan.config.json$ flan init -y -c /some-folder/flan.config.json
Config file found at /home/flan/some-folder/flan.config.json
The base directory has been created successfully at /home/flan/some-folder/.flan
The save directory has been created successfully at /home/flan/some-folder/.flan/local
Git repository initialized at /home/flan/some-folder/.flan/repo
```_See code: [src/commands/init.ts](https://github.com/sdelements/flan/blob/v0.1.0-alpha.10/src/commands/init.ts)_
## `flan list`
lists available dumps
```
USAGE
$ flan listOPTIONS
-c, --config=config [default: ./flan.config.json] Path to configuration fileEXAMPLE
$ flan list
```_See code: [src/commands/list.ts](https://github.com/sdelements/flan/blob/v0.1.0-alpha.10/src/commands/list.ts)_
## `flan load INPUT`
load database from dump
```
USAGE
$ flan load INPUTARGUMENTS
INPUT name of input fileOPTIONS
-c, --config=config [default: ./flan.config.json] Path to configuration file
--drop-db Drops and re-creates the DB before restoring it's data
--quiet Supress errors from pg_restoreEXAMPLES
$ flan load myDB
$ flan load --drop-db --quiet myDB
```_See code: [src/commands/load.ts](https://github.com/sdelements/flan/blob/v0.1.0-alpha.10/src/commands/load.ts)_
## `flan publish FILE`
publish specified dump file to a remote repository
```
USAGE
$ flan publish FILEARGUMENTS
FILE name of the fileOPTIONS
-c, --config=config [default: ./flan.config.json] Path to configuration fileEXAMPLE
$ flan publish filename
```_See code: [src/commands/publish.ts](https://github.com/sdelements/flan/blob/v0.1.0-alpha.10/src/commands/publish.ts)_
## `flan save OUTPUT`
save current database to dump
```
USAGE
$ flan save OUTPUTARGUMENTS
OUTPUT name of output fileOPTIONS
-c, --config=config [default: ./flan.config.json] Path to configuration fileEXAMPLE
$ flan save myDB
```_See code: [src/commands/save.ts](https://github.com/sdelements/flan/blob/v0.1.0-alpha.10/src/commands/save.ts)_
## `flan unpublish FILE`
unpublish specified database dump from a remote repository
```
USAGE
$ flan unpublish FILEARGUMENTS
FILE name of the fileOPTIONS
-c, --config=config [default: ./flan.config.json] Path to configuration fileEXAMPLE
$ flan unpublish [email protected]
```_See code: [src/commands/unpublish.ts](https://github.com/sdelements/flan/blob/v0.1.0-alpha.10/src/commands/unpublish.ts)_
From Toronto with love ❤️
👩🍳 :pie: 👨🍳 :pie: 👩🍳 :pie: 👨🍳 :pie: 👨🍳
Built by Team Pie
Special thanks to @revangel for the logo