Skip to content

Commit

Permalink
feat: Provide basic scripts to create/backup/restore Postgis/Mariadb …
Browse files Browse the repository at this point in the history
…databases (close #230)
  • Loading branch information
Christophe Nouguier committed Mar 17, 2021
1 parent 7b061ce commit 540753d
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ function getReferenceSidebar () {
return [
'environment',
'cli',
'helper-scripts'
'helper-scripts',
'scripts-library'
]
}

Expand Down
192 changes: 192 additions & 0 deletions docs/reference/scripts-library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
---
sidebarDepth: 3
---

# Scripts library

## file

### file_exists

Returns whether the given file exists or not.

Usage: `file_exists <file>`

### directory_exists

Returns whether the given directory exists or not.

Usage: `directory_exists <directory>`

### file_path_exists

Returns whether the given file path (file or directory) exists or not.

Usage: `file_path_exists <file_path>`

### delete_file_if_exists

Deletes the given file if it exists.

Usage: `delete_file_if_exist <file>`

### create_directory_if_not_exist

Creates the given directory if it does not exist

Usage: `create_directory_if_not_exist <directory`

### delete_directory_if_exist

Deletes the given directory if it exists.

Usage: `delete_directory_if_exist <directory`

## log

### log_info

Displays informational messages.

Usage: `log_info <message>`

### log_warning

Displays warning messages.

Usage: `log_warning <message>`

### log_error

Displays error messages.

Usage: `log_error <message>`

## mariadb

### mariadb_db_exists

Returns whether the given database exists.

Usage: `mariadb_db_exists <database>`

### create_mariadb_db

Creates the given database.

Usage: `create_mariadb_db <database>`

### create_mariadb_user

Creates the given user and grants him the privileges to access the specified database.

Usage: `create_mariadb_user <user> <password> <database>`

### drop_mariadb_db

Deletes the given database.

Usage: `drop_mariadb_db <database>`

### drop_mariadb_user()

Deletes the given user.

Usage: `drop_mariadb_user <user>`

### backup_mariadb_db()

Backup the given database to the specified directory. The generated backup file compressed using **gzip** and is named accordingly the name of the database, e.g. `<database>.gz`.

Usage: `backup_mariadb_db <user> <password> <database> <directory>`

### restore_mariadb_db()

Restore the given database from the specified backup file. The backup file must be compressed using **gzip** compression and located in the specified directory.

Usage: `restore_mariadb_db <user> <password> <database> <directory>`

## postgis

### postgis_db_exists

Returns whether the given database exists.

Usage: `postgis_db_exists <database>`

### create_postgis_db

Creates the given database.

Usage: `create_postgis_db <database>`

### create_postgis_user

Creates the given user and grants him the privileges to access the specified database.

Usage: `create_postgis_user <user> <password> <database>`

### drop_postgis_db

Deletes the given database.

Usage: `drop_postgis_db <database>`

### drop_postgis_user()

Deletes the given user.

Usage: `drop_postgis_user <user>`

### backup_postgis_db()

Backup the given database to the specified directory. The generated backup file compressed using **gzip** and is named accordingly the name of the database, e.g. `<database>.gz`.

Usage: `backup_postgis_db <user> <password> <database> <directory>`

### restore_postgis_db()

Restore the given database from the specified backup file. The backup file must be compressed using **gzip** compression and located in the specified directory.

Usage: `restore_postgis_db <user> <password> <database> <directory>`

## rclone

### remote_exists

Returns whether the given remote exists.

Usage: `remote_exists <remote>`

### copy_to_remote

Copy the given source to the specified remote location

Usage: `copy_to_store <remote> <source> <destination>`

### copy_from_remote

Copy from given remote source to the specified location

Usage: `copy_from_store <remote> <source> <destination>`

## slack

### notify_slack

Send an informational message to slack

Usage: `notify_slack <message> [default|good|danger]`

### notify_slack_good

Send a message with the style `good` to slack.

Usage: `notify_slack_good <message>`

### notify_slack_danger

Send a message with the style `danger` to slack.

Usage: `notify_slack_danger <message>`

4 changes: 2 additions & 2 deletions scripts/rclone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ remote_exists () {
return 0
}

copy_to_store() {
copy_to_remote() {
local REMOTE=$1
local SOURCE=$2
local DESTINATION=$3
Expand All @@ -37,7 +37,7 @@ copy_to_store() {
return 1
}

copy_from_store() {
copy_from_remote() {
local REMOTE=$1
local SOURCE=$2
local DESTINATION=$3
Expand Down

0 comments on commit 540753d

Please sign in to comment.